pgsql: Speed up planning when partitions can be pruned at plan time.

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Speed up planning when partitions can be pruned at plan time.
Дата
Msg-id E1hAMwH-0003MS-H7@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Speed up planning when partitions can be pruned at plan time.

Previously, the planner created RangeTblEntry and RelOptInfo structs
for every partition of a partitioned table, even though many of them
might later be deemed uninteresting thanks to partition pruning logic.
This incurred significant overhead when there are many partitions.
Arrange to postpone creation of these data structures until after
we've processed the query enough to identify restriction quals for
the partitioned table, and then apply partition pruning before not
after creation of each partition's data structures.  In this way
we need not open the partition relations at all for partitions that
the planner has no real interest in.

For queries that can be proven at plan time to access only a small
number of partitions, this patch improves the practical maximum
number of partitions from under 100 to perhaps a few thousand.

Amit Langote, reviewed at various times by Dilip Kumar, Jesper Pedersen,
Yoshikazu Imai, and David Rowley

Discussion: https://postgr.es/m/9d7c5112-cb99-6a47-d3be-cf1ee6862a1d@lab.ntt.co.jp

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/428b260f87e8861ba8e58807b69d433db491c4f4

Modified Files
--------------
contrib/postgres_fdw/expected/postgres_fdw.out    |  42 +-
src/backend/executor/execPartition.c              |  14 +-
src/backend/optimizer/path/allpaths.c             | 180 +-------
src/backend/optimizer/plan/initsplan.c            |   8 +-
src/backend/optimizer/plan/planner.c              | 492 +++++++++++++--------
src/backend/optimizer/prep/preptlist.c            |   4 +-
src/backend/optimizer/util/inherit.c              | 506 ++++++++++++++++------
src/backend/optimizer/util/plancat.c              |   5 +-
src/backend/optimizer/util/relnode.c              | 134 +++---
src/backend/partitioning/partprune.c              |  45 +-
src/include/nodes/plannodes.h                     |   3 +-
src/include/optimizer/inherit.h                   |   7 +-
src/include/optimizer/pathnode.h                  |   3 +-
src/test/regress/expected/partition_aggregate.out |   4 +-
src/test/regress/expected/partition_prune.out     |  54 +++
src/test/regress/sql/partition_prune.sql          |   7 +
16 files changed, 887 insertions(+), 621 deletions(-)


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

Предыдущее
От: Tomas Vondra
Дата:
Сообщение: pgsql: Fix compiler warnings in multivariate MCV code
Следующее
От: Tomas Vondra
Дата:
Сообщение: pgsql: Fix typo