@quereus/quereus 2.8.0 → 2.9.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.
Files changed (214) hide show
  1. package/dist/src/emit/ast-stringify.d.ts.map +1 -1
  2. package/dist/src/emit/ast-stringify.js +0 -3
  3. package/dist/src/emit/ast-stringify.js.map +1 -1
  4. package/dist/src/parser/ast.d.ts +3 -2
  5. package/dist/src/parser/ast.d.ts.map +1 -1
  6. package/dist/src/parser/parser.d.ts.map +1 -1
  7. package/dist/src/parser/parser.js +13 -4
  8. package/dist/src/parser/parser.js.map +1 -1
  9. package/dist/src/planner/building/foreign-key-builder.d.ts.map +1 -1
  10. package/dist/src/planner/building/foreign-key-builder.js +3 -2
  11. package/dist/src/planner/building/foreign-key-builder.js.map +1 -1
  12. package/dist/src/planner/building/select.js +14 -2
  13. package/dist/src/planner/building/select.js.map +1 -1
  14. package/dist/src/planner/building/update.d.ts.map +1 -1
  15. package/dist/src/planner/building/update.js +10 -6
  16. package/dist/src/planner/building/update.js.map +1 -1
  17. package/dist/src/planner/framework/characteristics.d.ts +3 -1
  18. package/dist/src/planner/framework/characteristics.d.ts.map +1 -1
  19. package/dist/src/planner/framework/characteristics.js +7 -0
  20. package/dist/src/planner/framework/characteristics.js.map +1 -1
  21. package/dist/src/planner/framework/physical-utils.d.ts +22 -1
  22. package/dist/src/planner/framework/physical-utils.d.ts.map +1 -1
  23. package/dist/src/planner/framework/physical-utils.js +47 -0
  24. package/dist/src/planner/framework/physical-utils.js.map +1 -1
  25. package/dist/src/planner/nodes/alias-node.d.ts.map +1 -1
  26. package/dist/src/planner/nodes/alias-node.js +2 -0
  27. package/dist/src/planner/nodes/alias-node.js.map +1 -1
  28. package/dist/src/planner/nodes/asof-scan-node.d.ts +137 -0
  29. package/dist/src/planner/nodes/asof-scan-node.d.ts.map +1 -0
  30. package/dist/src/planner/nodes/asof-scan-node.js +223 -0
  31. package/dist/src/planner/nodes/asof-scan-node.js.map +1 -0
  32. package/dist/src/planner/nodes/constraint-check-node.d.ts +3 -0
  33. package/dist/src/planner/nodes/constraint-check-node.d.ts.map +1 -1
  34. package/dist/src/planner/nodes/constraint-check-node.js.map +1 -1
  35. package/dist/src/planner/nodes/distinct-node.d.ts.map +1 -1
  36. package/dist/src/planner/nodes/distinct-node.js +7 -0
  37. package/dist/src/planner/nodes/distinct-node.js.map +1 -1
  38. package/dist/src/planner/nodes/filter.d.ts.map +1 -1
  39. package/dist/src/planner/nodes/filter.js +2 -0
  40. package/dist/src/planner/nodes/filter.js.map +1 -1
  41. package/dist/src/planner/nodes/function.d.ts +11 -1
  42. package/dist/src/planner/nodes/function.d.ts.map +1 -1
  43. package/dist/src/planner/nodes/function.js +94 -1
  44. package/dist/src/planner/nodes/function.js.map +1 -1
  45. package/dist/src/planner/nodes/hash-aggregate.d.ts.map +1 -1
  46. package/dist/src/planner/nodes/hash-aggregate.js +2 -0
  47. package/dist/src/planner/nodes/hash-aggregate.js.map +1 -1
  48. package/dist/src/planner/nodes/join-node.d.ts.map +1 -1
  49. package/dist/src/planner/nodes/join-node.js +10 -2
  50. package/dist/src/planner/nodes/join-node.js.map +1 -1
  51. package/dist/src/planner/nodes/join-utils.d.ts +19 -1
  52. package/dist/src/planner/nodes/join-utils.d.ts.map +1 -1
  53. package/dist/src/planner/nodes/join-utils.js +46 -0
  54. package/dist/src/planner/nodes/join-utils.js.map +1 -1
  55. package/dist/src/planner/nodes/limit-offset.d.ts.map +1 -1
  56. package/dist/src/planner/nodes/limit-offset.js +2 -0
  57. package/dist/src/planner/nodes/limit-offset.js.map +1 -1
  58. package/dist/src/planner/nodes/merge-join-node.d.ts.map +1 -1
  59. package/dist/src/planner/nodes/merge-join-node.js +4 -1
  60. package/dist/src/planner/nodes/merge-join-node.js.map +1 -1
  61. package/dist/src/planner/nodes/ordinal-slice-node.d.ts +50 -0
  62. package/dist/src/planner/nodes/ordinal-slice-node.d.ts.map +1 -0
  63. package/dist/src/planner/nodes/ordinal-slice-node.js +127 -0
  64. package/dist/src/planner/nodes/ordinal-slice-node.js.map +1 -0
  65. package/dist/src/planner/nodes/plan-node-type.d.ts +2 -0
  66. package/dist/src/planner/nodes/plan-node-type.d.ts.map +1 -1
  67. package/dist/src/planner/nodes/plan-node-type.js +2 -0
  68. package/dist/src/planner/nodes/plan-node-type.js.map +1 -1
  69. package/dist/src/planner/nodes/plan-node.d.ts +130 -1
  70. package/dist/src/planner/nodes/plan-node.d.ts.map +1 -1
  71. package/dist/src/planner/nodes/plan-node.js +49 -0
  72. package/dist/src/planner/nodes/plan-node.js.map +1 -1
  73. package/dist/src/planner/nodes/project-node.d.ts.map +1 -1
  74. package/dist/src/planner/nodes/project-node.js +6 -1
  75. package/dist/src/planner/nodes/project-node.js.map +1 -1
  76. package/dist/src/planner/nodes/reference.d.ts +4 -1
  77. package/dist/src/planner/nodes/reference.d.ts.map +1 -1
  78. package/dist/src/planner/nodes/reference.js +16 -0
  79. package/dist/src/planner/nodes/reference.js.map +1 -1
  80. package/dist/src/planner/nodes/scalar.d.ts +7 -1
  81. package/dist/src/planner/nodes/scalar.d.ts.map +1 -1
  82. package/dist/src/planner/nodes/scalar.js +100 -1
  83. package/dist/src/planner/nodes/scalar.js.map +1 -1
  84. package/dist/src/planner/nodes/set-operation-node.d.ts +2 -1
  85. package/dist/src/planner/nodes/set-operation-node.d.ts.map +1 -1
  86. package/dist/src/planner/nodes/set-operation-node.js +9 -0
  87. package/dist/src/planner/nodes/set-operation-node.js.map +1 -1
  88. package/dist/src/planner/nodes/sort.d.ts.map +1 -1
  89. package/dist/src/planner/nodes/sort.js +20 -0
  90. package/dist/src/planner/nodes/sort.js.map +1 -1
  91. package/dist/src/planner/nodes/stream-aggregate.d.ts.map +1 -1
  92. package/dist/src/planner/nodes/stream-aggregate.js +2 -0
  93. package/dist/src/planner/nodes/stream-aggregate.js.map +1 -1
  94. package/dist/src/planner/nodes/table-access-nodes.d.ts +37 -2
  95. package/dist/src/planner/nodes/table-access-nodes.d.ts.map +1 -1
  96. package/dist/src/planner/nodes/table-access-nodes.js +87 -10
  97. package/dist/src/planner/nodes/table-access-nodes.js.map +1 -1
  98. package/dist/src/planner/nodes/update-node.d.ts +1 -3
  99. package/dist/src/planner/nodes/update-node.d.ts.map +1 -1
  100. package/dist/src/planner/nodes/update-node.js +3 -9
  101. package/dist/src/planner/nodes/update-node.js.map +1 -1
  102. package/dist/src/planner/nodes/window-node.d.ts +61 -2
  103. package/dist/src/planner/nodes/window-node.d.ts.map +1 -1
  104. package/dist/src/planner/nodes/window-node.js +64 -3
  105. package/dist/src/planner/nodes/window-node.js.map +1 -1
  106. package/dist/src/planner/optimizer-tuning.d.ts +9 -0
  107. package/dist/src/planner/optimizer-tuning.d.ts.map +1 -1
  108. package/dist/src/planner/optimizer-tuning.js +3 -0
  109. package/dist/src/planner/optimizer-tuning.js.map +1 -1
  110. package/dist/src/planner/optimizer.d.ts.map +1 -1
  111. package/dist/src/planner/optimizer.js +91 -0
  112. package/dist/src/planner/optimizer.js.map +1 -1
  113. package/dist/src/planner/rules/access/rule-asof-strategy-select.d.ts +30 -0
  114. package/dist/src/planner/rules/access/rule-asof-strategy-select.d.ts.map +1 -0
  115. package/dist/src/planner/rules/access/rule-asof-strategy-select.js +112 -0
  116. package/dist/src/planner/rules/access/rule-asof-strategy-select.js.map +1 -0
  117. package/dist/src/planner/rules/access/rule-monotonic-limit-pushdown.d.ts +33 -0
  118. package/dist/src/planner/rules/access/rule-monotonic-limit-pushdown.d.ts.map +1 -0
  119. package/dist/src/planner/rules/access/rule-monotonic-limit-pushdown.js +162 -0
  120. package/dist/src/planner/rules/access/rule-monotonic-limit-pushdown.js.map +1 -0
  121. package/dist/src/planner/rules/access/rule-monotonic-range-access.d.ts +29 -0
  122. package/dist/src/planner/rules/access/rule-monotonic-range-access.d.ts.map +1 -0
  123. package/dist/src/planner/rules/access/rule-monotonic-range-access.js +175 -0
  124. package/dist/src/planner/rules/access/rule-monotonic-range-access.js.map +1 -0
  125. package/dist/src/planner/rules/access/rule-select-access-path.d.ts.map +1 -1
  126. package/dist/src/planner/rules/access/rule-select-access-path.js +31 -10
  127. package/dist/src/planner/rules/access/rule-select-access-path.js.map +1 -1
  128. package/dist/src/planner/rules/join/equi-pair-extractor.d.ts +61 -0
  129. package/dist/src/planner/rules/join/equi-pair-extractor.d.ts.map +1 -0
  130. package/dist/src/planner/rules/join/equi-pair-extractor.js +155 -0
  131. package/dist/src/planner/rules/join/equi-pair-extractor.js.map +1 -0
  132. package/dist/src/planner/rules/join/rule-join-physical-selection.d.ts.map +1 -1
  133. package/dist/src/planner/rules/join/rule-join-physical-selection.js +2 -122
  134. package/dist/src/planner/rules/join/rule-join-physical-selection.js.map +1 -1
  135. package/dist/src/planner/rules/join/rule-lateral-top1-asof.d.ts +21 -0
  136. package/dist/src/planner/rules/join/rule-lateral-top1-asof.d.ts.map +1 -0
  137. package/dist/src/planner/rules/join/rule-lateral-top1-asof.js +405 -0
  138. package/dist/src/planner/rules/join/rule-lateral-top1-asof.js.map +1 -0
  139. package/dist/src/planner/rules/join/rule-monotonic-merge-join.d.ts +31 -0
  140. package/dist/src/planner/rules/join/rule-monotonic-merge-join.d.ts.map +1 -0
  141. package/dist/src/planner/rules/join/rule-monotonic-merge-join.js +113 -0
  142. package/dist/src/planner/rules/join/rule-monotonic-merge-join.js.map +1 -0
  143. package/dist/src/planner/rules/window/rule-monotonic-window.d.ts +47 -0
  144. package/dist/src/planner/rules/window/rule-monotonic-window.d.ts.map +1 -0
  145. package/dist/src/planner/rules/window/rule-monotonic-window.js +341 -0
  146. package/dist/src/planner/rules/window/rule-monotonic-window.js.map +1 -0
  147. package/dist/src/runtime/context-helpers.d.ts +9 -0
  148. package/dist/src/runtime/context-helpers.d.ts.map +1 -1
  149. package/dist/src/runtime/context-helpers.js +5 -0
  150. package/dist/src/runtime/context-helpers.js.map +1 -1
  151. package/dist/src/runtime/emit/asof-scan.d.ts +10 -0
  152. package/dist/src/runtime/emit/asof-scan.d.ts.map +1 -0
  153. package/dist/src/runtime/emit/asof-scan.js +467 -0
  154. package/dist/src/runtime/emit/asof-scan.js.map +1 -0
  155. package/dist/src/runtime/emit/constraint-check.d.ts.map +1 -1
  156. package/dist/src/runtime/emit/constraint-check.js +20 -0
  157. package/dist/src/runtime/emit/constraint-check.js.map +1 -1
  158. package/dist/src/runtime/emit/ordinal-slice.d.ts +13 -0
  159. package/dist/src/runtime/emit/ordinal-slice.d.ts.map +1 -0
  160. package/dist/src/runtime/emit/ordinal-slice.js +89 -0
  161. package/dist/src/runtime/emit/ordinal-slice.js.map +1 -0
  162. package/dist/src/runtime/emit/returning.d.ts.map +1 -1
  163. package/dist/src/runtime/emit/returning.js +9 -4
  164. package/dist/src/runtime/emit/returning.js.map +1 -1
  165. package/dist/src/runtime/emit/scan.d.ts +19 -3
  166. package/dist/src/runtime/emit/scan.d.ts.map +1 -1
  167. package/dist/src/runtime/emit/scan.js +12 -8
  168. package/dist/src/runtime/emit/scan.js.map +1 -1
  169. package/dist/src/runtime/emit/schema-declarative.d.ts.map +1 -1
  170. package/dist/src/runtime/emit/schema-declarative.js +91 -14
  171. package/dist/src/runtime/emit/schema-declarative.js.map +1 -1
  172. package/dist/src/runtime/emit/window.d.ts.map +1 -1
  173. package/dist/src/runtime/emit/window.js +732 -37
  174. package/dist/src/runtime/emit/window.js.map +1 -1
  175. package/dist/src/runtime/foreign-key-actions.js +5 -4
  176. package/dist/src/runtime/foreign-key-actions.js.map +1 -1
  177. package/dist/src/runtime/register.d.ts.map +1 -1
  178. package/dist/src/runtime/register.js +4 -0
  179. package/dist/src/runtime/register.js.map +1 -1
  180. package/dist/src/schema/catalog.d.ts +10 -0
  181. package/dist/src/schema/catalog.d.ts.map +1 -1
  182. package/dist/src/schema/catalog.js +29 -6
  183. package/dist/src/schema/catalog.js.map +1 -1
  184. package/dist/src/schema/function.d.ts +24 -0
  185. package/dist/src/schema/function.d.ts.map +1 -1
  186. package/dist/src/schema/function.js.map +1 -1
  187. package/dist/src/schema/manager.d.ts +10 -0
  188. package/dist/src/schema/manager.d.ts.map +1 -1
  189. package/dist/src/schema/manager.js +10 -0
  190. package/dist/src/schema/manager.js.map +1 -1
  191. package/dist/src/schema/schema-differ.d.ts +18 -1
  192. package/dist/src/schema/schema-differ.d.ts.map +1 -1
  193. package/dist/src/schema/schema-differ.js +307 -42
  194. package/dist/src/schema/schema-differ.js.map +1 -1
  195. package/dist/src/types/logical-type.d.ts +11 -0
  196. package/dist/src/types/logical-type.d.ts.map +1 -1
  197. package/dist/src/types/logical-type.js.map +1 -1
  198. package/dist/src/util/ast-literal.d.ts +11 -0
  199. package/dist/src/util/ast-literal.d.ts.map +1 -0
  200. package/dist/src/util/ast-literal.js +26 -0
  201. package/dist/src/util/ast-literal.js.map +1 -0
  202. package/dist/src/vtab/best-access-plan.d.ts +41 -0
  203. package/dist/src/vtab/best-access-plan.d.ts.map +1 -1
  204. package/dist/src/vtab/best-access-plan.js +29 -0
  205. package/dist/src/vtab/best-access-plan.js.map +1 -1
  206. package/dist/src/vtab/filter-info.d.ts +14 -0
  207. package/dist/src/vtab/filter-info.d.ts.map +1 -1
  208. package/dist/src/vtab/memory/module.d.ts +39 -1
  209. package/dist/src/vtab/memory/module.d.ts.map +1 -1
  210. package/dist/src/vtab/memory/module.js +206 -44
  211. package/dist/src/vtab/memory/module.js.map +1 -1
  212. package/dist/src/vtab/module.d.ts +24 -0
  213. package/dist/src/vtab/module.d.ts.map +1 -1
  214. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"optimizer-tuning.d.ts","sourceRoot":"","sources":["../../../src/planner/optimizer-tuning.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,eAAe;IAC/B,8BAA8B;IAC9B,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IAEpC,+DAA+D;IAC/D,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAC;IAEtC,wBAAwB;IACxB,QAAQ,CAAC,IAAI,EAAE;QACd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,CAAC,KAAK,EAAE;QACf,gEAAgE;QAChE,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;QAChC,kDAAkD;QAClD,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;QAChC,uCAAuC;QACvC,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;KAC/B,CAAC;IAEF,0CAA0C;IAC1C,QAAQ,CAAC,IAAI,EAAE;QACd;;;;WAIG;QACH,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;KACnC,CAAC;IAEF,mEAAmE;IACnE,QAAQ,CAAC,aAAa,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAE7C,wCAAwC;IACxC,QAAQ,CAAC,KAAK,EAAE;QACf,yDAAyD;QACzD,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;KAC/B,CAAC;IAEF,wCAAwC;IACxC,QAAQ,CAAC,SAAS,CAAC,EAAE;QACpB,wDAAwD;QACxD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAC1B,4DAA4D;QAC5D,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;QAC7B,yDAAyD;QACzD,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;QAChC,wCAAwC;QACxC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;KAC1B,CAAC;CACF;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,eAmC5B,CAAC"}
