postgresql/src/backend
Tom Lane e03ff73969 Clean up handling of constraint_exclusion and enable_partition_pruning.
The interaction of these parameters was a bit confused/confusing,
and in fact v11 entirely misses the opportunity to apply partition
constraints when a partition is accessed directly (rather than
indirectly from its parent).

In HEAD, establish the principle that enable_partition_pruning controls
partition pruning and nothing else.  When accessing a partition via its
parent, we do partition pruning (if enabled by enable_partition_pruning)
and then there is no need to consider partition constraints in the
constraint_exclusion logic.  When accessing a partition directly, its
partition constraints are applied by the constraint_exclusion logic,
only if constraint_exclusion = on.

In v11, we can't have such a clean division of these GUCs' effects,
partly because we don't want to break compatibility too much in a
released branch, and partly because the clean coding requires
inheritance_planner to have applied partition pruning to a partitioned
target table, which it doesn't in v11.  However, we can tweak things
enough to cover the missed case, which seems like a good idea since
it's potentially a performance regression from v10.  This patch keeps
v11's previous behavior in which enable_partition_pruning overrides
constraint_exclusion for an inherited target table, though.

In HEAD, also teach relation_excluded_by_constraints that it's okay to use
inheritable constraints when trying to prune a traditional inheritance
tree.  This might not be thought worthy of effort given that that feature
is semi-deprecated now, but we have enough infrastructure that it only
takes a couple more lines of code to do it correctly.

Amit Langote and Tom Lane

Discussion: https://postgr.es/m/9813f079-f16b-61c8-9ab7-4363cab28d80@lab.ntt.co.jp
Discussion: https://postgr.es/m/29069.1555970894@sss.pgh.pa.us
2019-04-30 15:03:50 -04:00
..
access Message style fixes 2019-04-30 10:33:37 -04:00
bootstrap Fix tablespace inheritance for partitioned rels 2019-04-25 10:31:32 -04:00
catalog Fix potential assertion failure when reindexing a pg_class index. 2019-04-29 19:42:08 -07:00
commands Message style fixes 2019-04-30 10:33:37 -04:00
executor Fix slot type issue for fuzzy distance index scan over out-of-core table AM. 2019-04-19 11:42:37 -07:00
foreign Update copyright for 2019 2019-01-02 12:44:25 -05:00
jit Fix collection of typos and grammar mistakes in docs and comments 2019-04-19 16:57:40 +09:00
lib Fix example in comment. 2019-04-09 08:33:42 +03:00
libpq Clean up minor warnings from buildfarm. 2019-04-28 12:45:55 -04:00
main Replace @postgresql.org with @lists.postgresql.org for mailinglists 2019-01-19 19:06:35 +01:00
nodes Fix tablespace inheritance for partitioned rels 2019-04-25 10:31:32 -04:00
optimizer Clean up handling of constraint_exclusion and enable_partition_pruning. 2019-04-30 15:03:50 -04:00
parser Fix tablespace inheritance for partitioned rels 2019-04-25 10:31:32 -04:00
partitioning Fix failure with textual partition hash keys. 2019-04-15 16:47:09 -04:00
po Translation updates 2018-06-25 12:37:18 +02:00
port Consistently test for in-use shared memory. 2019-04-12 22:36:38 -07:00
postmaster Use preprocessor conditions compatible with Emacs indent. 2019-04-28 12:56:53 -07:00
regex Collations with nondeterministic comparison 2019-03-22 12:12:43 +01:00
replication In walreceiver, don't try to do ereport() in a signal handler. 2019-04-29 12:26:07 -04:00
rewrite Perform RLS subquery checks as the right user when going via a view. 2019-04-02 08:13:59 +01:00
snowball Update copyright for 2019 2019-01-02 12:44:25 -05:00
statistics Fix mvdistinct and dependencies size calculations 2019-04-21 20:23:34 +02:00
storage Fix function names in comments. 2019-04-25 23:43:48 +09:00
tcop Fix potential catalog corruption with temporary identity columns 2019-04-29 08:49:03 +02:00
tsearch Fix more strcmp() calls using boolean-like comparisons for result checks 2019-04-12 10:16:49 +09:00
utils Message style fixes 2019-04-30 10:33:37 -04:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
Makefile Get rid of jsonpath_gram.h and jsonpath_scanner.h 2019-03-20 11:13:34 +03:00
common.mk Remove PARTIAL_LINKING build mode. 2018-03-30 17:33:04 -07:00
nls.mk Translation updates 2018-06-25 12:37:18 +02:00