Repository navigation
perf: share partition sorting across compatible value windows - #33658
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? |
|
Queue requested — the merge queue status continues in this comment ↓. |
|
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: 9cc0ad17a26e33e5d99048199cd7dac520572cf6
Assessment: approve
No actionable defects found. The change extends the existing window-fusion and execution mechanisms, with guards for compatible layouts and safe arguments.
Model: gpt-6.1-terra / max
Session: 01a23504-137d-7f93-9b91-fd29f7f60fa2 · slot 1 · generation 42
Validation:
-
The focused planner and window tests passed, including spill/reset and later-slot offset validation.
-
A single-CN public SQL probe passed with nullable inputs at low and high spill thresholds. The low-threshold analyzed plan used one Window node and reported seven spilled rows.
-
An independent SQLite oracle matched the probe’s expected values and all seven changed SQL regression result rows.
-
A bounded 100,000-row, 512 MiB threshold comparison returned identical checksums; the candidate’s three measured runs were 25.342–25.874 ms versus 41.181–59.620 ms for the baseline control.
-
The isolation preflight, native input verification, gofmt check, and git diff --check passed.
Limitations:
-
The performance comparison used one shared single-CN host and does not establish performance for all workloads.
-
Full package suites, the BVT harness, race tests, and multi-CN execution were not independently run. The author reports a separate three-CN check; the draining-coordinator configuration remains unverified.
🚫 Left the queue · pull request merged manually2 h 20 min in the queue, with no time running CI. So far
Reason Pull request #33658 has been merged manually at 169ea91 Tick the box to put this pull request back in the merge queue (same as
Times in UTC · dashboard · how the merge queue works |
What type of PR is this?
Which issue(s) this PR fixes:
Related to #27943
What this PR does / why we need it:
The planner built five Partition/Window pairs for LAG, LEAD, FIRST_VALUE, LAST_VALUE and NTH_VALUE even when they all used the same partition keys, ordering and ROWS frame. Each pair could spill the same input separately.
Extend the existing post-remap fusion rule to ordered value functions with safe column or literal arguments. Allow lossless integer source casts and integer modulo partition keys with a positive literal divisor. Keep dynamic offsets, fallible casts, different layouts, dependencies and intermediate filters on their existing paths. The retained Window uses one permutation for its rows and all arguments, and validates every LAG/LEAD slot before publishing a chunk. This uses the existing execution and distribution formats.
On the issue's 100,000-row SQL fixture (single CN, macOS arm64, GOMAXPROCS=4), the plan went from five Window and five Partition nodes to one each. At
sort_spill_mem=1, Window spill rows went from 500,000 to 100,000 and reported Window spill size from about 22.9 MiB to 6.11 MiB. With one warm-up and five timed executions per setting, the median was 68.0 ms on main and 28.1 ms with this patch. At 64 MiB, medians were 35.9 ms and 23.8 ms. These are local SQL timings on a shared machine.Both revisions returned
(100000, 4798977, 4800545, 399995, 8700005, 1099995). Checked 100,000 nullable-source rows against an independent per-row oracle and verified chains for tied ordering at both spill thresholds. With analyzed low-NDV column keys, COST and HASH used Hash Partition and SORT used ordinary Partition, with the same five results. The two affected Go packages, scoped vet and incremental lint passed. The new SQL regression case was executed against the built service.On a three-CN cluster with all CNs working and forced distributed scans, physical ANALYZE showed table scans on both remote peers. One Partition fed one Window, which consumed and emitted all 100,000 rows and spilled 100,000 rows (6,402,520 bytes). The aggregate query matched the independent checksum. In a separate experiment with the coordinator explicitly set to draining, physical ANALYZE exceeded the three-minute timeout on both clean main and the candidate; that configuration remains unverified.
The remaining issue-wide rollout and shuffle-topology criteria require separate validation.