@@ -24,6 +24,9 @@ export const DEFAULT_TUNING = {
24
24
  maxSpillBuffer: 10000,
25
25
  spillEnabled: true
26
26
  },
27
+ asof: {
28
+ mergeRowThreshold: 10000
29
+ },
27
30
  debug: {
28
31
  validatePlan: false // Default to disabled in production
29
32
  },
@@ -1 +1 @@
1
- {"version":3,"file":"optimizer-tuning.js","sourceRoot":"","sources":["../../../src/planner/optimizer-tuning.ts"],"names":[],"mappings":"AAwEA;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAoB;IAC9C,kBAAkB,EAAE,IAAI;IACxB,oBAAoB,EAAE,EAAE;IACxB,IAAI,EAAE;QACL,qBAAqB,EAAE,CAAC;QACxB,sBAAsB,EAAE,KAAK;QAC7B,wBAAwB,EAAE,CAAC;QAC3B,iBAAiB,EAAE,KAAK;KACxB;IACD,GAAG,EAAE;QACJ,iBAAiB,EAAE,KAAK;QACxB,wBAAwB,EAAE,CAAC;QAC3B,iBAAiB,EAAE,KAAK;KACxB;IACD,YAAY,EAAE;QACb,aAAa,EAAE,KAAK;QACpB,qBAAqB,EAAE,KAAK;KAC5B;IACD,KAAK,EAAE;QACN,cAAc,EAAE,MAAM;QACtB,cAAc,EAAE,KAAK;QACrB,YAAY,EAAE,IAAI;KAClB;IACD,KAAK,EAAE;QACN,YAAY,EAAE,KAAK,CAAC,oCAAoC;KACxD;IACD,SAAS,EAAE;QACV,QAAQ,EAAE,GAAG;QACb,WAAW,EAAE,GAAG;QAChB,cAAc,EAAE,CAAC;QACjB,OAAO,EAAE,IAAI;KACb;CACD,CAAC"}
1
+ {"version":3,"file":"optimizer-tuning.js","sourceRoot":"","sources":["../../../src/planner/optimizer-tuning.ts"],"names":[],"mappings":"AAkFA;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAoB;IAC9C,kBAAkB,EAAE,IAAI;IACxB,oBAAoB,EAAE,EAAE;IACxB,IAAI,EAAE;QACL,qBAAqB,EAAE,CAAC;QACxB,sBAAsB,EAAE,KAAK;QAC7B,wBAAwB,EAAE,CAAC;QAC3B,iBAAiB,EAAE,KAAK;KACxB;IACD,GAAG,EAAE;QACJ,iBAAiB,EAAE,KAAK;QACxB,wBAAwB,EAAE,CAAC;QAC3B,iBAAiB,EAAE,KAAK;KACxB;IACD,YAAY,EAAE;QACb,aAAa,EAAE,KAAK;QACpB,qBAAqB,EAAE,KAAK;KAC5B;IACD,KAAK,EAAE;QACN,cAAc,EAAE,MAAM;QACtB,cAAc,EAAE,KAAK;QACrB,YAAY,EAAE,IAAI;KAClB;IACD,IAAI,EAAE;QACL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AAQ,EAAE,EAAE,EAAE,QAAQ,GAAG,QAAQ;IAe3D,YAAY,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,GAAG,QAAQ;IAuC3D,OAAO,CAAC,gBAAgB;IAiBxB;;OAEG;IACH,QAAQ,IAAI,aAAa;IAIzB,qDAAqD;IACrD,kBAAkB,IAAI,oBAAoB,GAAG,IAAI;CAGjD"}
@@ -12,6 +12,9 @@ import { PassManager, PassId } from './framework/pass.js';
12
12
  import { ruleMaterializationAdvisory } from './rules/cache/rule-materialization-advisory.js';
