pgsql: Propagate pathkeys from CTEs up to the outer query.

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Propagate pathkeys from CTEs up to the outer query.
Дата
Msg-id E1rpAFR-005ndo-P7@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/a65724dfa73db8b451d0c874a9161935a34a914e

Modified Files
--------------
src/backend/optimizer/path/allpaths.c  | 16 ++++++++++++++--
src/backend/optimizer/plan/planner.c   |  1 +
src/backend/optimizer/plan/subselect.c | 28 ++++++++++++++++++----------
src/backend/optimizer/util/pathnode.c  |  5 +++--
src/include/nodes/pathnodes.h          |  3 +++
src/include/optimizer/pathnode.h       |  2 +-
src/test/regress/expected/with.out     | 17 +++++++++++++++++
src/test/regress/sql/with.sql          |  7 +++++++
8 files changed, 64 insertions(+), 15 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: pgsql: C comment: mention no doc for negative start of substring(text)
Следующее
От: Nathan Bossart
Дата:
Сообщение: pgsql: Micro-optimize pg_lfind32().