@quereus/quereus 4.21.1 → 4.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/core/database-cardinality-feedback.d.ts +259 -0
- package/dist/src/core/database-cardinality-feedback.d.ts.map +1 -0
- package/dist/src/core/database-cardinality-feedback.js +547 -0
- package/dist/src/core/database-cardinality-feedback.js.map +1 -0
- package/dist/src/core/database-transaction.d.ts +9 -2
- package/dist/src/core/database-transaction.d.ts.map +1 -1
- package/dist/src/core/database-transaction.js +27 -9
- package/dist/src/core/database-transaction.js.map +1 -1
- package/dist/src/core/database.d.ts +5 -0
- package/dist/src/core/database.d.ts.map +1 -1
- package/dist/src/core/database.js +86 -7
- package/dist/src/core/database.js.map +1 -1
- package/dist/src/core/statement.d.ts +16 -2
- package/dist/src/core/statement.d.ts.map +1 -1
- package/dist/src/core/statement.js +55 -2
- package/dist/src/core/statement.js.map +1 -1
- package/dist/src/func/builtins/cardinality-feedback.d.ts +15 -0
- package/dist/src/func/builtins/cardinality-feedback.d.ts.map +1 -0
- package/dist/src/func/builtins/cardinality-feedback.js +106 -0
- package/dist/src/func/builtins/cardinality-feedback.js.map +1 -0
- package/dist/src/func/builtins/explain.d.ts.map +1 -1
- package/dist/src/func/builtins/explain.js +3 -1
- package/dist/src/func/builtins/explain.js.map +1 -1
- package/dist/src/func/builtins/index.d.ts.map +1 -1
- package/dist/src/func/builtins/index.js +3 -0
- package/dist/src/func/builtins/index.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/planner/cost/index.d.ts +25 -19
- package/dist/src/planner/cost/index.d.ts.map +1 -1
- package/dist/src/planner/cost/index.js +28 -21
- package/dist/src/planner/cost/index.js.map +1 -1
- package/dist/src/planner/framework/trace.js +2 -2
- package/dist/src/planner/framework/trace.js.map +1 -1
- package/dist/src/planner/nodes/aggregate-node.d.ts +2 -1
- package/dist/src/planner/nodes/aggregate-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/aggregate-node.js +1 -0
- package/dist/src/planner/nodes/aggregate-node.js.map +1 -1
- package/dist/src/planner/nodes/filter.d.ts.map +1 -1
- package/dist/src/planner/nodes/filter.js +5 -10
- package/dist/src/planner/nodes/filter.js.map +1 -1
- package/dist/src/planner/nodes/hash-aggregate.d.ts +2 -1
- package/dist/src/planner/nodes/hash-aggregate.d.ts.map +1 -1
- package/dist/src/planner/nodes/hash-aggregate.js +1 -0
- package/dist/src/planner/nodes/hash-aggregate.js.map +1 -1
- package/dist/src/planner/nodes/plan-node.d.ts +11 -0
- package/dist/src/planner/nodes/plan-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/plan-node.js +3 -0
- package/dist/src/planner/nodes/plan-node.js.map +1 -1
- package/dist/src/planner/nodes/reference.d.ts +7 -0
- package/dist/src/planner/nodes/reference.d.ts.map +1 -1
- package/dist/src/planner/nodes/reference.js +17 -3
- package/dist/src/planner/nodes/reference.js.map +1 -1
- package/dist/src/planner/nodes/stream-aggregate.d.ts +2 -1
- package/dist/src/planner/nodes/stream-aggregate.d.ts.map +1 -1
- package/dist/src/planner/nodes/stream-aggregate.js +1 -0
- package/dist/src/planner/nodes/stream-aggregate.js.map +1 -1
- package/dist/src/planner/nodes/table-access-nodes.d.ts +14 -1
- package/dist/src/planner/nodes/table-access-nodes.d.ts.map +1 -1
- package/dist/src/planner/nodes/table-access-nodes.js +52 -20
- package/dist/src/planner/nodes/table-access-nodes.js.map +1 -1
- package/dist/src/planner/optimizer-tuning.d.ts +67 -7
- package/dist/src/planner/optimizer-tuning.d.ts.map +1 -1
- package/dist/src/planner/optimizer-tuning.js +14 -3
- package/dist/src/planner/optimizer-tuning.js.map +1 -1
- package/dist/src/planner/rules/access/rule-key-set-seek.d.ts +9 -0
- package/dist/src/planner/rules/access/rule-key-set-seek.d.ts.map +1 -1
- package/dist/src/planner/rules/access/rule-key-set-seek.js +18 -12
- package/dist/src/planner/rules/access/rule-key-set-seek.js.map +1 -1
- package/dist/src/planner/rules/access/rule-select-access-path.d.ts.map +1 -1
- package/dist/src/planner/rules/access/rule-select-access-path.js +7 -8
- package/dist/src/planner/rules/access/rule-select-access-path.js.map +1 -1
- package/dist/src/planner/rules/aggregate/rule-aggregate-streaming.js +1 -1
- package/dist/src/planner/rules/aggregate/rule-aggregate-streaming.js.map +1 -1
- package/dist/src/planner/rules/cache/rule-nested-loop-right-cache.d.ts.map +1 -1
- package/dist/src/planner/rules/cache/rule-nested-loop-right-cache.js +7 -0
- package/dist/src/planner/rules/cache/rule-nested-loop-right-cache.js.map +1 -1
- package/dist/src/planner/rules/join/index-nested-loop.d.ts +6 -2
- package/dist/src/planner/rules/join/index-nested-loop.d.ts.map +1 -1
- package/dist/src/planner/rules/join/index-nested-loop.js +20 -14
- package/dist/src/planner/rules/join/index-nested-loop.js.map +1 -1
- package/dist/src/planner/rules/join/rule-fanout-batched-outer.d.ts.map +1 -1
- package/dist/src/planner/rules/join/rule-fanout-batched-outer.js +5 -0
- package/dist/src/planner/rules/join/rule-fanout-batched-outer.js.map +1 -1
- package/dist/src/planner/rules/join/rule-join-physical-selection.d.ts.map +1 -1
- package/dist/src/planner/rules/join/rule-join-physical-selection.js +102 -53
- package/dist/src/planner/rules/join/rule-join-physical-selection.js.map +1 -1
- package/dist/src/planner/rules/join/rule-monotonic-merge-join.d.ts +1 -1
- package/dist/src/planner/rules/join/rule-monotonic-merge-join.d.ts.map +1 -1
- package/dist/src/planner/rules/join/rule-monotonic-merge-join.js +15 -6
- package/dist/src/planner/rules/join/rule-monotonic-merge-join.js.map +1 -1
- package/dist/src/planner/rules/join/rule-quickpick-enumeration.d.ts.map +1 -1
- package/dist/src/planner/rules/join/rule-quickpick-enumeration.js +8 -1
- package/dist/src/planner/rules/join/rule-quickpick-enumeration.js.map +1 -1
- package/dist/src/planner/rules/retrieve/rule-grow-retrieve.d.ts.map +1 -1
- package/dist/src/planner/rules/retrieve/rule-grow-retrieve.js +7 -6
- package/dist/src/planner/rules/retrieve/rule-grow-retrieve.js.map +1 -1
- package/dist/src/planner/stats/catalog-stats.d.ts +11 -2
- package/dist/src/planner/stats/catalog-stats.d.ts.map +1 -1
- package/dist/src/planner/stats/catalog-stats.js +14 -5
- package/dist/src/planner/stats/catalog-stats.js.map +1 -1
- package/dist/src/planner/stats/table-cardinality.d.ts +146 -23
- package/dist/src/planner/stats/table-cardinality.d.ts.map +1 -1
- package/dist/src/planner/stats/table-cardinality.js +159 -23
- package/dist/src/planner/stats/table-cardinality.js.map +1 -1
- package/dist/src/planner/util/relative-rows.d.ts +29 -0
- package/dist/src/planner/util/relative-rows.d.ts.map +1 -0
- package/dist/src/planner/util/relative-rows.js +67 -0
- package/dist/src/planner/util/relative-rows.js.map +1 -0
- package/dist/src/planner/util/row-estimates.d.ts +23 -0
- package/dist/src/planner/util/row-estimates.d.ts.map +1 -1
- package/dist/src/planner/util/row-estimates.js +29 -0
- package/dist/src/planner/util/row-estimates.js.map +1 -1
- package/dist/src/runtime/cardinality-observations.d.ts +85 -0
- package/dist/src/runtime/cardinality-observations.d.ts.map +1 -0
- package/dist/src/runtime/cardinality-observations.js +103 -0
- package/dist/src/runtime/cardinality-observations.js.map +1 -0
- package/dist/src/runtime/emit/scan.d.ts +1 -1
- package/dist/src/runtime/emit/scan.d.ts.map +1 -1
- package/dist/src/runtime/emit/scan.js +100 -3
- package/dist/src/runtime/emit/scan.js.map +1 -1
- package/dist/src/runtime/parallel-driver.d.ts +3 -0
- package/dist/src/runtime/parallel-driver.d.ts.map +1 -1
- package/dist/src/runtime/parallel-driver.js +4 -0
- package/dist/src/runtime/parallel-driver.js.map +1 -1
- package/dist/src/runtime/types.d.ts +12 -0
- package/dist/src/runtime/types.d.ts.map +1 -1
- package/dist/src/runtime/types.js.map +1 -1
- package/dist/src/schema/manager.d.ts +7 -0
- package/dist/src/schema/manager.d.ts.map +1 -1
- package/dist/src/schema/manager.js +8 -0
- package/dist/src/schema/manager.js.map +1 -1
- package/dist/src/vtab/filter-info.d.ts +16 -0
- package/dist/src/vtab/filter-info.d.ts.map +1 -1
- package/dist/src/vtab/filter-info.js +29 -0
- package/dist/src/vtab/filter-info.js.map +1 -1
- package/dist/src/vtab/memory/module.d.ts.map +1 -1
- package/dist/src/vtab/memory/module.js +5 -3
- package/dist/src/vtab/memory/module.js.map +1 -1
- package/dist/src/vtab/module.d.ts +53 -0
- package/dist/src/vtab/module.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The observed row-count overlay: exact base-table sizes seen during execution.
|
|
3
|
+
*
|
|
4
|
+
* One per `Database`. The planner reads it through `plannedRowCount`
|
|
5
|
+
* (`planner/stats/table-cardinality.ts`), where an answering entry outranks the
|
|
6
|
+
* catalog's `ANALYZE` count and a module's approximate count, but not a module's
|
|
7
|
+
* exact one, and through `plannedRowsPerKey`, where an entry's rows per key answers
|
|
8
|
+
* unless the catalog's statistics cover the column set. This module owns the record
|
|
9
|
+
* policy — which observations are worth keeping, and when one has moved far enough
|
|
10
|
+
* from what plans were costed against to call it a *shift* — and the entries' lifetime.
|
|
11
|
+
*
|
|
12
|
+
* Validity is schema identity: an entry answers only for the exact `TableSchema`
|
|
13
|
+
* object it was observed under. Any swap (`ANALYZE`, `ALTER TABLE`, drop and
|
|
14
|
+
* re-create) silences it, and a schema-change listener evicts it. The identity
|
|
15
|
+
* check is the correctness guard; the listener is memory hygiene.
|
|
16
|
+
*
|
|
17
|
+
* An entry holds an exact count from a complete read, a floor ("at least N rows") from a
|
|
18
|
+
* partial one, or both; a floor only ever raises an estimate, and an exact count clears it.
|
|
19
|
+
* Beside them it keeps, per equality column set the table is seeked on through a
|
|
20
|
+
* non-unique index, a running mean of the rows one key matched ({@link PerKeyEntry}).
|
|
21
|
+
*
|
|
22
|
+
* Execution feeds it through {@link CardinalityFeedbackManager.publish}, which admits
|
|
23
|
+
* only observations of committed state: one made inside a transaction is held until
|
|
24
|
+
* that transaction commits ({@link CardinalityFeedbackManager.onCommitted}) and
|
|
25
|
+
* dropped if it rolls back ({@link CardinalityFeedbackManager.onRolledBack}).
|
|
26
|
+
*
|
|
27
|
+
* A shift reaches prepared statements through `onShift`; each statement paces its
|
|
28
|
+
* re-plans with a {@link FeedbackReplanState}. A module-reported size, which moves with
|
|
29
|
+
* no observation at all, is re-checked by each statement at execution start against the
|
|
30
|
+
* size its plan was costed with ({@link ReportedSizeSnapshot}).
|
|
31
|
+
*
|
|
32
|
+
* Nothing here is persisted: a new `Database` starts empty. See
|
|
33
|
+
* docs/progressive-optimizer.md §3.2–3.6.
|
|
34
|
+
*/
|
|
35
|
+
import type { OptimizerTuning } from '../planner/optimizer-tuning.js';
|
|
36
|
+
import { CardinalityObservations, type RowsPerKeySpec } from '../runtime/cardinality-observations.js';
|
|
37
|
+
import { type ObservedKeyCardinalities, type ObservedRowCount, type ObservedRowCounts } from '../planner/stats/table-cardinality.js';
|
|
38
|
+
import type { SchemaDependency } from '../planner/planning-context.js';
|
|
39
|
+
import type { TableSchema } from '../schema/table.js';
|
|
40
|
+
import type { Database } from './database.js';
|
|
41
|
+
import type { ModuleRowCount } from '../vtab/module.js';
|
|
42
|
+
/** Database internals the manager needs — keeps it constructible without the full `Database`. */
|
|
43
|
+
export interface CardinalityFeedbackManagerContext {
|
|
44
|
+
readonly schemaManager: Database['schemaManager'];
|
|
45
|
+
/** Read on every record, so `Database.updateOptimizerTuning` takes effect immediately. */
|
|
46
|
+
getTuning(): OptimizerTuning;
|
|
47
|
+
/** True when no transaction (explicit or implicit) is open. */
|
|
48
|
+
getAutocommit(): boolean;
|
|
49
|
+
/** The table's module's own count (`RowCountSources.reportedRows`), ranked with this overlay's entry. */
|
|
50
|
+
reportedRows(table: TableSchema): ModuleRowCount | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* A recorded count, floor or rows-per-key mean moved at least
|
|
53
|
+
* `cardinalityFeedback.shiftFactor` away from its baseline: plans costed against the
|
|
54
|
+
* old number may be wrong. `key` is the lowercased `schema.table` — one key for every
|
|
55
|
+
* kind, so a per-key shift re-plans every statement reading the table, seeking or not.
|
|
56
|
+
*/
|
|
57
|
+
onShift(key: string): void;
|
|
58
|
+
}
|
|
59
|
+
/** By-value view of one column set's rows per key, for tests and diagnostics. */
|
|
60
|
+
export interface ObservedRowsPerKeySnapshot {
|
|
61
|
+
/** Column names, in the order of their sorted indexes. */
|
|
62
|
+
readonly keyColumns: readonly string[];
|
|
63
|
+
readonly rowsPerKey: number;
|
|
64
|
+
readonly samples: number;
|
|
65
|
+
readonly baselineRowsPerKey: number;
|
|
66
|
+
readonly shifts: number;
|
|
67
|
+
}
|
|
68
|
+
/** By-value view of one valid entry, for tests and diagnostics. */
|
|
69
|
+
export interface ObservedRowCountSnapshot {
|
|
70
|
+
readonly schemaName: string;
|
|
71
|
+
readonly tableName: string;
|
|
72
|
+
readonly rows: number | undefined;
|
|
73
|
+
readonly atLeast: number | undefined;
|
|
74
|
+
/** What the catalog (`ANALYZE`) says for the same table; `undefined` when never analyzed. */
|
|
75
|
+
readonly catalogRows: number | undefined;
|
|
76
|
+
readonly baselineRows: number;
|
|
77
|
+
readonly observations: number;
|
|
78
|
+
readonly shifts: number;
|
|
79
|
+
/** Least recently recorded first. */
|
|
80
|
+
readonly perKey: readonly ObservedRowsPerKeySnapshot[];
|
|
81
|
+
}
|
|
82
|
+
/** The overlay's key for a table: lowercased `schema.table`. Shifts are reported under it. */
|
|
83
|
+
export declare function overlayTableKey(schemaName: string, tableName: string): string;
|
|
84
|
+
/**
|
|
85
|
+
* One prepared statement's feedback re-plan cooldown (docs/progressive-optimizer.md §3.6).
|
|
86
|
+
* A shift marks the cached plan; the mark is acted on at an execution start, never
|
|
87
|
+
* mid-execution. The first feedback re-plan is immediate; re-plan `k + 1` waits until the
|
|
88
|
+
* statement has executed `cooldown × 2^min(k − 1, 6)` times since re-plan `k` — a mark
|
|
89
|
+
* arriving sooner stays pending until then.
|
|
90
|
+
*/
|
|
91
|
+
export declare class FeedbackReplanState {
|
|
92
|
+
private marked;
|
|
93
|
+
/** Feedback re-plans so far. */
|
|
94
|
+
private replans;
|
|
95
|
+
/** Executions started since the last feedback re-plan, the re-planning one included. */
|
|
96
|
+
private executionsSinceReplan;
|
|
97
|
+
/** A table the cached plan reads shifted. */
|
|
98
|
+
markShift(): void;
|
|
99
|
+
/** The cached plan was dropped for any reason; whatever compiles next reads the current overlay. */
|
|
100
|
+
onPlanDropped(): void;
|
|
101
|
+
/** Counts one execution; true when the marked plan must be dropped before it runs. */
|
|
102
|
+
onExecutionStart(cooldown: number): boolean;
|
|
103
|
+
private requiredExecutions;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* The planned sizes, as of one compile, of the tables the plan reads whose module reports
|
|
107
|
+
* its own count (docs/progressive-optimizer.md §3.6). Such a count moves on every write
|
|
108
|
+
* with no event the planner hears, and a plan that no longer reads the table in full
|
|
109
|
+
* never produces an observation, so nothing else notices that a table planned at 10 rows
|
|
110
|
+
* now holds a million. A prepared statement compares its snapshot with the current
|
|
111
|
+
* planned sizes at each execution start and treats a drift like an overlay shift.
|
|
112
|
+
*
|
|
113
|
+
* Planned sizes, not raw module answers, are compared, so an approximate count the
|
|
114
|
+
* overlay outranks drifts only when what planning would use drifts.
|
|
115
|
+
*/
|
|
116
|
+
export declare class ReportedSizeSnapshot {
|
|
117
|
+
private readonly sizes;
|
|
118
|
+
static readonly empty: ReportedSizeSnapshot;
|
|
119
|
+
private constructor();
|
|
120
|
+
/**
|
|
121
|
+
* Called right after a compile, in the same synchronous turn, so each size is the one
|
|
122
|
+
* the plan's table references were costed with. Tables whose module has no
|
|
123
|
+
* `getRowCount` are left out: overlay shifts and schema changes already cover them.
|
|
124
|
+
*/
|
|
125
|
+
static capture(db: Database, dependencies: readonly SchemaDependency[]): ReportedSizeSnapshot;
|
|
126
|
+
/**
|
|
127
|
+
* True when some table's planned size has moved `shiftFactor` from the captured one
|
|
128
|
+
* with the larger side above `minRows` — the overlay's shift rule (§3.4). A table whose
|
|
129
|
+
* catalog object was replaced is skipped: that schema change already dropped the plan.
|
|
130
|
+
*/
|
|
131
|
+
drifted(db: Database): boolean;
|
|
132
|
+
}
|
|
133
|
+
export declare class CardinalityFeedbackManager implements ObservedRowCounts, ObservedKeyCardinalities {
|
|
134
|
+
private readonly ctx;
|
|
135
|
+
/**
|
|
136
|
+
* Lowercased `schema.table` → entry, the change-log / work-counter key convention.
|
|
137
|
+
* `Map` insertion order doubles as recency: a hit or a record re-inserts, so the
|
|
138
|
+
* first key is the least recently used.
|
|
139
|
+
*/
|
|
140
|
+
private readonly entries;
|
|
141
|
+
/**
|
|
142
|
+
* Observations made inside the open transaction, held until it ends; same key as
|
|
143
|
+
* `entries`, last count and largest floor per table win. Bounded by the distinct
|
|
144
|
+
* tables one transaction observes.
|
|
145
|
+
*/
|
|
146
|
+
private readonly pending;
|
|
147
|
+
/** {@link onRolledBack} calls so far; each execution's sink records it at start. */
|
|
148
|
+
private rollbacks;
|
|
149
|
+
private unsubscribeSchemaChanges;
|
|
150
|
+
constructor(ctx: CardinalityFeedbackManagerContext);
|
|
151
|
+
observedRows(table: TableSchema): ObservedRowCount | undefined;
|
|
152
|
+
/** The running mean for `columns` on `table`, under the same identity rule as {@link observedRows}; a hit refreshes the table's recency. */
|
|
153
|
+
observedRowsPerKey(table: TableSchema, columns: readonly number[]): number | undefined;
|
|
154
|
+
/**
|
|
155
|
+
* Offer one exact row count of `table`, observed by a complete enumeration of
|
|
156
|
+
* committed state. Applies the record policy (docs/progressive-optimizer.md §3.4):
|
|
157
|
+
* ignored when the schema object is superseded or when both the observation and the
|
|
158
|
+
* current estimate are small; otherwise recorded — clearing any floor, which the newer
|
|
159
|
+
* complete count supersedes — and reported through `onShift` when it has moved
|
|
160
|
+
* `shiftFactor` from the entry's baseline.
|
|
161
|
+
*/
|
|
162
|
+
record(table: TableSchema, rows: number): void;
|
|
163
|
+
/**
|
|
164
|
+
* Offer one floor for `table`: a read of committed state yielded `rows` distinct rows of
|
|
165
|
+
* it, so it holds at least that many (docs/progressive-optimizer.md §3.4). Recorded only
|
|
166
|
+
* when it exceeds both what planning would use now and `minRows`, so a floor never
|
|
167
|
+
* lowers an estimate and never makes an unknown table look smaller than the default it
|
|
168
|
+
* plans at today. Shifts like a count; floors only raise, so they cannot oscillate.
|
|
169
|
+
*/
|
|
170
|
+
recordAtLeast(table: TableSchema, rows: number): void;
|
|
171
|
+
/**
|
|
172
|
+
* Offer `count` samples of rows per key for `spec`'s column set on `table`, summing to
|
|
173
|
+
* `sum` rows — one sample per exhausted equality seek with non-NULL keys
|
|
174
|
+
* (docs/progressive-optimizer.md §3.4). Ignored under a superseded schema, and unless
|
|
175
|
+
* the table's planned size exceeds `minRows`: below that every plan finishes fast, and
|
|
176
|
+
* the gate keeps small-table plans unchanged exactly as the count gate does. So a table
|
|
177
|
+
* of unknown size learns rows per key only once its size is learned (a complete scan,
|
|
178
|
+
* a floor, or a module count above the gate); publication applies per-key batches
|
|
179
|
+
* after the same execution's counts and floors, so one execution can open the gate for
|
|
180
|
+
* itself. A new column-set entry's baseline is the rows per key the plan was priced
|
|
181
|
+
* with; the table remembers at most `maxKeySetsPerTable` sets, least recently recorded
|
|
182
|
+
* evicted. Accepted bias: frequently probed keys weigh more than a uniform sample would.
|
|
183
|
+
* Reported through `onShift` under the table's key when the folded mean has moved
|
|
184
|
+
* `shiftFactor` from the set's baseline — the count rule, applied to the mean.
|
|
185
|
+
*/
|
|
186
|
+
recordRowsPerKey(table: TableSchema, spec: RowsPerKeySpec, sum: number, count: number): void;
|
|
187
|
+
/**
|
|
188
|
+
* Offer one finished execution's observations (docs/progressive-optimizer.md §3.5).
|
|
189
|
+
* A committed read (`readCommitted`) or an execution that ended with no transaction
|
|
190
|
+
* open saw committed state and is recorded now. Anything else may include the open
|
|
191
|
+
* transaction's uncommitted writes, so it is held for {@link onCommitted} — unless a
|
|
192
|
+
* rollback ran during the execution (typically a failing statement's own statement
|
|
193
|
+
* savepoint, which fires before publication): then a completed scan may have counted
|
|
194
|
+
* rows that no longer exist, and the whole execution is discarded.
|
|
195
|
+
*/
|
|
196
|
+
publish(observations: CardinalityObservations, options: {
|
|
197
|
+
readCommitted: boolean;
|
|
198
|
+
}): void;
|
|
199
|
+
/**
|
|
200
|
+
* A fresh per-execution sink, stamped so {@link publish} can tell whether a rollback ran
|
|
201
|
+
* under it, and carrying the record floor so it can drop floors that could never record.
|
|
202
|
+
*/
|
|
203
|
+
beginObservations(): CardinalityObservations;
|
|
204
|
+
/**
|
|
205
|
+
* The open transaction committed: record what it held, except tables it wrote.
|
|
206
|
+
* Such an observation was made mid-transaction, possibly before later writes in the
|
|
207
|
+
* same transaction, and the change log cannot say which came first. `changedCounts` is
|
|
208
|
+
* the change log keyed like `entries` — every table the transaction wrote, even one
|
|
209
|
+
* whose writes cancelled out — and is not built when nothing is held.
|
|
210
|
+
*/
|
|
211
|
+
onCommitted(changedCounts: () => Map<string, number>): void;
|
|
212
|
+
/** The open transaction, or some of its work, was undone: forget everything held. */
|
|
213
|
+
onRolledBack(): void;
|
|
214
|
+
/** Forget every observation, held ones included; later compiles read the catalog only. */
|
|
215
|
+
clear(): void;
|
|
216
|
+
/** Valid entries, by value, least recently used first. Does not refresh recency. */
|
|
217
|
+
snapshot(): ObservedRowCountSnapshot[];
|
|
218
|
+
dispose(): void;
|
|
219
|
+
private subscribeToSchemaChanges;
|
|
220
|
+
/**
|
|
221
|
+
* Exact counts first: a floor at or below the count just recorded is then ignored.
|
|
222
|
+
* Rows per key last, so a count or floor from the same execution can open its table-size gate.
|
|
223
|
+
*/
|
|
224
|
+
private recordAll;
|
|
225
|
+
private holdAll;
|
|
226
|
+
/** What is held for `table`; anything held under an older schema object for its name is superseded. */
|
|
227
|
+
private held;
|
|
228
|
+
/** As {@link recordAll}: the count first, so a floor it already covers is ignored, and rows per key last. */
|
|
229
|
+
private recordHeld;
|
|
230
|
+
private isSuperseded;
|
|
231
|
+
/**
|
|
232
|
+
* What planning would use for `table` right now — `existing` ranked with the module's
|
|
233
|
+
* count and the catalog's (§3.3), else the default — so an exactly module-sized table
|
|
234
|
+
* compares against the module and a scan agreeing with it shifts nothing.
|
|
235
|
+
*/
|
|
236
|
+
private plannedBefore;
|
|
237
|
+
/** Counts one recorded observation on `entry`, makes it the most recent, and enforces the cap. */
|
|
238
|
+
private upsert;
|
|
239
|
+
/** Reports a shift through `onShift` when `rows` has moved `shiftFactor` from the entry's baseline. */
|
|
240
|
+
private shiftIfMoved;
|
|
241
|
+
/**
|
|
242
|
+
* Reports a shift through `onShift` when a column set's mean has moved `shiftFactor`
|
|
243
|
+
* from its baseline. The table key is reported, not the set: a statement that reads the
|
|
244
|
+
* table re-plans and every seek node in it re-snapshots the overlay (§3.6). A set's first
|
|
245
|
+
* record cannot shift when its plan was already priced from the mean (the baseline is what
|
|
246
|
+
* the plan used); a set re-created after eviction carries the module's estimate again and
|
|
247
|
+
* may shift once, landing the same plan.
|
|
248
|
+
*/
|
|
249
|
+
private shiftIfRowsPerKeyMoved;
|
|
250
|
+
/** The entry under `key` if it was observed against `table`; a stale one is replaced on record. */
|
|
251
|
+
private validEntry;
|
|
252
|
+
private touch;
|
|
253
|
+
/**
|
|
254
|
+
* Drop least-recently-used entries past the cap. No `onShift`: plans already built
|
|
255
|
+
* keep their snapshot, and the next compile falls back to catalog or default numbers.
|
|
256
|
+
*/
|
|
257
|
+
private evictBeyond;
|
|
258
|
+
}
|
|
259
|
+
//# sourceMappingURL=database-cardinality-feedback.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"database-cardinality-feedback.d.ts","sourceRoot":"","sources":["../../../src/core/database-cardinality-feedback.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,uBAAuB,EAAwC,KAAK,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAC5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