Repository navigation
Add query_plan_aggregation_bucket_top_k - #116124
Conversation
|
Workflow [PR], commit [09c140b] Summary: ✅
AI ReviewSummaryThis PR splits the bucket top-K rewrite under its own Tests
Final VerdictChanges requested: add JSON LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 31/36 (86.11%) · Uncovered code |
| SET query_plan_aggregation_bucket_top_k = 1; | ||
|
|
||
| -- The matching shape carries the flag. | ||
| SELECT count() FROM (EXPLAIN actions = 1 SELECT number % 1000 AS k, count() AS c FROM numbers(100000) GROUP BY k ORDER BY c DESC LIMIT 10) |
There was a problem hiding this comment.
The new stateless coverage still exercises only EXPLAIN actions = 1, but this PR now changes EXPLAIN json = 1 as well. That means AggregatingStep::describeActions(JSONBuilder::JSONMap &) can regress without tripping CI; that is exactly what happened between the first and second commits here. Please add a focused JSON assertion for the Bucket Top-K object and its Ascending field.
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction. Compile time of recompiled translation units10 translation units recompiled, 30 s compile time in total, 10 of them have a recent master baseline. |
Backport #116124 to 26.8: Add `query_plan_aggregation_bucket_top_k`
… threshold merge serves `count` with riders Master's #116124 put the bucket-local selection under `query_plan_aggregation_bucket_top_k`; the shared plan pass now runs under the disjunction of that setting and `enable_aggregation_top_k_threshold_merge`, and each optimization checks its own flag, so disabling one no longer silently disables the other. Also, per review: the lone-count selection (`bucket_top_k`) no longer preempts the threshold merge when other aggregates ride along - there the merge is the better deal, since it also skips merging the losers' other states. The selection still serves the lone `count` and the shapes the merge does not (e.g. the ascending order). Co-Authored-By: Claude Fable 5 <[email protected]>
Related: #115755
The bucket top-K plan optimization (materializing only each two-level bucket's best
ngroups when a final aggregation feedsORDER BYover its outputs withLIMIT nand the per-bucket selection is provably exact) currently runs unconditionally underquery_plan_enable_optimizations. This PR gives it a dedicated setting,query_plan_aggregation_bucket_top_k(enabled by default), makes the pushed flag visible inEXPLAINoutput (Bucket top-K: n ascending/descending), and adds a test covering the shapes where the rewrite must and must not fire plus an exactness pair. The toggle was split out of #115755 per review.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Adds setting
query_plan_aggregation_bucket_top_k(enabled by default) to toggle the plan optimization that materializes only each two-level bucket's bestngroups when a final aggregation feedsORDER BYover its outputs withLIMIT n. The optimization is now also visible inEXPLAINoutput.Workflow [PR]
Sync PR [sync-upstream/pr/116124]
Version info
26.8.1.1998