13
13
  // Phase 1.5 rules
14
14
  import { ruleSelectAccessPath } from './rules/access/rule-select-access-path.js';
15
+ import { ruleMonotonicLimitPushdown } from './rules/access/rule-monotonic-limit-pushdown.js';
16
+ import { ruleMonotonicRangeAccess } from './rules/access/rule-monotonic-range-access.js';
17
+ import { ruleAsofStrategySelect } from './rules/access/rule-asof-strategy-select.js';
15
18
  import { ruleGrowRetrieve } from './rules/retrieve/rule-grow-retrieve.js';
16
19
  import { rulePredicatePushdown } from './rules/predicate/rule-predicate-pushdown.js';
17
20
  import { ruleFilterMerge } from './rules/predicate/rule-filter-merge.js';
@@ -22,6 +25,9 @@ import { ruleJoinGreedyCommute } from './rules/join/rule-join-greedy-commute.js'
22
25
  import { ruleAggregatePhysical } from './rules/aggregate/rule-aggregate-streaming.js';
23
26
  import { ruleQuickPickJoinEnumeration } from './rules/join/rule-quickpick-enumeration.js';
24
27
  import { ruleJoinPhysicalSelection } from './rules/join/rule-join-physical-selection.js';
28
+ import { ruleMonotonicMergeJoin } from './rules/join/rule-monotonic-merge-join.js';
29
+ import { ruleLateralTop1Asof } from './rules/join/rule-lateral-top1-asof.js';
30
+ import { ruleMonotonicWindow } from './rules/window/rule-monotonic-window.js';
25
31
  // Constraint rules removed - now handled in builders for correctness
