1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-30 11:03:19 +03:00

Add GUC enable_partition_pruning

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
This commit is contained in:
Alvaro Herrera
2018-04-23 17:57:43 -03:00
parent 4df58f7ed7
commit 055fb8d33d
16 changed files with 322 additions and 29 deletions

View File

@ -3826,6 +3826,23 @@ ANY <replaceable class="parameter">num_sync</replaceable> ( <replaceable class="
</listitem>
</varlistentry>
<varlistentry id="guc-enable-partition-pruning" xreflabel="enable_partition_pruning">
<term><varname>enable_partition_pruning</varname> (<type>boolean</type>)
<indexterm>
<primary><varname>enable_partition_pruning</varname> configuration parameter</primary>
</indexterm>
</term>
<listitem>
<para>
Enables or disables the query planner's ability to eliminate a
partitioned table's partitions from query plans. This also controls
the planner's ability to generate query plans which allow the query
executor to remove (ignore) partitions during query execution. The
default is <literal>on</literal>.
</para>
</listitem>
</varlistentry>
<varlistentry id="guc-enable-partitionwise-join" xreflabel="enable_partitionwise_join">
<term><varname>enable_partitionwise_join</varname> (<type>boolean</type>)
<indexterm>
@ -4417,8 +4434,7 @@ ANY <replaceable class="parameter">num_sync</replaceable> ( <replaceable class="
<literal>partition</literal> (examine constraints only for inheritance child
tables and <literal>UNION ALL</literal> subqueries).
<literal>partition</literal> is the default setting.
It is often used with inheritance and partitioned tables to
improve performance.
It is often used with inheritance tables to improve performance.
</para>
<para>
@ -4441,11 +4457,11 @@ SELECT * FROM parent WHERE key = 2400;
<para>
Currently, constraint exclusion is enabled by default
only for cases that are often used to implement table partitioning.
Turning it on for all tables imposes extra planning overhead that is
quite noticeable on simple queries, and most often will yield no
benefit for simple queries. If you have no partitioned tables
you might prefer to turn it off entirely.
only for cases that are often used to implement table partitioning via
inheritance tables. Turning it on for all tables imposes extra
planning overhead that is quite noticeable on simple queries, and most
often will yield no benefit for simple queries. If you have no
inheritance partitioned tables you might prefer to turn it off entirely.
</para>
<para>

View File

@ -3196,7 +3196,7 @@ CREATE INDEX ON measurement (logdate);
<listitem>
<para>
Ensure that the <xref linkend="guc-constraint-exclusion"/>
Ensure that the <xref linkend="guc-enable-partition-pruning"/>
configuration parameter is not disabled in <filename>postgresql.conf</filename>.
If it is, queries will not be optimized as desired.
</para>