model-writtenrun 7301 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Önder Kalacı reported PostgreSQL 15 merge joins consuming more than 100 GB and potentially exhausting memory, supplied a text-column reproducer, and traced repeated allocations through tuplesort_getdatum() in #1.
- Tom Lane confirmed the leak with Valgrind and bisected it to the single-column Datum-sort optimization in #2; he proposed restricting that optimization to pass-by-value types because adding explicit freeing would complicate the code and require renewed performance testing in #3.
- David Rowley attached the conservative restriction in #4, while proposing a no-copy retrieval function as a possible longer-term solution; Tom requested a clear lifetime contract and suggested that aggregates could also benefit in #5.
- David committed #4 as 3a5817695a, using TupleDescAttr() instead of direct attribute access, and announced the change in #6; the fix was also backpatched to PostgreSQL 15.
- Peter Geoghegan advocated adding a copy argument to the existing retrieval function in #8, while Michael Paquier's suggestion of an EXPLAIN-based regression check in #9 was set aside because David and Tom explained that this optimization is not exposed by EXPLAIN in #10 and #11.
- David posted a separate follow-up in #13 that introduced tuplesort_getdatum_nocopy(), restored by-reference Datum sorting, and avoided unnecessary copies for duplicate aggregate inputs; he reported about a 3% DISTINCT aggregate improvement and left a possible mode_final() optimization unexplored.
- David reported a stronger single-column sorting improvement and said he would move the optimization to another thread and the next CommitFest in #15.
- Ronan Dunklau tested whether compiler specialization could remove branching from a shared copy-argument implementation in #17; Tom rejected duplicating the function without performance evidence in #18, Ronan clarified the scope of his experiment in #19, and Peter supported Tom's objection in #20.
- At the thread's final message, Önder confirmed that the committed leak fix resolved the affected query patterns in #21; the optimization follow-up had been designated for continued work elsewhere.
- The optimization subsequently landed as d37aa3d358 from the later patchset #518781 in thread #46692, with only a comment punctuation change; that later source supersedes the previous attribution to this thread's prototype #13.