@quereus/quereus 4.18.0 → 4.19.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/common/types.d.ts +17 -0
- package/dist/src/common/types.d.ts.map +1 -1
- package/dist/src/common/types.js.map +1 -1
- package/dist/src/core/database-assertions.d.ts.map +1 -1
- package/dist/src/core/database-assertions.js +2 -1
- package/dist/src/core/database-assertions.js.map +1 -1
- package/dist/src/core/database-auto-analyze.d.ts +3 -3
- package/dist/src/core/database-auto-analyze.d.ts.map +1 -1
- package/dist/src/core/database-auto-analyze.js +17 -11
- package/dist/src/core/database-auto-analyze.js.map +1 -1
- package/dist/src/core/database-materialized-views-plan-builders.d.ts +11 -2
- package/dist/src/core/database-materialized-views-plan-builders.d.ts.map +1 -1
- package/dist/src/core/database-materialized-views-plan-builders.js +15 -10
- package/dist/src/core/database-materialized-views-plan-builders.js.map +1 -1
- package/dist/src/core/database-watchers.d.ts.map +1 -1
- package/dist/src/core/database-watchers.js +2 -1
- package/dist/src/core/database-watchers.js.map +1 -1
- package/dist/src/func/builtins/explain.d.ts.map +1 -1
- package/dist/src/func/builtins/explain.js +38 -42
- package/dist/src/func/builtins/explain.js.map +1 -1
- package/dist/src/planner/cost/index.d.ts +9 -0
- package/dist/src/planner/cost/index.d.ts.map +1 -1
- package/dist/src/planner/cost/index.js +28 -0
- package/dist/src/planner/cost/index.js.map +1 -1
- package/dist/src/planner/debug.d.ts +5 -0
- package/dist/src/planner/debug.d.ts.map +1 -1
- package/dist/src/planner/debug.js +5 -0
- package/dist/src/planner/debug.js.map +1 -1
- package/dist/src/planner/framework/characteristics.d.ts +0 -22
- package/dist/src/planner/framework/characteristics.d.ts.map +1 -1
- package/dist/src/planner/framework/characteristics.js +0 -3
- package/dist/src/planner/framework/characteristics.js.map +1 -1
- package/dist/src/planner/framework/pass.js +3 -3
- package/dist/src/planner/nodes/async-gather-node.d.ts +13 -0
- package/dist/src/planner/nodes/async-gather-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/async-gather-node.js +19 -29
- package/dist/src/planner/nodes/async-gather-node.js.map +1 -1
- package/dist/src/planner/nodes/constraint-check-node.d.ts +9 -0
- package/dist/src/planner/nodes/constraint-check-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/constraint-check-node.js +13 -0
- package/dist/src/planner/nodes/constraint-check-node.js.map +1 -1
- package/dist/src/planner/nodes/cte-node.d.ts +8 -5
- package/dist/src/planner/nodes/cte-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/cte-node.js +14 -4
- package/dist/src/planner/nodes/cte-node.js.map +1 -1
- package/dist/src/planner/nodes/cte-reference-node.d.ts +9 -1
- package/dist/src/planner/nodes/cte-reference-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/cte-reference-node.js +13 -0
- package/dist/src/planner/nodes/cte-reference-node.js.map +1 -1
- package/dist/src/planner/nodes/delete-node.d.ts +7 -1
- package/dist/src/planner/nodes/delete-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/delete-node.js +12 -2
- package/dist/src/planner/nodes/delete-node.js.map +1 -1
- package/dist/src/planner/nodes/dml-executor-node.d.ts +2 -1
- package/dist/src/planner/nodes/dml-executor-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/dml-executor-node.js +8 -1
- package/dist/src/planner/nodes/dml-executor-node.js.map +1 -1
- package/dist/src/planner/nodes/insert-node.d.ts +8 -1
- package/dist/src/planner/nodes/insert-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/insert-node.js +12 -1
- package/dist/src/planner/nodes/insert-node.js.map +1 -1
- package/dist/src/planner/nodes/join-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/join-node.js +10 -0
- package/dist/src/planner/nodes/join-node.js.map +1 -1
- package/dist/src/planner/nodes/recursive-cte-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/recursive-cte-node.js +7 -0
- package/dist/src/planner/nodes/recursive-cte-node.js.map +1 -1
- package/dist/src/planner/nodes/remote-query-node.d.ts +7 -1
- package/dist/src/planner/nodes/remote-query-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/remote-query-node.js +11 -0
- package/dist/src/planner/nodes/remote-query-node.js.map +1 -1
- package/dist/src/planner/nodes/returning-node.d.ts +4 -0
- package/dist/src/planner/nodes/returning-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/returning-node.js +8 -1
- package/dist/src/planner/nodes/returning-node.js.map +1 -1
- package/dist/src/planner/nodes/set-operation-node.d.ts +14 -1
- package/dist/src/planner/nodes/set-operation-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/set-operation-node.js +22 -1
- package/dist/src/planner/nodes/set-operation-node.js.map +1 -1
- package/dist/src/planner/nodes/sink-node.d.ts +9 -1
- package/dist/src/planner/nodes/sink-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/sink-node.js +12 -0
- package/dist/src/planner/nodes/sink-node.js.map +1 -1
- package/dist/src/planner/nodes/table-access-nodes.d.ts.map +1 -1
- package/dist/src/planner/nodes/table-access-nodes.js +4 -3
- package/dist/src/planner/nodes/table-access-nodes.js.map +1 -1
- package/dist/src/planner/nodes/update-node.d.ts +7 -1
- package/dist/src/planner/nodes/update-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/update-node.js +9 -1
- package/dist/src/planner/nodes/update-node.js.map +1 -1
- package/dist/src/planner/nodes/view-mutation-node.d.ts +13 -1
- package/dist/src/planner/nodes/view-mutation-node.d.ts.map +1 -1
- package/dist/src/planner/nodes/view-mutation-node.js +25 -1
- package/dist/src/planner/nodes/view-mutation-node.js.map +1 -1
- package/dist/src/planner/optimizer-tuning.d.ts +9 -9
- package/dist/src/planner/optimizer-tuning.d.ts.map +1 -1
- package/dist/src/planner/optimizer-tuning.js +0 -2
- package/dist/src/planner/optimizer-tuning.js.map +1 -1
- package/dist/src/planner/optimizer.d.ts.map +1 -1
- package/dist/src/planner/optimizer.js +9 -21
- package/dist/src/planner/optimizer.js.map +1 -1
- 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 +19 -10
- 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 +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 +34 -19
- package/dist/src/planner/rules/access/rule-select-access-path.js.map +1 -1
- package/dist/src/planner/rules/aggregate/rule-minmax-index-boundary.d.ts.map +1 -1
- package/dist/src/planner/rules/aggregate/rule-minmax-index-boundary.js +14 -1
- package/dist/src/planner/rules/aggregate/rule-minmax-index-boundary.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 +6 -4
- 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.map +1 -1
- package/dist/src/planner/rules/join/index-nested-loop.js +13 -10
- package/dist/src/planner/rules/join/index-nested-loop.js.map +1 -1
- package/dist/src/planner/rules/join/rule-join-greedy-commute.d.ts +2 -1
- package/dist/src/planner/rules/join/rule-join-greedy-commute.d.ts.map +1 -1
- package/dist/src/planner/rules/join/rule-join-greedy-commute.js +45 -17
- package/dist/src/planner/rules/join/rule-join-greedy-commute.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 +5 -3
- package/dist/src/planner/rules/join/rule-join-physical-selection.js.map +1 -1
- package/dist/src/planner/rules/join/rule-quickpick-enumeration.d.ts +19 -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 +36 -3
- package/dist/src/planner/rules/join/rule-quickpick-enumeration.js.map +1 -1
- package/dist/src/planner/rules/predicate/rule-filter-selectivity.js +4 -3
- package/dist/src/planner/rules/predicate/rule-filter-selectivity.js.map +1 -1
- package/dist/src/planner/rules/retrieve/rule-grow-retrieve.d.ts +14 -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 +200 -13
- package/dist/src/planner/rules/retrieve/rule-grow-retrieve.js.map +1 -1
- package/dist/src/planner/stats/catalog-stats.js +1 -1
- package/dist/src/planner/stats/catalog-stats.js.map +1 -1
- package/dist/src/planner/stats/index.d.ts.map +1 -1
- package/dist/src/planner/stats/index.js +3 -4
- package/dist/src/planner/stats/index.js.map +1 -1
- package/dist/src/planner/stats/table-cardinality.d.ts +6 -6
- package/dist/src/planner/stats/table-cardinality.js +7 -7
- package/dist/src/planner/stats/table-cardinality.js.map +1 -1
- package/dist/src/planner/util/row-estimates.d.ts +91 -0
- package/dist/src/planner/util/row-estimates.d.ts.map +1 -1
- package/dist/src/planner/util/row-estimates.js +134 -18
- package/dist/src/planner/util/row-estimates.js.map +1 -1
- package/dist/src/runtime/emit/materialized-view-helpers.d.ts.map +1 -1
- package/dist/src/runtime/emit/materialized-view-helpers.js +3 -3
- package/dist/src/runtime/emit/materialized-view-helpers.js.map +1 -1
- package/dist/src/runtime/scheduler.d.ts +47 -0
- package/dist/src/runtime/scheduler.d.ts.map +1 -1
- package/dist/src/runtime/scheduler.js +105 -11
- package/dist/src/runtime/scheduler.js.map +1 -1
- package/dist/src/runtime/types.d.ts +18 -3
- package/dist/src/runtime/types.d.ts.map +1 -1
- package/dist/src/runtime/types.js +7 -5
- package/dist/src/runtime/types.js.map +1 -1
- package/dist/src/schema/lens-prover.d.ts.map +1 -1
- package/dist/src/schema/lens-prover.js +2 -1
- package/dist/src/schema/lens-prover.js.map +1 -1
- package/dist/src/schema/manager.d.ts.map +1 -1
- package/dist/src/schema/manager.js +0 -3
- package/dist/src/schema/manager.js.map +1 -1
- package/dist/src/schema/table.d.ts +0 -2
- package/dist/src/schema/table.d.ts.map +1 -1
- package/dist/src/schema/table.js.map +1 -1
- package/dist/src/vtab/best-access-plan.d.ts +89 -4
- package/dist/src/vtab/best-access-plan.d.ts.map +1 -1
- package/dist/src/vtab/best-access-plan.js +76 -1
- package/dist/src/vtab/best-access-plan.js.map +1 -1
- package/dist/src/vtab/memory/module.d.ts.map +1 -1
- package/dist/src/vtab/memory/module.js +27 -11
- package/dist/src/vtab/memory/module.js.map +1 -1
- package/dist/src/vtab/module.d.ts +7 -0
- package/dist/src/vtab/module.d.ts.map +1 -1
- package/dist/src/vtab/test-support/committed-read-conformance.d.ts +5 -2
- package/dist/src/vtab/test-support/committed-read-conformance.d.ts.map +1 -1
- package/dist/src/vtab/test-support/committed-read-conformance.js +55 -9
- package/dist/src/vtab/test-support/committed-read-conformance.js.map +1 -1
- package/package.json +3 -3
- package/dist/src/planner/rules/cache/rule-cte-optimization.d.ts +0 -17
- package/dist/src/planner/rules/cache/rule-cte-optimization.d.ts.map +0 -1
- package/dist/src/planner/rules/cache/rule-cte-optimization.js +0 -69
- package/dist/src/planner/rules/cache/rule-cte-optimization.js.map +0 -1
|
@@ -36,4 +36,95 @@ export declare function physicalSourceRows(childPhysical: PhysicalProperties | u
|
|
|
36
36
|
* @param groupDivisor rows-per-group assumption for the grouped estimate
|
|
37
37
|
*/
|
|
38
38
|
export declare function aggregateRowsFrom(sourceRows: number | undefined, grouped: boolean, groupDivisor: number): number | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* ## Data-modifying nodes: rows EMITTED, not rows written
|
|
41
|
+
*
|
|
42
|
+
* Every estimate in this file counts the rows a node puts on its own output
|
|
43
|
+
* stream. For the write family (`InsertNode`, `UpdateNode`, `DeleteNode`,
|
|
44
|
+
* `ConstraintCheckNode`, `DmlExecutorNode`, `ReturningNode`) that stream tracks
|
|
45
|
+
* the source at most one-for-one — the prep nodes yield one flat OLD/NEW row per
|
|
46
|
+
* source row and `ReturningNode` projects one row per written row — so every
|
|
47
|
+
* member relays its source count unchanged.
|
|
48
|
+
*
|
|
49
|
+
* That relay is an UPPER BOUND, not an exact count, because two members can drop
|
|
50
|
+
* a row silently. `ConstraintCheckNode` skips a row whose NOT NULL / CHECK
|
|
51
|
+
* violation resolves to `IGNORE` (`runtime/row-constraints.ts` returns
|
|
52
|
+
* `{ skip: true }` and the emitter `continue`s), and `DmlExecutorNode` yields
|
|
53
|
+
* nothing for a row it did not write (`insert or ignore` onto an existing key,
|
|
54
|
+
* `on conflict do nothing`, an update whose row is no longer there). Neither skip
|
|
55
|
+
* rate is modelled: both are properties of the data, not of the plan, and
|
|
56
|
+
* inventing a discount would be less honest than the bound. Consumers of a
|
|
57
|
+
* write's estimate size buffers and pick strategies, which an upper bound serves
|
|
58
|
+
* correctly.
|
|
59
|
+
*
|
|
60
|
+
* The two readings only diverge at the statement boundary, and that boundary is
|
|
61
|
+
* a different node: a statement with no `returning` is topped by a `SinkNode`,
|
|
62
|
+
* which drains the write stream and reports the single changes-count row
|
|
63
|
+
* (`SinkNode.estimatedRows === 1`). So a consumer reading `estimatedRows` on a
|
|
64
|
+
* DML node is asking "how much work flows through this write pipeline", which is
|
|
65
|
+
* what sort strategy / cache thresholds above it want; a consumer asking "how
|
|
66
|
+
* many rows does this statement hand back" reads the Sink.
|
|
67
|
+
*/
|
|
68
|
+
/** Largest row estimate the relay will emit; see {@link clampRowEstimate}. */
|
|
69
|
+
export declare const MAX_ROW_ESTIMATE: number;
|
|
70
|
+
/**
|
|
71
|
+
* Normalize a composed row estimate to a finite, non-negative integer.
|
|
72
|
+
*
|
|
73
|
+
* Combinators that multiply (`crossProduct`) can push three large branches past
|
|
74
|
+
* `Number.MAX_SAFE_INTEGER` and on to `Infinity`; consumers do arithmetic on
|
|
75
|
+
* this value (selectivity multiplication, cache thresholds), so an `Infinity` or
|
|
76
|
+
* a fractional count leaks into cost comparisons and EXPLAIN output. Saturate at
|
|
77
|
+
* `MAX_ROW_ESTIMATE` instead — a saturated estimate is still "astronomically
|
|
78
|
+
* large", which is all any consumer does with it. `NaN` cannot survive either:
|
|
79
|
+
* it saturates too, since the only way to produce one here is an overflowed
|
|
80
|
+
* intermediate.
|
|
81
|
+
*/
|
|
82
|
+
export declare function clampRowEstimate(rows: number): number;
|
|
83
|
+
/** The set operations `SetOperationNode` can carry. */
|
|
84
|
+
export type SetOperationKind = 'union' | 'unionAll' | 'intersect' | 'except';
|
|
85
|
+
/**
|
|
86
|
+
* A set operation's output cardinality as a pure function of its branches' —
|
|
87
|
+
* shared by `SetOperationNode`'s logical `estimatedRows` getter and its
|
|
88
|
+
* `computePhysical` (which feeds it the PHYSICAL branch counts) so the two
|
|
89
|
+
* cannot drift.
|
|
90
|
+
*
|
|
91
|
+
* - `unionAll` — the sum; no rows are removed.
|
|
92
|
+
* - `union` — the true count lies in `max(branches) … sum(branches)` and the
|
|
93
|
+
* deduplication factor is unknown, so report the **sum**: the honest upper
|
|
94
|
+
* bound. The deduplication happens inside the node's own emitter
|
|
95
|
+
* (`runtime/emit/set-operation.ts`), not in a `Distinct` above it, so nothing
|
|
96
|
+
* downstream narrows this claim — it stays an upper bound for the whole plan.
|
|
97
|
+
* - `intersect` — the min; the result is a subset of both branches.
|
|
98
|
+
* - `except` — the left branch's count. The right branch can only remove rows,
|
|
99
|
+
* so the left count is an upper bound and the result can never go negative.
|
|
100
|
+
*
|
|
101
|
+
* `undefined` propagates from any branch the formula actually reads. `except`
|
|
102
|
+
* reads only the left branch, so an unknown right side does not blank it —
|
|
103
|
+
* the left bound is exactly as sound then as it is with a known right side.
|
|
104
|
+
*/
|
|
105
|
+
export declare function setOperationRowsFrom(op: SetOperationKind, leftRows: number | undefined, rightRows: number | undefined): number | undefined;
|
|
106
|
+
/** The combinators `AsyncGatherNode` can carry. */
|
|
107
|
+
export type GatherCombinatorKind = 'unionAll' | 'zipByKey' | 'crossProduct';
|
|
108
|
+
/**
|
|
109
|
+
* An `AsyncGatherNode`'s output cardinality as a pure function of its branches' —
|
|
110
|
+
* shared by its logical `estimatedRows` getter and its `computePhysical` (which
|
|
111
|
+
* feeds it the PHYSICAL branch counts), the same discipline
|
|
112
|
+
* {@link aggregateRowsFrom} applies to the aggregate family.
|
|
113
|
+
*
|
|
114
|
+
* - `unionAll` — the sum, matching {@link setOperationRowsFrom}: a
|
|
115
|
+
* PostOptimization rule substitutes a gather for a `union all`, and the two
|
|
116
|
+
* shapes must not report different counts for the same rows.
|
|
117
|
+
* - `zipByKey` — the max. Distinct keys across branches bound the result at
|
|
118
|
+
* `max(branches) … sum(branches)`; heavily overlapping keys is the normal case.
|
|
119
|
+
* NOTE: this is the only arm that picks the LOW end of its range — every other
|
|
120
|
+
* arm reports the upper bound. Now that the number is also stamped physically,
|
|
121
|
+
* a low-key-overlap workload can under-size a buffer above the gather; if that
|
|
122
|
+
* ever shows up, move this arm to the sum like the others.
|
|
123
|
+
* - `crossProduct` — the product, saturated by {@link clampRowEstimate} so three
|
|
124
|
+
* large branches cannot emit `Infinity`.
|
|
125
|
+
*
|
|
126
|
+
* Any unknown branch makes the whole result unknown — every branch is an input
|
|
127
|
+
* to all three formulas.
|
|
128
|
+
*/
|
|
129
|
+
export declare function gatherRowsFrom(kind: GatherCombinatorKind, branchRows: readonly (number | undefined)[]): number | undefined;
|
|
39
130
|
//# sourceMappingURL=row-estimates.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"row-estimates.d.ts","sourceRoot":"","sources":["../../../../src/planner/util/row-estimates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEpF;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"row-estimates.d.ts","sourceRoot":"","sources":["../../../../src/planner/util/row-estimates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEpF;;;;;;;;GAQG;AAMH,wBAAgB,kBAAkB,CACjC,aAAa,EAAE,kBAAkB,GAAG,SAAS,EAC7C,MAAM,EAAE,kBAAkB,GACxB,MAAM,GAAG,SAAS,CAEpB;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAChC,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,MAAM,GAClB,MAAM,GAAG,SAAS,CAapB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,8EAA8E;AAC9E,eAAO,MAAM,gBAAgB,QAA0B,CAAC;AAExD;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAIrD;AAED,uDAAuD;AACvD,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,UAAU,GAAG,WAAW,GAAG,QAAQ,CAAC;AAE7E;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,oBAAoB,CACnC,EAAE,EAAE,gBAAgB,EACpB,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,SAAS,EAAE,MAAM,GAAG,SAAS,GAC3B,MAAM,GAAG,SAAS,CAQpB;AAED,mDAAmD;AACnD,MAAM,MAAM,oBAAoB,GAAG,UAAU,GAAG,UAAU,GAAG,cAAc,CAAC;AAE5E;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,cAAc,CAC7B,IAAI,EAAE,oBAAoB,EAC1B,UAAU,EAAE,SAAS,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,GACzC,MAAM,GAAG,SAAS,CAoBpB"}
|
|
@@ -23,17 +23,11 @@
|
|
|
23
23
|
* there the logical getter is the only number available, and it is still the
|
|
24
24
|
* pre-optimization truth.
|
|
25
25
|
*/
|
|
26
|
-
//
|
|
27
|
-
//
|
|
28
|
-
// "
|
|
29
|
-
//
|
|
30
|
-
//
|
|
31
|
-
// consumer that reads a row estimate as a *magnitude* must therefore spell 0 as
|
|
32
|
-
// unknown — `rule-cte-optimization` gates on `sourceSize > 0` and had to be taught
|
|
33
|
-
// this (its `|| defaultRowEstimate` matches `vtab/memory/module.ts`); threshold
|
|
34
|
-
// consumers that floor (the cache threshold's min of 1000) or use a `>` test are
|
|
35
|
-
// unaffected. The real fix is distinguishing unknown from empty at the source —
|
|
36
|
-
// not clamping here, which would erase a genuinely empty analyzed table.
|
|
26
|
+
// Invariant: a row estimate has exactly two spellings — `undefined` means "nobody
|
|
27
|
+
// knows" and a number (including a real 0, from an analyzed empty table) means
|
|
28
|
+
// "measured or derived" (see `planner/stats/table-cardinality.ts`). A never-analyzed
|
|
29
|
+
// table's scan reports `undefined`, not 0, so this relay may propagate any number it
|
|
30
|
+
// sees as a genuine magnitude; consumers apply their own default only on `undefined`.
|
|
37
31
|
export function physicalSourceRows(childPhysical, source) {
|
|
38
32
|
return childPhysical?.estimatedRows ?? source.estimatedRows;
|
|
39
33
|
}
|
|
@@ -54,15 +48,137 @@ export function aggregateRowsFrom(sourceRows, grouped, groupDivisor) {
|
|
|
54
48
|
// (including the unknown sentinel — the count is not a function of the source).
|
|
55
49
|
if (!grouped)
|
|
56
50
|
return 1;
|
|
57
|
-
// 0
|
|
58
|
-
//
|
|
59
|
-
//
|
|
60
|
-
// leave here as a confident single row, which reads as a real magnitude and
|
|
61
|
-
// silently defeats every downstream `|| default` unknown-guard —
|
|
62
|
-
// `rule-join-physical-selection` costed a 1x1 join and kept the nested loop
|
|
63
|
-
// where both sides were un-analyzed grouped aggregates.
|
|
51
|
+
// 0 passes through unchanged: it now only ever means a genuinely empty source
|
|
52
|
+
// (never-analyzed is `undefined`, handled above), and 0 rows in ⇒ 0 groups
|
|
53
|
+
// out. Flooring it to 1 would claim a row an empty table cannot produce.
|
|
64
54
|
if (sourceRows === 0)
|
|
65
55
|
return 0;
|
|
66
56
|
return Math.max(1, Math.floor(sourceRows / groupDivisor));
|
|
67
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* ## Data-modifying nodes: rows EMITTED, not rows written
|
|
60
|
+
*
|
|
61
|
+
* Every estimate in this file counts the rows a node puts on its own output
|
|
62
|
+
* stream. For the write family (`InsertNode`, `UpdateNode`, `DeleteNode`,
|
|
63
|
+
* `ConstraintCheckNode`, `DmlExecutorNode`, `ReturningNode`) that stream tracks
|
|
64
|
+
* the source at most one-for-one — the prep nodes yield one flat OLD/NEW row per
|
|
65
|
+
* source row and `ReturningNode` projects one row per written row — so every
|
|
66
|
+
* member relays its source count unchanged.
|
|
67
|
+
*
|
|
68
|
+
* That relay is an UPPER BOUND, not an exact count, because two members can drop
|
|
69
|
+
* a row silently. `ConstraintCheckNode` skips a row whose NOT NULL / CHECK
|
|
70
|
+
* violation resolves to `IGNORE` (`runtime/row-constraints.ts` returns
|
|
71
|
+
* `{ skip: true }` and the emitter `continue`s), and `DmlExecutorNode` yields
|
|
72
|
+
* nothing for a row it did not write (`insert or ignore` onto an existing key,
|
|
73
|
+
* `on conflict do nothing`, an update whose row is no longer there). Neither skip
|
|
74
|
+
* rate is modelled: both are properties of the data, not of the plan, and
|
|
75
|
+
* inventing a discount would be less honest than the bound. Consumers of a
|
|
76
|
+
* write's estimate size buffers and pick strategies, which an upper bound serves
|
|
77
|
+
* correctly.
|
|
78
|
+
*
|
|
79
|
+
* The two readings only diverge at the statement boundary, and that boundary is
|
|
80
|
+
* a different node: a statement with no `returning` is topped by a `SinkNode`,
|
|
81
|
+
* which drains the write stream and reports the single changes-count row
|
|
82
|
+
* (`SinkNode.estimatedRows === 1`). So a consumer reading `estimatedRows` on a
|
|
83
|
+
* DML node is asking "how much work flows through this write pipeline", which is
|
|
84
|
+
* what sort strategy / cache thresholds above it want; a consumer asking "how
|
|
85
|
+
* many rows does this statement hand back" reads the Sink.
|
|
86
|
+
*/
|
|
87
|
+
/** Largest row estimate the relay will emit; see {@link clampRowEstimate}. */
|
|
88
|
+
export const MAX_ROW_ESTIMATE = Number.MAX_SAFE_INTEGER;
|
|
89
|
+
/**
|
|
90
|
+
* Normalize a composed row estimate to a finite, non-negative integer.
|
|
91
|
+
*
|
|
92
|
+
* Combinators that multiply (`crossProduct`) can push three large branches past
|
|
93
|
+
* `Number.MAX_SAFE_INTEGER` and on to `Infinity`; consumers do arithmetic on
|
|
94
|
+
* this value (selectivity multiplication, cache thresholds), so an `Infinity` or
|
|
95
|
+
* a fractional count leaks into cost comparisons and EXPLAIN output. Saturate at
|
|
96
|
+
* `MAX_ROW_ESTIMATE` instead — a saturated estimate is still "astronomically
|
|
97
|
+
* large", which is all any consumer does with it. `NaN` cannot survive either:
|
|
98
|
+
* it saturates too, since the only way to produce one here is an overflowed
|
|
99
|
+
* intermediate.
|
|
100
|
+
*/
|
|
101
|
+
export function clampRowEstimate(rows) {
|
|
102
|
+
if (Number.isNaN(rows))
|
|
103
|
+
return MAX_ROW_ESTIMATE;
|
|
104
|
+
if (rows >= MAX_ROW_ESTIMATE)
|
|
105
|
+
return MAX_ROW_ESTIMATE;
|
|
106
|
+
return Math.max(0, Math.floor(rows));
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* A set operation's output cardinality as a pure function of its branches' —
|
|
110
|
+
* shared by `SetOperationNode`'s logical `estimatedRows` getter and its
|
|
111
|
+
* `computePhysical` (which feeds it the PHYSICAL branch counts) so the two
|
|
112
|
+
* cannot drift.
|
|
113
|
+
*
|
|
114
|
+
* - `unionAll` — the sum; no rows are removed.
|
|
115
|
+
* - `union` — the true count lies in `max(branches) … sum(branches)` and the
|
|
116
|
+
* deduplication factor is unknown, so report the **sum**: the honest upper
|
|
117
|
+
* bound. The deduplication happens inside the node's own emitter
|
|
118
|
+
* (`runtime/emit/set-operation.ts`), not in a `Distinct` above it, so nothing
|
|
119
|
+
* downstream narrows this claim — it stays an upper bound for the whole plan.
|
|
120
|
+
* - `intersect` — the min; the result is a subset of both branches.
|
|
121
|
+
* - `except` — the left branch's count. The right branch can only remove rows,
|
|
122
|
+
* so the left count is an upper bound and the result can never go negative.
|
|
123
|
+
*
|
|
124
|
+
* `undefined` propagates from any branch the formula actually reads. `except`
|
|
125
|
+
* reads only the left branch, so an unknown right side does not blank it —
|
|
126
|
+
* the left bound is exactly as sound then as it is with a known right side.
|
|
127
|
+
*/
|
|
128
|
+
export function setOperationRowsFrom(op, leftRows, rightRows) {
|
|
129
|
+
if (leftRows === undefined)
|
|
130
|
+
return undefined;
|
|
131
|
+
// The right branch subtracts; it is not an input to the upper bound.
|
|
132
|
+
if (op === 'except')
|
|
133
|
+
return clampRowEstimate(leftRows);
|
|
134
|
+
if (rightRows === undefined)
|
|
135
|
+
return undefined;
|
|
136
|
+
if (op === 'intersect')
|
|
137
|
+
return clampRowEstimate(Math.min(leftRows, rightRows));
|
|
138
|
+
// union / unionAll: sum (see the `union` note above).
|
|
139
|
+
return clampRowEstimate(leftRows + rightRows);
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* An `AsyncGatherNode`'s output cardinality as a pure function of its branches' —
|
|
143
|
+
* shared by its logical `estimatedRows` getter and its `computePhysical` (which
|
|
144
|
+
* feeds it the PHYSICAL branch counts), the same discipline
|
|
145
|
+
* {@link aggregateRowsFrom} applies to the aggregate family.
|
|
146
|
+
*
|
|
147
|
+
* - `unionAll` — the sum, matching {@link setOperationRowsFrom}: a
|
|
148
|
+
* PostOptimization rule substitutes a gather for a `union all`, and the two
|
|
149
|
+
* shapes must not report different counts for the same rows.
|
|
150
|
+
* - `zipByKey` — the max. Distinct keys across branches bound the result at
|
|
151
|
+
* `max(branches) … sum(branches)`; heavily overlapping keys is the normal case.
|
|
152
|
+
* NOTE: this is the only arm that picks the LOW end of its range — every other
|
|
153
|
+
* arm reports the upper bound. Now that the number is also stamped physically,
|
|
154
|
+
* a low-key-overlap workload can under-size a buffer above the gather; if that
|
|
155
|
+
* ever shows up, move this arm to the sum like the others.
|
|
156
|
+
* - `crossProduct` — the product, saturated by {@link clampRowEstimate} so three
|
|
157
|
+
* large branches cannot emit `Infinity`.
|
|
158
|
+
*
|
|
159
|
+
* Any unknown branch makes the whole result unknown — every branch is an input
|
|
160
|
+
* to all three formulas.
|
|
161
|
+
*/
|
|
162
|
+
export function gatherRowsFrom(kind, branchRows) {
|
|
163
|
+
let acc = kind === 'crossProduct' ? 1 : 0;
|
|
164
|
+
for (const rows of branchRows) {
|
|
165
|
+
if (rows === undefined)
|
|
166
|
+
return undefined;
|
|
167
|
+
switch (kind) {
|
|
168
|
+
case 'unionAll':
|
|
169
|
+
acc += rows;
|
|
170
|
+
break;
|
|
171
|
+
case 'zipByKey':
|
|
172
|
+
acc = Math.max(acc, rows);
|
|
173
|
+
break;
|
|
174
|
+
case 'crossProduct':
|
|
175
|
+
// Saturate every step, not just the result: an overflowed `Infinity`
|
|
176
|
+
// intermediate followed by a provably-empty branch would otherwise
|
|
177
|
+
// multiply out to `NaN`.
|
|
178
|
+
acc = clampRowEstimate(acc * rows);
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return clampRowEstimate(acc);
|
|
183
|
+
}
|
|
68
184
|
//# sourceMappingURL=row-estimates.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"row-estimates.js","sourceRoot":"","sources":["../../../../src/planner/util/row-estimates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH;;;;;;;;GAQG;AACH,
|
|
1
|
+
{"version":3,"file":"row-estimates.js","sourceRoot":"","sources":["../../../../src/planner/util/row-estimates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH;;;;;;;;GAQG;AACH,kFAAkF;AAClF,+EAA+E;AAC/E,qFAAqF;AACrF,qFAAqF;AACrF,sFAAsF;AACtF,MAAM,UAAU,kBAAkB,CACjC,aAA6C,EAC7C,MAA0B;IAE1B,OAAO,aAAa,EAAE,aAAa,IAAI,MAAM,CAAC,aAAa,CAAC;AAC7D,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,iBAAiB,CAChC,UAA8B,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,CAAC;IAChC;;;;sEAIkE;IAClE,aAAa,CAAC,EAAE,aAAa,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC;CACrD;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,kBAAkB,CACjC,EAAE,EAAE,QAAQ,EACZ,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,eAAe,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,SAAS,EAClD,OAAO,CAAC,EAAE;IACT,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;IAChD,OAAO,CAAC,EAAE,WAAW,CAAC;CACtB,GACC,YAAY,CAOd;AA+HD;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,YAAY,GAAG,aAAa,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC,CAa7G;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACtC,EAAE,EAAE,QAAQ,EACZ,UAAU,EAAE,MAAM,EAClB,gBAAgB,EAAE,MAAM,EACxB,KAAK,EAAE,YAAY,EACnB,UAAU,CAAC,EAAE,MAAM,EACnB,UAAU,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAC/C,8FAA8F;AAC9F,IAAI,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,GACvC,WAAW,
|
|
1
|
+
{"version":3,"file":"materialized-view-helpers.d.ts","sourceRoot":"","sources":["../../../../src/runtime/emit/materialized-view-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD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QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,kBAAkB,CAwBpH;AAID;;;;;;;;GAQG;AACH,wBAAgB,8BAA8B,CAAC,EAAE,EAAE,QAAQ,GAAG,WAAW,CAAC,MAAM,CAAC,CAMhF;AAYD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,uCAAuC,CAC5D,EAAE,EAAE,QAAQ,EACZ,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,EAC7B,MAAM,EAAE,iBAAiB,GACvB,OAAO,CAAC,IAAI,CAAC,CA0Bf;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,wCAAwC,CAC7D,EAAE,EAAE,QAAQ,EACZ,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,EAC7B,OAAO,EAAE,gBAAgB,EACzB,SAAS,EAAE,MAAM,EACjB,qBAAqB,EAAE,qBAAqB,GAC1C,OAAO,CAAC,IAAI,CAAC,CAcf;AAoGD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AACH,wBAAsB,kCAAkC,CACvD,EAAE,EAAE,QAAQ,EACZ,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,GAC3B,OAAO,CAAC,IAAI,CAAC,CAyCf"}
|
|
@@ -283,7 +283,6 @@ tags) {
|
|
|
283
283
|
vtabArgs: moduleArgs ? { ...moduleArgs } : {},
|
|
284
284
|
vtabAuxData: moduleInfo.auxData,
|
|
285
285
|
isView: false,
|
|
286
|
-
estimatedRows: 0,
|
|
287
286
|
tags: tags && Object.keys(tags).length > 0 ? tags : undefined,
|
|
288
287
|
};
|
|
289
288
|
}
|
|
@@ -359,7 +358,6 @@ function normalizeBackingShape(db, schemaName, shape, moduleName, moduleArgs, ag
|
|
|
359
358
|
vtabModuleName: resolvedModuleName,
|
|
360
359
|
vtabArgs: moduleArgs ? { ...moduleArgs } : {},
|
|
361
360
|
isView: false,
|
|
362
|
-
estimatedRows: 0,
|
|
363
361
|
};
|
|
364
362
|
const normalized = module.normalizeCreateSchema(probe);
|
|
365
363
|
if (normalized.columns === probe.columns)
|
|
@@ -644,7 +642,9 @@ export async function adoptMaterializedView(db, def, preExisting, shape) {
|
|
|
644
642
|
const schema = sm.getSchemaOrFail(def.schemaName);
|
|
645
643
|
assertNoSelfReference(def, shape);
|
|
646
644
|
const stamped = buildBackingTableSchema(db, def.schemaName, def.viewName, shape, def.backingModuleName, def.backingModuleArgs, def.tags);
|
|
647
|
-
|
|
645
|
+
// Carry the adopted table's measured statistics forward — the pre-existing
|
|
646
|
+
// backing's rows are being kept, so its row count is still the truth.
|
|
647
|
+
schema.addTable(preExisting.statistics ? { ...stamped, statistics: preExisting.statistics } : stamped);
|
|
648
648
|
const maintained = sm.attachDerivation(def.schemaName, def.viewName, buildTableDerivation(def, shape));
|
|
649
649
|
linkCoveredUniqueConstraints(db, maintained, def.bodySql);
|
|
650
650
|
try {
|