You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A filtered query (city = 'NYC') doesn't read its group from a grouped summary another query builds #902
Q3's per-city KLL already holds the NYC group, but no candidate answers Q2 by reading that group. Q2 always builds its own KLL, and shares neither the scan nor the build with Q1 or Q3.
Expected: a candidate in which Q2 reads the city = 'NYC' group of Q3's per-city summary, with no build of its own.
Confirmed that the memo migration has not added the required filtered-group reuse transformation.
Using the issue's SQL table nullability (only ts explicitly non-nullable), the original three-query workload plans on the local current-engine diagnostic tree, but the filtered query still has its own raw scan/range/aggregate path. A 30 s enforced-accuracy run returned cost 0.3723209703 with exact aggregates; this cost is a bounded-search result, not an optimum.
The structural reason is upstream of MILP: source predicates remain part of scan/input identity, while existing state sharing/rollup requires the same input rows and compatible filters. The memo reuse rules have no transformation that turns the raw city='NYC' predicate into a reader of the unfiltered per-city producer. Scan widening intentionally preserves source predicates. Also, a plain NonASAP Filter currently rejects a State input (NonASAPOp structural validation), so inserting an ordinary Filter directly on a KLL state is not an available implementation.
The fix needs an explicit group-selection/readout candidate, with preserved accuracy and SQL empty-input semantics. Merely filtering Q3's result is insufficient for the original ungrouped Q2: when NYC is absent, Q2's global percentile must produce its NULL aggregate result, whereas filtering grouped output produces zero rows.
A separate diagnostic variant with a non-nullable value column exposed another bug: a grouped-to-global quantile merge was marked non-nullable, causing the rollup output-contract check to abort planning. quantile_may_be_empty did not account for a merge with an empty group_by. A local correction removes that abort. This is an additional variant, NOT the root cause of the original nullable-column example.
No fix for the original filtered-reader transformation is complete yet. Changes/tests are uncommitted; no PR or commit has been published.
Implemented in PR #943. A key-equality reader reuses the existing grouped quantile result, including a KLL readout, without its own summary build. A reduction over at most one selected group preserves the single NULL row required when the group is absent. Execution tests cover missing groups, empty input and NULL-only samples; a multi-group filter does not inherit a single quantile rank bound. Original workload cost falls from 0.3723209703/s to 0.1963089020/s.
Final local validation: 690 focused tests passed, plus workspace format and all-target/all-feature Clippy checks.
Activity
zzylol commentedon Oct 23, 2026
Deferred until the memo search (#879, #888) lands. This sharing/reuse rule will be added as a memo transformation rather than to the legacy search.
devtools: planner_fuzz, a metamorphic fuzz tester for missed reuse an…
zzylol commentedon Oct 27, 2026
Confirmed that the memo migration has not added the required filtered-group reuse transformation.
Using the issue's SQL table nullability (only ts explicitly non-nullable), the original three-query workload plans on the local current-engine diagnostic tree, but the filtered query still has its own raw scan/range/aggregate path. A 30 s enforced-accuracy run returned cost 0.3723209703 with exact aggregates; this cost is a bounded-search result, not an optimum.
The structural reason is upstream of MILP: source predicates remain part of scan/input identity, while existing state sharing/rollup requires the same input rows and compatible filters. The memo reuse rules have no transformation that turns the raw
city='NYC'predicate into a reader of the unfiltered per-city producer. Scan widening intentionally preserves source predicates. Also, a plain NonASAP Filter currently rejects a State input (NonASAPOpstructural validation), so inserting an ordinary Filter directly on a KLL state is not an available implementation.The fix needs an explicit group-selection/readout candidate, with preserved accuracy and SQL empty-input semantics. Merely filtering Q3's result is insufficient for the original ungrouped Q2: when NYC is absent, Q2's global percentile must produce its NULL aggregate result, whereas filtering grouped output produces zero rows.
A separate diagnostic variant with a non-nullable value column exposed another bug: a grouped-to-global quantile merge was marked non-nullable, causing the rollup output-contract check to abort planning.
quantile_may_be_emptydid not account for a merge with an empty group_by. A local correction removes that abort. This is an additional variant, NOT the root cause of the original nullable-column example.No fix for the original filtered-reader transformation is complete yet. Changes/tests are uncommitted; no PR or commit has been published.
zzylol commentedon Oct 27, 2026
Implemented in PR #943. A key-equality reader reuses the existing grouped quantile result, including a KLL readout, without its own summary build. A reduction over at most one selected group preserves the single NULL row required when the group is absent. Execution tests cover missing groups, empty input and NULL-only samples; a multi-group filter does not inherit a single quantile rank bound. Original workload cost falls from 0.3723209703/s to 0.1963089020/s.
Final local validation: 690 focused tests passed, plus workspace format and all-target/all-feature Clippy checks.