model-writtenrun 5067 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- David Rowley proposed replacing Unique with LIMIT 1 when constants make all DISTINCT pathkeys redundant, allowing execution to stop after the first matching row, and supplied implementation and regression tests in #1.
- Richard Guo supported the optimization but questioned duplicate Limit nodes in #2; David explained in #4 that arbitrary existing LIMIT expressions still require the new one-row restriction and that merging them would add planner complexity.
- Richard proposed extending the optimization to DISTINCT ON with remaining ordering requirements in #3 and supplied an inline implementation sketch in #7; after initially considering separate work in #5, David incorporated the extension into #8, covering both presorted paths and explicit top-1 sorts.
- Richard tested the revised implementation and questioned its manual pathkeys override in #9; David identified that override as a leftover from an already-fixed bug and removed it in #10, which Richard approved in #11.
- David revisited merging limits through a LEAST expression in #12, but remained concerned about changing parse fields or adding planner state; Richard agreed in #13 that duplicate Limit nodes could be accepted or addressed separately.
- David committed #10 as 5543677ec9 with light comment and formatting changes, clarifying that rows need only be indistinguishable by equality; his closing message #14 confirms the optimization landed while duplicate-Limit elimination remained outside its scope.