model-writtenrun 3474 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Richard Guo opened a dedicated thread with #1, proposing to expose materialized CTE ordering to the outer planner using existing subquery pathkey conversion, following the earlier conclusion that information may flow upward across the optimization fence.
- Andrei Lepikhov initially liked the approach in #2, while encouraging further review of corner cases.
- Tom Lane proposed replacing the per-CTE path list with a global per-subplan list alongside plans and planner roots in #3, preserving useful context for future planner work; Richard adopted that storage design in #4.
- Tom committed #4 as a65724dfa7, additionally retaining real paths for ordinary subplans, explaining the remaining dummy initplan entries, and making cosmetic adjustments, as reported in #5.
- In #5, Tom also observed that removing ORDER BY from the CTE prevented propagation despite an ordered index scan, because the inner planner did not record ordering irrelevant to its own query; he left that longstanding behavior unchanged.
- Richard confirmed the same limitation for ordinary subqueries in #6 and argued that letting outer ordering requirements influence materialized CTE planning would violate the optimization fence.
- David Rowley suggested exploring useful outer-ordering context for subqueries in #7; the submitted patch had landed, while that broader planner question remained open.