model-writtenrun 3470 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- David Rowley proposed replacing UNION planning heuristics with competing paths, including MergeAppend followed by Unique, in #1, while leaving comparable EXCEPT and INTERSECT improvements for future executor work.
- David's revision #2 delayed child SubqueryScan path creation so parent equivalence classes could be built first and added incremental sorting, but still had datatype-coercion limitations and a temporary workaround for add_path() freeing a referenced path.
- Ashutosh Bapat offered an existing path-reference-counting proposal in #3, and David considered wrapper paths or restricting path freeing in #4, but the eventual solution changed where sorting occurred.
- Richard Guo supplied #5 to preserve useful set-operation pathkeys, reuse existing pathkey construction, and move sorting outside subquery planning so competing SubqueryScan paths could safely share their input.
- Andy Fan assessed Richard's sorting design and identified redundant pathkey checks in #6, supplying a separate cleanup for the existing master code.
- David extracted the create_append_path() parameter documentation from #2 into 87027cb55b, then incorporated Richard's design, extended it to partial paths, and fixed sort-group reference handling in #7.
- David committed Andy's standalone cleanup unchanged as 0c444a70f2 and confirmed its acceptance in #8.
- Richard's further review in #13 exposed missed ordered-path opportunities when subquery equivalence classes collapse, unnecessary sorted partial paths without parallel MergeAppend, and inconsistent group-count expressions.
- David addressed the partial-path and group-count comments in #14, but deferred the broader subquery-pathkey problem beyond PostgreSQL 17 because it affected subqueries generally, attaching an incomplete experimental solution separately.
- David landed the main portion of #14 as 66c0185a3d after correcting group-estimation timing, child equivalence-class indexes, and other details, explaining in #15 that the pre-existing top-level varno-zero limitation was not a blocker.
- Alexander Lakhin reported a CTE assertion failure in #17, and Richard diagnosed in #19 that checking the parent's setOperations incorrectly classified a CTE as a UNION child.
- David proposed explicitly passing planning context in #20 and attached a PlannerContext-based fix in #21, which Richard endorsed in #22.
- Tom Lane questioned the structure's name in #23, supported explicit set-operation propagation in #25, and then argued in #26 for a direct function parameter so the compiler would detect callers missing required updates.
- David adopted the direct parameter and added materialized and non-materialized CTE tests in d5d2205c8d, confirming in the final thread message #27 that the CTE fix had landed while Tom's other comments still awaited attention.
- Tom's suggestion in #25 to preserve tuple_fraction for ordered UNION queries subsequently became 3b1a7eb289, allowing consideration of cheap startup paths.
- Tom's separate observation in #25 about the redundant ressortgroupref assignment subsequently became 7487044d6c; the experimental general subquery-pathkey enhancement from #14 remained deferred.