model-writtenrun 4876 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
Jun - Jul 2021 · 9 entries
- David Rowley proposed planner-selected presorted inputs for ORDER BY and DISTINCT aggregates in #1, aiming to remove unnecessary executor sorts and unblock future parallel aggregation work; the initial implementation favored the first compatible aggregate ordering and lacked DISTINCT JIT support.
- Ronan Dunklau questioned changes to unordered aggregate output in #2, while David Rowley, Gavin Flower, and Tom Lane accepted that unspecified ordering could change in #3, #4, and #5.
- Ronan Dunklau traced the performance regression to Sort nodes lacking the aggregate executor's single-datum tuplesort optimization in #6, supplied an independent patch and benchmarks in #7, and accepted Ranier Vilela's cleanup in #8 and #9.
- James Coleman recommended separating the single-datum optimization in #12, and Ronan Dunklau moved it to another thread and commitfest entry in #13; David Rowley's measurements in #14 confirmed that combining the two optimizations eliminated the observed regression.
- James Coleman reviewed the main design in #11, discussing selection by the number of benefiting aggregates and identifying a merge-join ordering change that prevented incremental sorting.
- David Rowley split ORDER BY support from unfinished DISTINCT support in #15 and incorporated Ranier Vilela's variable-scope feedback in #17.
- Ronan Dunklau's concern about target-list-dependent ordering in #21 led David Rowley to choose the ordering serving the most aggregates in #23, while temporarily omitting DISTINCT to isolate failures caused by missing JIT support.
- David Rowley corrected handling of unsortable grouping keys in #24, then addressed Ronan Dunklau's redundant-key report in #25 by integrating GROUP BY and aggregate pathkey construction in #27.
- Testing exposed changed postgres_fdw aggregation pushdown choices in #28; discussion through #31 attributed these to costing and rejected an unconditional preference for remote aggregation because local grouping could sometimes perform better.
Mar - Apr 2022 · 1 entry
- After a long gap and the sqljson test-ordering issue reported in #32, David Rowley resumed the work in #34, adapting it to GROUP BY key reordering, restoring DISTINCT with LLVM support, and pursuing the merge-join improvement separately.
Jul - Aug 2022 · 4 entries
- Richard Guo found that aggregates requiring weaker compatible orderings were not marked presorted in #36, and David Rowley fixed that in #37; Richard verified the fix in #39, while index-aware selection of aggregate ordering was explicitly deferred in #41.
- Tom Lane's final review in #44 requested explicit initialization and clearer test-plan changes; David Rowley landed #37 with those light adjustments as 1349d2790b and explained the temporary FDW cost setting and preceding merge-join fix in #45.
- Zhihong Yu supplied post-landing field-removal patches in #48 and #49; David Rowley removed one additional unused field and committed the cleanup as 9fc1776dda, confirming the change in #50.
- Justin Pryzby identified a shadowed group_pathkeys variable in #51, prompting af7d270dd3; David Rowley explained in #52 that the affected partial-aggregation path could not currently encounter differing values, making this a hypothetical correctness issue.
Nov 2022 - Jan 2023 · 8 entries
- Pavel Luzanov reported a real performance regression in #53, and Ronan Dunklau traced it to pessimistic incremental-sort costing in #54; Pavel's measurements in #57 confirmed that the rejected incremental-sort plan was faster.
- David Rowley proposed removing the incremental-sort cost multiplier and avoiding competing full-sort paths in #58; Pavel Luzanov confirmed improved plan selection in #59, and Richard Guo's unnecessary-path report in #60 was addressed in #62.
- Skewed-data testing in #63 demonstrated that incremental sorting could still regress, leading David Rowley to favor realistic costing plus an enable_presorted_aggregate escape hatch instead of retaining blanket pessimism.
- The expanded series in #64 applied the sorting strategy across additional planner paths, bundled an isolation-test prerequisite whose discussion belonged elsewhere, and added the new GUC; its incremental-sort component landed unchanged as 4a29eabd1d, announced in #65.
- David Rowley moved GUC discussion to a separate thread in #65, and the GUC component already attached in #64 subsequently landed unchanged as 3226f47282.
- Dean Rasheed reported failure of COUNT(DISTINCT random()) in #66, Richard Guo diagnosed the missing target-list expression in #67, and David Rowley proposed excluding volatile aggregate sort keys in #68.
- Dean Rasheed explained in #72 that sharing a presort across volatile aggregates could change their independent evaluation semantics, supporting the discussion-derived fix da5800d5fa, whose landing David Rowley confirmed in #73.
- All six candidate changes had landed by the final discussion, but broader inconsistencies between volatile expressions in query ORDER BY and aggregate ORDER BY remained unresolved; examples in #76 and #78 led Tom Lane to caution against changing established semantics in #79.