Repository navigation
Reduce SORT ROLLUP finalization and window allocations - #31584
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
…19ad499c710154f16eaf824d3d27e26fae31e11
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: e9281125b65348d22cdfe7afafa28c5a69f2871d
Assessment: approve
Reviewed the complete change, affected consumers, ownership and failure paths. No actionable defects remain. Aggregate reuse preserves fallback behavior, arithmetic, output ownership and cleanup.
Model: gpt-6-astra / xhigh
Session: 01a13dcf-1586-7a01-9000-d45e20995cf8 · slot 1 · generation 1
Validation:
-
Reused frozen-head successful build, UT, static-analysis, coverage and multi-CN BVT statuses.
-
Inspected regression tests and existing SQL result oracles; reconciled all discussion entries.
-
Source and discussion integrity check passed: checks/1793192362985754652-3.json, with review-integrity.log.
Limitations:
-
Raw CI and author validation logs were not supplied; no local Go tests were rerun.
-
Benchmarks predate the merged head. Conflicting low-NDV sampling windows limit performance conclusions; no general non-regression claim is established.
🚫 Left the queue32 min in the queue, with no time running CI. So far
Reason Pull request #31584 has been dequeued Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.
Hint You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it. Merge conditions: 2 of 3 metThis pull request
The batch, tested in place
Tick the box to put this pull request back in the merge queue (same as
Times in UTC · dashboard · how the merge queue works |
…19ad499c710154f16eaf824d3d27e26fae31e11
…19ad499c710154f16eaf824d3d27e26fae31e11
What type of PR is this?
Which issue(s) this PR fixes:
What this PR does / why we need it:
SORT ROLLUP repeatedly finalizes and rebuilds completed aggregate groups and allocates argument windows. At high group cardinality, these costs can dominate aggregation. This change reuses single-group state through append/reset and fills input ranges directly when the complete aggregate list supports the narrow COUNT/native SUM/AVG fast path. A list containing any unsupported aggregate keeps the existing path for the whole list. Results, NULL handling, output ownership, cancellation checks, planner admission, and COST thresholds are preserved.
This is a follow-up to merged #28987 (SORT ROLLUP feature) and #31505 (DISTINCT correctness and ordered-input admission). Those DISTINCT/admission fixes are already present; this PR addresses the remaining executor cost. The earlier static cost concern is separate from the pre-merge measurements below. This change does not optimize every SORT ROLLUP workload. After merge, the original reporter should verify the remaining workload against this change.
Validation at the merged PR head
At
e9281125b65348d22cdfe7afafa28c5a69f2871d:vcs.modified=false; gpt-6-astra medium final overall review passed at this head.The earlier two complete ROLLUP BVT runs (51/51 each) and full cancellation/timeout matrix (10 result checks, 6 resource-closure checks, including client cancellation, KILL QUERY/CONNECTION, reuse, and cleanup) remain evidence from pre-merge revision
07701c4cd47779ca7017b4674c3552fed719b815, reviewed with the documentation update at44aab779ca5b5430c12edd22fba8758577b434f6. These full matrices were not rerun at the merged head.Performance and limitations
Pre-merge local physical-operator benchmarks on Apple M4, Go 1.27.1, GOMAXPROCS=4 (100 ms, three samples per shape) show 78–94% lower time and more than 96% lower B/op and allocs/op for four ordered high-NDV shapes against the pre-change SORT implementation. Derived-input shapes including sorting also improve. These are historical operator measurements of production candidate
c123861e5500408a2f1798a0f8e4e80a05a35d22with final benchmark fixtures at07701c4cd47779ca7017b4674c3552fed719b815(pre-merge reviewed head44aab779ca5b5430c12edd22fba8758577b434f6). No performance timing was rerun after the main merge ate9281125b65348d22cdfe7afafa28c5a69f2871d; the final review confirms the optimization mechanism and the applicability of these historical results, without establishing merged-head percentages, exact timings, or absence of regression. There are no SQL end-to-end or multi-CN performance claims.Forced SORT remains 1.08–6.80x slower than the retained shared-HASH baseline in the measured comparisons. DISTINCT, dedicated decimal implementations, MIN/MAX, and unsupported mixed lists are not accelerated. Earlier design-document performance numbers remain historical calibration, separate from the pre-merge candidate measurements above; neither set is a new measurement of the merged revision.
In those pre-merge measurements, for low-NDV protection, all three contemporaneous baseline/candidate pairs per shape fit the unchanged 20% engineering budget (nine pairs total, maximum ratio 1.128; median ratios 0.977/1.048/0.932). Pooling measurements across different periods instead gives COUNT/AVG ratios of 1.283/1.473, exceeding that budget; the initial comparison was also unfavorable. Using all contemporaneous pairs as the primary acceptance evidence is an explicitly reviewed, post-hoc applicability revision. The small sample and fixed baseline-first order limit the conclusion: this is not statistical proof of no regression.
CI remains pending and is separate from the local results above. No real multi-CN run was performed; distributed routing/state and compiler placement gates are unchanged.