model-writtenrun 1951 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Richard Guo opened the thread with a semijoin plan containing two unnecessary sorts and proposed a cached RelOptInfo whose hash-based and sort-based unique-ification paths compete through add_path(), also identifying apparently dead UNIQUE_PATH_NOOP handling #1.
- Andy Fan supported the approach and asked that startup cost and fractional retrieval be considered when retaining paths #2.
- Richard's first implementation retained JOIN_UNIQUE_OUTER and JOIN_UNIQUE_INNER for uniqueness detection while removing most special handling, and unified semijoin and DISTINCT UniquePath structures #4; the next revision added costing fixes, child-relation handling, parallel-safety checks, and regression coverage #5.
- After roughly a month, Richard rebased the patch and defended exploring multiple paths because the extra work is confined to relevant semijoins and considers promising cheapest or presorted inputs #6.
- Subsequent revisions corrected LATERAL-dependent unique-ification and parameterized-path estimates #7, demonstrated that unique row estimates no longer exceed their input estimates #8, and refined projection and aggregation targets #9.
- Alvaro Herrera tested a larger version of the opening query and reported removal of both sorts and an execution-time improvement from about 733 ms to 621 ms #10; Richard highlighted additional opportunities from presorted alternatives and parallel unique-ification #11.
- Alexandra Wang tested the patch and found a case where its chosen hash-aggregation plan was slower than a sort-based alternative #12; Richard explained that both methods should compete on cost and attributed that choice to inaccurate estimates #13.
- That review led Richard to propose detecting unique-ified relations from the nominal join type, semijoin metadata, and RHS relids #14; wenhui qiu reported further testing and supported the stronger check #15, which Richard adopted #16.
- Alexandra also questioned whether removing JOIN_UNIQUE_OUTER restrictions could admit unsafe partial paths #17; Richard explained that the unique relation has no partial paths and pointed to the assertion enforcing that invariant #18.
- Richard incorporated the semantic uniqueness predicate and expanded the submission to two patches, adding a cleanup of relation_has_unique_index_for() after its expression-list caller disappeared #19.
- wenhui qiu suggested replacing the new macro with an inline function #20, but accepted Richard's decision to keep it consistent with existing relation-classification macros #21 #22.
- A naming discussion started by Alvaro Herrera #24 led Tom Lane to suggest RELATION_WAS_MADE_UNIQUE to distinguish explicit duplicate elimination from inherent uniqueness #27; Richard accepted that name #28 and included it with final comments and child-relids clarification in #29.
- Richard committed both patches from #29: the main planner change as 24225ad9aa, with only blank-line adjustments, and the unique-index helper cleanup unchanged as bf9ee294e5.
- In the push announcement, Richard retained make_sort_from_sortclauses() despite removing its last core caller, because it had been exported for CitusDB and extension compatibility remained uncertain #30.
- After landing, Richard reported another query running about 3.7 times faster #31; Andrei Lepikhov raised concerns that the additional RelOptInfo resembles a regular relation but cannot be found through standard lookup functions #32.
- The thread ended with both patches committed and no further patch submission: Richard considered the unique relation internal to semijoin path generation #33, while Andrei argued that exposed planner types affect extensions and called for broader discussion of their needs #34.