Add GUC enable_partition_pruning

Enterprise / PostgreSQL - Alvaro Herrera [alvh.no-ip.org] - 23 April 2018 20:57 EDT

This controls both plan-time and execution-time new-style partition pruning. While finer-grain control is possible (maybe using an enum GUC instead of boolean), there doesn't seem to be much need for that.

This new parameter controls partition pruning for all queries: trivially, SELECT queries that affect partitioned tables are naturally under its control since they are using the new technology. However, while UPDATE/DELETE queries do not use the new code, we make the new GUC control their behavior also (stealing control from constraint_exclusion), because it is more natural, and it leads to a more natural transition to the future in which those queries will also use the new pruning code.

Constraint exclusion still controls pruning for regular inheritance situations (those not involving partitioned tables).

Author: David Rowley Review: Amit Langote, Ashutosh Bapat, Justin Pryzby, David G. Johnston Discussion: https://postgr.es/m/CAKJS1f_0HwsxJG9m+nzU+CizxSdGtfe6iF_ykPYBiYft302DCw@mail.gmail.com

055fb8d33d Add GUC enable_partition_pruning
doc/src/sgml/config.sgml | 30 +++--
doc/src/sgml/ddl.sgml | 2 +-
src/backend/nodes/outfuncs.c | 2 +-
src/backend/optimizer/path/allpaths.c | 3 +-
src/backend/optimizer/path/costsize.c | 1 +
src/backend/optimizer/plan/createplan.c | 7 +-
src/backend/optimizer/plan/planner.c | 11 +-
src/backend/optimizer/prep/prepjointree.c | 2 +-
src/backend/optimizer/util/plancat.c | 45 +++++--
src/backend/utils/misc/guc.c | 11 ++
src/backend/utils/misc/postgresql.conf.sample | 1 +
src/include/nodes/relation.h | 16 ++-
src/include/optimizer/cost.h | 1 +
src/test/regress/expected/partition_prune.out | 164 ++++++++++++++++++++++++++
src/test/regress/expected/sysviews.out | 3 +-
src/test/regress/sql/partition_prune.sql | 52 ++++++++
16 files changed, 322 insertions(+), 29 deletions(-)

Upstream: git.postgresql.org


  • Share