model-writtenrun 6306 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Ronan Dunklau opened the thread with an independently useful optimization originally developed alongside ordered-aggregate work: use Datum sorting when a Sort node carries exactly one attribute, initially limited to unbounded, pass-by-value inputs #1.
- James Coleman questioned both restrictions and requested explanatory comments, while Dilip Kumar noted that the Datum API supports other types; Ronan consequently enabled bounded and pass-by-reference sorts and fixed a null-tuple free exposed by bounded sorting #4 #6 #7.
- Ronan clarified that the optimization requires a single input/output attribute, not merely one sort key, so extending it to incremental sort would require broader projection changes; the next revision only corrected formatting #9.
- David Rowley verified that existing regression tests exercised both Datum types, requested naming and bracing cleanup, and separated the bounded-sort bugfix for independent handling; Ronan incorporated the cleanup and then removed that fix after David reported it committed #10 #11 #12 #13.
- Benchmarks showed substantial gains for eligible sorts but raised concerns about small regressions elsewhere, prompting Ranier Vilela's branch-order experiments and David's alternative with separate tuple and Datum executor functions #12 #16 #17 #19.
- Further benchmarks from Ranier, John Naylor, and Ronan did not establish a compelling benefit from duplicated executor functions, while Ronan discovered that the separately discussed local-flag variant forgot the sort mode after returning its first tuple #20 #21 #28 #30.
- David recommended retaining the original single-function architecture while selecting the sort mode during initialization, which Ronan implemented; David explained that actual tuplesort allocation should remain deferred until execution needs it #33 #36 #38.
- James supplied additional benchmarks, and David prepared the final version with clearer comments and consistent bracing; Ranier endorsed that version and acknowledged the correctness problem in his local-flag experiment #37 #39 #40.
- James asked whether planner costs should reflect the speedup, but discussion concluded that the existing cost model offered too little room for a meaningful adjustment without a broader redesign, and James supported proceeding unchanged #41 #42 #44 #45 #49.
- Ranier submitted separate cost_tuplesort() cleanup, but David rejected it as unhelpful and uncompilable and requested any continuation in another thread; David resent the unchanged executor patch to restore CF bot's focus #46 #47 #48.
- Hou Zhijie suggested merging the two input loops, then accepted David's explanation that separate loops keep an extra branch out of the hot per-tuple path, leaving the final patch unchanged #51 #52 #53.
- David committed the exact executor changes from #47 as 91e9e89dcc, crediting Ronan as author, and closed the thread with confirmation that the optimization had landed; costing changes and alternative executor designs were left out #54.