postgresql/src/include/optimizer
Tom Lane a65724dfa7 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
2024-03-26 13:05:51 -04:00
..
appendinfo.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
clauses.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
cost.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
geqo.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
geqo_copy.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
geqo_gene.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
geqo_misc.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
geqo_mutation.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
geqo_pool.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
geqo_random.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
geqo_recombination.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
geqo_selection.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
inherit.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
joininfo.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
optimizer.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
orclauses.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
paramassign.h Add RETURNING support to MERGE. 2024-03-17 13:58:59 +00:00
pathnode.h Propagate pathkeys from CTEs up to the outer query. 2024-03-26 13:05:51 -04:00
paths.h Do not translate dummy SpecialJoinInfos for child joins 2024-03-25 18:06:47 +09:00
placeholder.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
plancat.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
planmain.h Add better handling of redundant IS [NOT] NULL quals 2024-01-23 18:09:18 +13:00
planner.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
prep.h Allow planner to use Merge Append to efficiently implement UNION 2024-03-25 14:31:14 +13:00
restrictinfo.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
subselect.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
tlist.h Update copyright for 2024 2024-01-03 20:49:05 -05:00