model-writtenrun 3718 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Hans Buschmann reported severe underestimation when joining four CTEs in #1, then corrected the claimed slowdown from roughly 500-fold to 50-fold and supplied fuller queries in #3.
- Tomas Vondra identified missing statistics propagation through materialized CTEs in #2, explained why null-rejecting expressions legitimately converted the left joins to inner joins, and suggested NOT MATERIALIZED in #4; he also supplied reproduction scripts without data in #5.
- After several months, Jian Guo proposed treating CTE columns as unique in #6, then abandoned that unsafe assumption and instead attempted to retrieve underlying column statistics in #8.
- jian he reported compiler warnings and an apparently unexercised recursive path in #11; Tom Lane subsequently explained that the patch confused CTE output columns with underlying relation columns and supplied a substantial rewrite supporting proper target-list lookup and RETURNING in #13.
- Richard Guo approved the rewrite and supplied a regression test demonstrating a better semi-join plan in #14, while Tom Lane confirmed a runtime improvement and noticed that CTE output ordering remained unavailable to the outer planner in #15.
- Tom Lane argued in #17 that a MATERIALIZED optimization fence should prevent the outer query from influencing the CTE's chosen plan while allowing statistics and ordering information to flow outward; David G. Johnston, Laurenz Albe, and Richard Guo endorsed that interpretation in #18, #19, and #20.
- Tom Lane committed the statistics rewrite from #13 as f7816aec23, adding Richard Guo's regression test and simplifying the implementation to use the planned query tree for all checks, as explained in #21.
- Richard Guo started a separate pathkey-propagation patch in #22; Tom Lane's review in #23 led to #24, which saves each CTE's chosen path explicitly and uses the existing plan target list, leaving broader deferred-plan-construction refactoring aside.
- Alexander Lakhin reported in #25 that the statistics commit caused INSERT RETURNING CTE queries to fail with a missing relation-entry error; Tom Lane supplied #26 to tolerate absent RelOptInfos and obtain permission information directly from the RTE.
- Richard Guo endorsed the INSERT RETURNING fix and assessed its reachability in #27, and Tom Lane committed #26 unchanged as 89b69db82a.
- Tom Lane explained in #28 that he withheld backpatching because the failing case appeared unreachable before the statistics enhancement, while leaving open a PostgreSQL 16 backpatch if contrary evidence emerged.
- After the commitfest entry was mistakenly marked complete, Richard Guo clarified in #30 that statistics propagation and its bugfix had landed but pathkey propagation remained under review; he moved that remaining work and its context to a new thread and updated the entry in #32.