26
32
  import { ruleCteOptimization } from './rules/cache/rule-cte-optimization.js';
27
33
  import { ruleMutatingSubqueryCache } from './rules/cache/rule-mutating-subquery-cache.js';
@@ -169,9 +175,42 @@ export class Optimizer {
169
175
  fn: ruleAggregatePhysical,
170
176
  priority: 20
171
177
  });
178
+ // Recognize lateral-top-1 asof. Runs in the Structural pass (before
179
+ // predicate-pushdown at priority 20) so the lateral's Filter still
180
+ // carries the asof predicate intact — predicate-pushdown would
181
+ // otherwise consume it into the inner Retrieve pipeline.
182
+ this.passManager.addRuleToPass(PassId.Structural, {
183
+ id: 'lateral-top1-asof',
184
+ nodeType: PlanNodeType.Join,
185
+ phase: 'rewrite',
186
+ fn: ruleLateralTop1Asof,
187
+ priority: 5
188
+ });
172
189
  // Post-optimization pass rules (bottom-up) - for cleanup and caching
173
190
  // Physical join selection runs here (after Physical pass) so QuickPick can
174
191
  // see the full logical join tree before any physical conversion happens.
192
+ // Monotonic-aware merge-join recognition runs first (lower priority) so
193
+ // it can recognise cases where both sides advertise MonotonicOn but
194
+ // `physical.ordering` does not match positionally — once it converts a
195
+ // Join into a MergeJoin, the ordering-based rule no-ops on it.
196
+ this.passManager.addRuleToPass(PassId.PostOptimization, {
197
+ id: 'monotonic-merge-join',
198
+ nodeType: PlanNodeType.Join,
199
+ phase: 'impl',
200
+ fn: ruleMonotonicMergeJoin,
201
+ priority: 4
202
+ });
203
+ // Monotonic streaming-window recognition. Runs after monotonic-merge-join
204
+ // (priority 4) so child joins have already become MergeJoins and
205
+ // propagate their `monotonicOn`; runs before monotonic-limit-pushdown
206
+ // (priority 8) but does not interact with it (different node type).
207
+ this.passManager.addRuleToPass(PassId.PostOptimization, {
208
+ id: 'monotonic-window',
209
+ nodeType: PlanNodeType.Window,
210
+ phase: 'impl',
211
+ fn: ruleMonotonicWindow,
212
+ priority: 6
213
+ });
175
214
  this.passManager.addRuleToPass(PassId.PostOptimization, {
176
215
  id: 'join-physical-selection',
177
216
  nodeType: PlanNodeType.Join,
@@ -179,6 +218,48 @@ export class Optimizer {
179
218
  fn: ruleJoinPhysicalSelection,
180
219
  priority: 5
181
220
  });
221
+ // Monotonic LIMIT/OFFSET pushdown: replace LimitOffset[/Sort]/access-leaf
222
+ // with OrdinalSlice when the leaf advertises supportsOrdinalSeek. Runs in
223
+ // PostOptimization so the leaf already carries its physical capabilities.
224
+ this.passManager.addRuleToPass(PassId.PostOptimization, {
225
+ id: 'monotonic-limit-pushdown',
226
+ nodeType: PlanNodeType.LimitOffset,
227
+ phase: 'impl',
228
+ fn: ruleMonotonicLimitPushdown,
229
+ priority: 8
230
+ });
231
+ // Monotonic range-scan recognition. Runs on physical leaves to annotate
232
+ // `rangeBoundedOn` when a handled range/equality bounds the monotonic
233
+ // column. Also runs on Filter nodes for the defensive escalation: drop
234
+ // `monotonicOn` from a leaf when an unhandled range predicate sits in a
235
+ // directly-overhead Filter. Runs after the limit pushdown (priority 9)
236
+ // so that an OrdinalSlice rewrite has already replaced any leaf it
237
+ // would have annotated; ordering vs. join-physical-selection (priority 5)
238
+ // is not load-bearing — `rangeBoundedOn` is a pure annotation today and
239
+ // the defensive drop only matters for downstream rules that check
240
+ // `physical.monotonicOn` (asof/merge-join/limit-pushdown), which run
241
+ // later in the same pass or have already run.
242
+ const rangeAccessLeafTypes = [
243
+ PlanNodeType.IndexScan,
244
+ PlanNodeType.IndexSeek,
245
+ PlanNodeType.SeqScan,
246
+ ];
247
+ for (const nodeType of rangeAccessLeafTypes) {
248
+ this.passManager.addRuleToPass(PassId.PostOptimization, {
249
+ id: `monotonic-range-access-${nodeType}`,
250
+ nodeType,
251
+ phase: 'rewrite',
252
+ fn: ruleMonotonicRangeAccess,
253
+ priority: 9
254
+ });
255
+ }
256
+ this.passManager.addRuleToPass(PassId.PostOptimization, {
257
+ id: 'monotonic-range-access-filter',
258
+ nodeType: PlanNodeType.Filter,
259
+ phase: 'rewrite',
260
+ fn: ruleMonotonicRangeAccess,
261
+ priority: 9
262
+ });
182
263
  this.passManager.addRuleToPass(PassId.PostOptimization, {
183
264
  id: 'mutating-subquery-cache',
184
265
  nodeType: PlanNodeType.Join,
@@ -186,6 +267,16 @@ export class Optimizer {
186
267
  fn: ruleMutatingSubqueryCache,
187
268
  priority: 10
188
269
  });
270
+ // AsofScan strategy selection (hash → merge). Runs after the leaves'
271
+ // physical.ordering / monotonicOn are finalized (range-access at
272
+ // priority 9) so the predicate-driven check can read them off.
273
+ this.passManager.addRuleToPass(PassId.PostOptimization, {
274
+ id: 'asof-strategy-select',
275
+ nodeType: PlanNodeType.AsofScan,
276
+ phase: 'impl',
277
+ fn: ruleAsofStrategySelect,
278
+ priority: 11
279
+ });
189
280
  this.passManager.addRuleToPass(PassId.PostOptimization, {
190
281
  id: 'cte-optimization',
191
282
  nodeType: PlanNodeType.CTE,
@@ -1 +1 @@
1
- {"version":3,"file":"optimizer.js","sourceRoot":"","sources":["../../../src/planner/optimizer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAmB,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAExE,4BAA4B;AAC5B,OAAO,EAAE,cAAc,EAAE,CAAC;AAE1B,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpG,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAmB,MAAM,wBAAwB,CAAC;AAE3E,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC1D,gBAAgB;AAChB,OAAO,EAAE,2BAA2B,EAAE,MAAM,gDAAgD,CAAC;AAC7F,kBAAkB;AAClB,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CA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AAgB,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC;QAE3F,gCAAgC;QAChC,MAAM,eAAe,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,KAAK,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;QAE5F,IAAI,CAAC,eAAe,EAAE,CAAC;YACtB,OAAO,IAAI,CAAC,CAAC,aAAa;QAC3B,CAAC;QAED,8DAA8D;QAC9D,oEAAoE;QACpE,OAAO,IAAI,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAAC;IAC7C,CAAC;IAED;;OAEG;IACH,QAAQ;QACP,OAAO,IAAI,CAAC,KAAK,CAAC;IACnB,CAAC;IAED,qDAAqD;IACrD,kBAAkB;QACjB,OAAO,IAAI,CAAC,eAAe,CAAC;IAC7B,CAAC"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Rule: AsofScan strategy selection (hash → merge).
3
+ *
4
+ * Promotes an `AsofScanNode` from the default `'hash'` strategy to the
5
+ * co-streaming `'merge'` strategy when:
6
+ *
7
+ * - Both children advertise `physical.ordering` whose leading
8
+ * `partitionAttrs.length + 1` entries form `[partition cols..., matchAttr]`.
9
+ * - At each partition position, left and right's attribute IDs pair up via
10
+ * a `partitionAttrs` equi-pair, in the same direction on both sides.
11
+ * - The trailing match-attr ordering on each side is ASC. The merge emitter
12
+ * walks both inputs forward — `direction='desc'` (latest right ≤ left)
13
+ * accumulates the largest qualifier seen; `direction='asc'` (earliest
14
+ * right ≥ left) returns the first qualifier. Both forms assume ASC sort
15
+ * on the matchAttr; that aligns with how access-path `monotonicOn` is
16
+ * advertised today (always ascending).
17
+ * - The right's estimated row count meets the configured
18
+ * `tuning.asof.mergeRowThreshold` — below it, hash's constant factors win.
19
+ *
20
+ * Bails to `null` (leaving the hash strategy) on any failure.
21
+ *
22
+ * The merge strategy streams memory O(1) and emits as left rows arrive,
23
+ * unlike the hash variant's O(R) buffering and full-right-arrival latency.
24
+ * Cost is O(L + R) for both — only constant factors differ — so this is a
25
+ * predicate-driven rewrite rather than enumerate-and-cost.
26
+ */
27
+ import type { PlanNode } from '../../nodes/plan-node.js';
28
+ import type { OptContext } from '../../framework/context.js';
29
+ export declare function ruleAsofStrategySelect(node: PlanNode, ctx: OptContext): PlanNode | null;
30
+ //# sourceMappingURL=rule-asof-strategy-select.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rule-asof-strategy-select.d.ts","sourceRoot":"","sources":["../../../../../src/planner/rules/access/rule-asof-strategy-select.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AA+B7D,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,UAAU,GAAG,QAAQ,GAAG,IAAI,CA6EvF"}
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Rule: AsofScan strategy selection (hash → merge).
3
+ *
4
+ * Promotes an `AsofScanNode` from the default `'hash'` strategy to the
5
+ * co-streaming `'merge'` strategy when:
6
+ *
7
+ * - Both children advertise `physical.ordering` whose leading
8
+ * `partitionAttrs.length + 1` entries form `[partition cols..., matchAttr]`.
9
+ * - At each partition position, left and right's attribute IDs pair up via
10
+ * a `partitionAttrs` equi-pair, in the same direction on both sides.
11
+ * - The trailing match-attr ordering on each side is ASC. The merge emitter
12
+ * walks both inputs forward — `direction='desc'` (latest right ≤ left)
13
+ * accumulates the largest qualifier seen; `direction='asc'` (earliest
14
+ * right ≥ left) returns the first qualifier. Both forms assume ASC sort
15
+ * on the matchAttr; that aligns with how access-path `monotonicOn` is
16
+ * advertised today (always ascending).
17
+ * - The right's estimated row count meets the configured
18
+ * `tuning.asof.mergeRowThreshold` — below it, hash's constant factors win.
19
+ *
20
+ * Bails to `null` (leaving the hash strategy) on any failure.
21
+ *
22
+ * The merge strategy streams memory O(1) and emits as left rows arrive,
23
+ * unlike the hash variant's O(R) buffering and full-right-arrival latency.
24
+ * Cost is O(L + R) for both — only constant factors differ — so this is a
25
+ * predicate-driven rewrite rather than enumerate-and-cost.
26
+ */
27
+ import { createLogger } from '../../../common/logger.js';
28
+ import { AsofScanNode } from '../../nodes/asof-scan-node.js';
29
+ const log = createLogger('optimizer:rule:asof-strategy-select');
30
+ /**
31
+ * Translate the leading `prefixLen` ordering entries on a child to
32
+ * (attrId, desc) pairs. Returns null when the ordering is shorter than
33
+ * required or contains entries that do not map to a known attribute.
34
+ */
35
+ function mapLeadingOrdering(ordering, attrs, prefixLen) {
36
+ if (!ordering || ordering.length < prefixLen)
37
+ return null;
38
+ const out = [];
39
+ for (let i = 0; i < prefixLen; i++) {
40
+ const entry = ordering[i];
41
+ const attr = attrs[entry.column];
42
+ if (!attr)
43
+ return null;
44
+ out.push({ attrId: attr.id, desc: entry.desc });
45
+ }
46
+ return out;
47
+ }
48
+ export function ruleAsofStrategySelect(node, ctx) {
49
+ if (!(node instanceof AsofScanNode))
50
+ return null;
51
+ if (node.strategy !== 'hash')
52
+ return null;
53
+ const partitionLen = node.partitionAttrs.length;
54
+ const prefixLen = partitionLen + 1;
55
+ const leftAttrs = node.left.getAttributes();
56
+ const rightAttrs = node.right.getAttributes();
57
+ const leftOrdering = mapLeadingOrdering(node.left.physical.ordering, leftAttrs, prefixLen);
58
+ if (!leftOrdering) {
59
+ log('Left does not provide a long enough ordering prefix (need %d)', prefixLen);
60
+ return null;
61
+ }
62
+ const rightOrdering = mapLeadingOrdering(node.right.physical.ordering, rightAttrs, prefixLen);
63
+ if (!rightOrdering) {
64
+ log('Right does not provide a long enough ordering prefix (need %d)', prefixLen);
65
+ return null;
66
+ }
67
+ // Partition prefix: at each ordering position, left's attr-id must be the
68
+ // `leftAttrId` of one of the partition pairs; the same position on the
69
+ // right must carry the corresponding `rightAttrId`. Directions must match.
70
+ const remainingPairs = node.partitionAttrs.slice();
71
+ for (let i = 0; i < partitionLen; i++) {
72
+ const leftEntry = leftOrdering[i];
73
+ const rightEntry = rightOrdering[i];
74
+ if (leftEntry.desc !== rightEntry.desc) {
75
+ log('Direction mismatch at partition position %d (left=%s, right=%s)', i, leftEntry.desc ? 'desc' : 'asc', rightEntry.desc ? 'desc' : 'asc');
76
+ return null;
77
+ }
78
+ const pairIdx = remainingPairs.findIndex(p => p.leftAttrId === leftEntry.attrId && p.rightAttrId === rightEntry.attrId);
79
+ if (pairIdx < 0) {
80
+ log('Position %d (left=%d, right=%d) does not pair via partitionAttrs', i, leftEntry.attrId, rightEntry.attrId);
81
+ return null;
82
+ }
83
+ remainingPairs.splice(pairIdx, 1);
84
+ }
85
+ // Trailing entry on each side must be the asof match attribute, ASC.
86
+ // The merge emitter walks both inputs forward; that requires ascending
87
+ // match-attr ordering on both sides regardless of the asof direction.
88
+ const tailLeft = leftOrdering[partitionLen];
89
+ const tailRight = rightOrdering[partitionLen];
90
+ if (tailLeft.attrId !== node.matchAttr.leftAttrId) {
91
+ log('Left ordering tail (attr=%d) is not the match attr (attr=%d)', tailLeft.attrId, node.matchAttr.leftAttrId);
92
+ return null;
93
+ }
94
+ if (tailRight.attrId !== node.matchAttr.rightAttrId) {
95
+ log('Right ordering tail (attr=%d) is not the match attr (attr=%d)', tailRight.attrId, node.matchAttr.rightAttrId);
96
+ return null;
97
+ }
98
+ if (tailLeft.desc || tailRight.desc) {
99
+ log('Match-attr ordering must be ASC on both sides (left=%s, right=%s)', tailLeft.desc ? 'desc' : 'asc', tailRight.desc ? 'desc' : 'asc');
100
+ return null;
101
+ }
102
+ // Threshold gate.
103
+ const tuning = ctx.tuning;
104
+ const rightRows = node.right.estimatedRows ?? tuning.defaultRowEstimate;
105
+ if (rightRows < tuning.asof.mergeRowThreshold) {
106
+ log('Right estimated rows (%d) below merge threshold (%d); keeping hash', rightRows, tuning.asof.mergeRowThreshold);
107
+ return null;
108
+ }
109
+ log('Promoting AsofScan to merge strategy (rightRows=%d, partitionCols=%d)', rightRows, partitionLen);
110
+ return node.withStrategy('merge');
111
+ }
112
+ //# sourceMappingURL=rule-asof-strategy-select.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rule-asof-strategy-select.js","sourceRoot":"","sources":["../../../../../src/planner/rules/access/rule-asof-strategy-select.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGzD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAE7D,MAAM,GAAG,GAAG,YAAY,CAAC,qCAAqC,CAAC,CAAC;AAOhE;;;;GAIG;AACH,SAAS,kBAAkB,CAC1B,QAAkE,EAClE,KAAgC,EAChC,SAAiB;IAEjB,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,MAAM,GAAG,SAAS;QAAE,OAAO,IAAI,CAAC;IAC1D,MAAM,GAAG,GAAoB,EAAE,CAAC;IAChC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,EAAE,CAAC,EAAE,EAAE,CAAC;QACpC,MAAM,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;QAC1B,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACjC,IAAI,CAAC,IAAI;YAAE,OAAO,IAAI,CAAC;QACvB,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;IACjD,CAAC;IACD,OAAO,GAAG,CAAC;AACZ,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,IAAc,EAAE,GAAe;IACrE,IAAI,CAAC,CAAC,IAAI,YAAY,YAAY,CAA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I,SAAS,CAAC,IAAI,EAAE,CAAC;QACrC,GAAG,CAAC,mEAAmE,EACtE,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,EAC9B,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QAClC,OAAO,IAAI,CAAC;IACb,CAAC;IAED,kBAAkB;IAClB,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC;IAC1B,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,IAAI,MAAM,CAAC,kBAAkB,CAAC;IACxE,IAAI,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAC/C,GAAG,CAAC,oEAAoE,EACvE,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAC3C,OAAO,IAAI,CAAC;IACb,CAAC;IAED,GAAG,CAAC,uEAAuE,EAC1E,SAAS,EAAE,YAAY,CAAC,CAAC;IAC1B,OAAO,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;AACnC,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Rule: Monotonic LIMIT/OFFSET pushdown
3
+ *
4
+ * Pattern (the rule peels through these in order, top-down from the
5
+ * LimitOffsetNode toward the leaf):
6
+ *
7
+ * LimitOffsetNode
8
+ * └─ SortNode? (single trivial column ref matching leaf monotonicOn)
9
+ * └─ (ProjectNode | AliasNode)* (only trivial column-reference projections)
10
+ * └─ IndexScan / IndexSeek / SeqScan
11
+ * (advertises monotonicOn AND accessCapabilities.ordinalSeek)
12
+ *
13
+ * On a successful match, the entire `LimitOffset[/Sort]/.../leaf` subtree is
14
+ * replaced with `…/OrdinalSlice(leaf)` — the OrdinalSlice slots in directly
15
+ * above the leaf, threading the resolved offset/limit into the leaf's
16
+ * FilterInfo so the vtab can seek directly to the kth row in O(log N)
17
+ * instead of buffering k+n rows.
18
+ *
19
+ * Trivial Project nodes (all projections are bare ColumnReferenceNodes) and
20
+ * Alias wrappers preserve row count and order, so we can descend through
21
+ * them — the OrdinalSlice still slices the leaf in monotonic order.
22
+ *
23
+ * The rule rejects all of:
24
+ * - `Sort` whose key isn't a single trivial column ref into the leaf
25
+ * - `Sort` direction mismatching the advertised `monotonicOn.direction`
26
+ * - any non-trivial intermediate node (Filter, Distinct, Aggregate, etc.)
27
+ * - leaf advertising `monotonicOn` but not `ordinalSeek`
28
+ * - multi-key `ORDER BY`
29
+ */
30
+ import type { PlanNode } from '../../nodes/plan-node.js';
31
+ import type { OptContext } from '../../framework/context.js';
32
+ export declare function ruleMonotonicLimitPushdown(node: PlanNode, _context: OptContext): PlanNode | null;
33
+ //# sourceMappingURL=rule-monotonic-limit-pushdown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rule-monotonic-limit-pushdown.d.ts","sourceRoot":"","sources":["../../../../../src/planner/rules/access/rule-monotonic-limit-pushdown.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAsB,MAAM,0BAA0B,CAAC;AAE7E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AA+F7D,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,GAAG,QAAQ,GAAG,IAAI,CA0EhG"}
@@ -0,0 +1,162 @@
1
+ /**
2
+ * Rule: Monotonic LIMIT/OFFSET pushdown
3
+ *
4
+ * Pattern (the rule peels through these in order, top-down from the
5
+ * LimitOffsetNode toward the leaf):
6
+ *
7
+ * LimitOffsetNode
8
+ * └─ SortNode? (single trivial column ref matching leaf monotonicOn)
9
+ * └─ (ProjectNode | AliasNode)* (only trivial column-reference projections)
10
+ * └─ IndexScan / IndexSeek / SeqScan
11
+ * (advertises monotonicOn AND accessCapabilities.ordinalSeek)
12
+ *
13
+ * On a successful match, the entire `LimitOffset[/Sort]/.../leaf` subtree is
14
+ * replaced with `…/OrdinalSlice(leaf)` — the OrdinalSlice slots in directly
15
+ * above the leaf, threading the resolved offset/limit into the leaf's
16
+ * FilterInfo so the vtab can seek directly to the kth row in O(log N)
17
+ * instead of buffering k+n rows.
18
+ *
19
+ * Trivial Project nodes (all projections are bare ColumnReferenceNodes) and
20
+ * Alias wrappers preserve row count and order, so we can descend through
21
+ * them — the OrdinalSlice still slices the leaf in monotonic order.
22
+ *
23
+ * The rule rejects all of:
24
+ * - `Sort` whose key isn't a single trivial column ref into the leaf
25
+ * - `Sort` direction mismatching the advertised `monotonicOn.direction`
26
+ * - any non-trivial intermediate node (Filter, Distinct, Aggregate, etc.)
27
+ * - leaf advertising `monotonicOn` but not `ordinalSeek`
28
+ * - multi-key `ORDER BY`
29
+ */
30
+ import { createLogger } from '../../../common/logger.js';
31
+ import { isRelationalNode } from '../../nodes/plan-node.js';
32
+ import { LimitOffsetNode } from '../../nodes/limit-offset.js';
33
+ import { SortNode } from '../../nodes/sort.js';
34
+ import { AliasNode } from '../../nodes/alias-node.js';
35
+ import { ProjectNode } from '../../nodes/project-node.js';
36
+ import { SeqScanNode, IndexScanNode, IndexSeekNode } from '../../nodes/table-access-nodes.js';
37
+ import { ColumnReferenceNode } from '../../nodes/reference.js';
38
+ import { OrdinalSliceNode } from '../../nodes/ordinal-slice-node.js';
39
+ const log = createLogger('optimizer:rule:monotonic-limit-pushdown');
40
+ function isAccessLeaf(node) {
41
+ return node instanceof SeqScanNode || node instanceof IndexScanNode || node instanceof IndexSeekNode;
42
+ }
43
+ /**
44
+ * A Project is "trivial" iff every projection is a bare ColumnReferenceNode.
45
+ * Trivial projects preserve row count, order, and per-row identity, so an
46
+ * OrdinalSlice underneath them still computes the right slice indices.
47
+ *
48
+ * Computed/expression projections might mutate cardinality (impossible for
49
+ * pure scalars, but the conservative check keeps the rule simple) or change
50
+ * the meaning of "kth row" if combined with subqueries; we exclude them.
51
+ */
52
+ function isTrivialProject(project) {
53
+ return project.projections.every(p => p.node instanceof ColumnReferenceNode);
54
+ }
55
+ /**
56
+ * Walk down from `chainRoot` toward the access leaf, descending only through
57
+ * trivial Project / Alias wrappers. Returns null if we hit a non-trivial node
58
+ * before reaching the leaf.
59
+ */
60
+ function peelToLeaf(chainRoot) {
61
+ let cursor = chainRoot;
62
+ let sort;
63
+ if (cursor instanceof SortNode) {
64
+ sort = cursor;
65
+ cursor = cursor.source;
66
+ }
67
+ let safety = 16;
68
+ while (safety-- > 0) {
69
+ if (isAccessLeaf(cursor)) {
70
+ return { leaf: cursor, chainRoot, sort };
71
+ }
72
+ if (cursor instanceof AliasNode) {
73
+ cursor = cursor.source;
74
+ continue;
75
+ }
76
+ if (cursor instanceof ProjectNode && isTrivialProject(cursor)) {
77
+ cursor = cursor.source;
78
+ continue;
79
+ }
80
+ return null;
81
+ }
82
+ return null;
83
+ }
84
+ /**
85
+ * Rebuild the chain `chainRoot → … → oldLeaf` with `oldLeaf` replaced by
86
+ * `newLeaf`. Each intermediate node is reconstructed via `withChildren`,
87
+ * preserving its other children (scalar inputs to Project / Sort).
88
+ */
89
+ function rebuildChain(chainRoot, oldLeaf, newLeaf) {
90
+ if (chainRoot === oldLeaf) {
91
+ return newLeaf;
92
+ }
93
+ const originalChildren = chainRoot.getChildren();
94
+ const newChildren = originalChildren.map(child => {
95
+ if (isRelationalNode(child)) {
96
+ return rebuildChain(child, oldLeaf, newLeaf);
97
+ }
98
+ return child;
99
+ });
100
+ return chainRoot.withChildren(newChildren);
101
+ }
102
+ export function ruleMonotonicLimitPushdown(node, _context) {
103
+ if (!(node instanceof LimitOffsetNode))
104
+ return null;
105
+ // Degenerate LimitOffset (no bounds) — nothing to push down.
106
+ if (!node.limit && !node.offset)
107
+ return null;
108
+ const peeled = peelToLeaf(node.source);
109
+ if (!peeled) {
110
+ log('Could not peel down to a physical access leaf from %s', node.source.nodeType);
111
+ return null;
112
+ }
113
+ const physical = peeled.leaf.physical;
114
+ if (!physical.accessCapabilities?.ordinalSeek) {
115
+ log('Leaf does not advertise ordinalSeek; skipping');
116
+ return null;
117
+ }
118
+ const monotonicOn = physical.monotonicOn;
119
+ if (!monotonicOn || monotonicOn.length === 0) {
120
+ log('Leaf advertises ordinalSeek but no monotonicOn; skipping');
121
+ return null;
122
+ }
123
+ const leafMonotonic = monotonicOn[0];
124
+ // If a Sort is present, it must be a single trivial column ref whose
125
+ // attribute id and direction match the leaf's monotonicOn[0].
126
+ if (peeled.sort) {
127
+ if (peeled.sort.sortKeys.length !== 1) {
128
+ log('Sort has %d keys; multi-key ORDER BY not supported', peeled.sort.sortKeys.length);
129
+ return null;
130
+ }
131
+ const key = peeled.sort.sortKeys[0];
132
+ if (!(key.expression instanceof ColumnReferenceNode)) {
133
+ log('Sort key is not a trivial column reference');
134
+ return null;
135
+ }
136
+ if (key.expression.attributeId !== leafMonotonic.attrId) {
137
+ log('Sort key attr=%d does not match leaf monotonicOn attr=%d', key.expression.attributeId, leafMonotonic.attrId);
138
+ return null;
139
+ }
140
+ if (key.direction !== leafMonotonic.direction) {
141
+ log('Sort direction %s does not match leaf monotonicOn direction %s', key.direction, leafMonotonic.direction);
142
+ return null;
143
+ }
144
+ }
145
+ // Build OrdinalSlice over the leaf, then re-stitch the chain above it.
146
+ const slice = new OrdinalSliceNode(node.scope, peeled.leaf, leafMonotonic.attrId, node.offset, node.limit, leafMonotonic.direction);
147
+ // `chainRoot` is the original LimitOffset.source — could be Sort, Project,
148
+ // Alias, or the leaf itself. We replace the leaf in that chain with the
149
+ // slice and drop the Sort if present (the slice preserves emit order).
150
+ let rewrittenSource;
151
+ if (peeled.sort) {
152
+ // Drop the Sort entirely: the slice's source already emits in the
153
+ // requested order, so re-sorting would be wasteful.
154
+ rewrittenSource = rebuildChain(peeled.sort.source, peeled.leaf, slice);
155
+ }
156
+ else {
157
+ rewrittenSource = rebuildChain(peeled.chainRoot, peeled.leaf, slice);
158
+ }
159
+ log('Replaced LimitOffset[/Sort]/leaf with OrdinalSlice (attr=%d, %s)', leafMonotonic.attrId, leafMonotonic.direction);
160
+ return rewrittenSource;
161
+ }
162
+ //# sourceMappingURL=rule-monotonic-limit-pushdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rule-monotonic-limit-pushdown.js","sourceRoot":"","sources":["../../../../../src/planner/rules/access/rule-monotonic-limit-pushdown.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAC9F,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAErE,MAAM,GAAG,GAAG,YAAY,CAAC,yCAAyC,CAAC,CAAC;AAIpE,SAAS,YAAY,CAAC,IAAc;IACnC,OAAO,IAAI,YAAY,WAAW,IAAI,IAAI,YAAY,aAAa,IAAI,IAAI,YAAY,aAAa,CAAC;AACtG,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,gBAAgB,CAAC,OAAoB;IAC7C,OAAO,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,YAAY,mBAAmB,CAAC,CAAC;AAC9E,CAAC;AAWD;;;;GAIG;AACH,SAAS,UAAU,CAAC,SAA6B;IAChD,IAAI,MAAM,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;IAChD,OAAO,eAAe,CAAC;AACxB,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Rule: Monotonic range scan recognition
3
+ *
4
+ * Two responsibilities, gated by node type:
5
+ *
6
+ * 1. **Annotation (leaf nodes — IndexScan / IndexSeek / SeqScan)**:
7
+ * When the leaf advertises `monotonicOn(x)` and its `FilterInfo.constraints`
8
+ * carries a handled range/equality on `x`, set `physical.rangeBoundedOn` so
9
+ * EXPLAIN and downstream rules can read off the symbolic bound. This is a
10
+ * pure annotation — it does not change the row stream.
11
+ *
12
+ * 2. **Defensive `monotonicOn` drop (Filter directly above a leaf)**:
13
+ * If a `FilterNode` sits directly above a leaf that advertises
14
+ * `monotonicOn(x)` and the filter's predicate contains a range or equality
15
+ * on `x` (i.e., the vtab declined to handle the bound), the row stream
16
+ * emerging from the *Filter* is no longer monotonic over the WHERE-restricted
17
+ * set. Drop `monotonicOn` (and the implied `accessCapabilities`) from the
18
+ * leaf so downstream rules (asof, merge-join) don't make false assumptions.
19
+ *
20
+ * The rule runs in the PostOptimization pass so it sees physical leaves with
21
+ * lifted advertisements + resolved FilterInfo. The annotation reads off the
22
+ * leaf's own `FilterInfo.constraints` (the canonical record of which bounds
23
+ * the access path is walking with). The defensive escalation reads the parent
24
+ * Filter's predicate.
25
+ */
26
+ import type { PlanNode } from '../../nodes/plan-node.js';
27
+ import type { OptContext } from '../../framework/context.js';
28
+ export declare function ruleMonotonicRangeAccess(node: PlanNode, _ctx: OptContext): PlanNode | null;
29
+ //# sourceMappingURL=rule-monotonic-range-access.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rule-monotonic-range-access.d.ts","sourceRoot":"","sources":["../../../../../src/planner/rules/access/rule-monotonic-range-access.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAuN7D,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,GAAG,QAAQ,GAAG,IAAI,CAQ1F"}