aboutsummaryrefslogtreecommitdiff
path: root/src/backend/optimizer/plan/planner.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2024-03-26 13:05:49 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2024-03-26 13:05:51 -0400
commita65724dfa73db8b451d0c874a9161935a34a914e (patch)
tree04bdd460d3344447dcc29501e733d3dd6e8928aa /src/backend/optimizer/plan/planner.c
parente648e77e25708874196326b6e4da30e7717156ab (diff)
downloadpostgresql-a65724dfa73db8b451d0c874a9161935a34a914e.tar.gz
postgresql-a65724dfa73db8b451d0c874a9161935a34a914e.zip
Propagate pathkeys from CTEs up to the outer query.
If we know the sort order of a CTE's output, and it is relevant to the outer query, label the CTE's outer-query access path using those pathkeys. This may enable optimizations such as avoiding a sort in the outer query. The code for hoisting pathkeys into the outer query already exists for regular RTE_SUBQUERY subqueries, but it wasn't getting used for CTEs, possibly out of concern for maintaining an optimization fence between the CTE and the outer query. However, on the same arguments used for commit f7816aec2, there seems no harm in letting the outer query know what the inner query decided to do. In support of this, we now remember the best Path as well as Plan for each subquery for the rest of the planner run. There may be future applications for having that at hand, and it surely costs little to build one more List. Richard Guo (minor mods by me) Discussion: https://postgr.es/m/CAMbWs49xYd3f8CrE8-WW3--dV1zH_sDSDn-vs2DzHj81Wcnsew@mail.gmail.com
Diffstat (limited to 'src/backend/optimizer/plan/planner.c')
-rw-r--r--src/backend/optimizer/plan/planner.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c
index 6d08cc8cdd5..38d070fa004 100644
--- a/src/backend/optimizer/plan/planner.c
+++ b/src/backend/optimizer/plan/planner.c
@@ -306,6 +306,7 @@ standard_planner(Query *parse, const char *query_string, int cursorOptions,
glob->boundParams = boundParams;
glob->subplans = NIL;
+ glob->subpaths = NIL;
glob->subroots = NIL;
glob->rewindPlanIDs = NULL;
glob->finalrtable = NIL;