select open change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

CONFIGURATION / QUERY TUNING

enable_partition_pruning

Read PG 18 manual ↗

Enables or disables the query planner's ability to eliminate a partitioned table's partitions from query plans.

Type
bool
Context
user
Measured default
on
Unit
Metadata snapshot
18

Definition PG 18 manual

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 on. See Section 5.12.4 for details.

Measured default history
Version intervalDefault
11 – 19on
Analysis & operational context

Authored guidance from the GUC source snapshot; the version-specific manual above is the definition reference. View source ↗

How it works

enable_partition_pruning controls whether the planner may choose plan-time and execution-time elimination of partitions contradicted by query predicates.

It is consulted while a plan is built. A session-level change is useful for comparing EXPLAIN alternatives, but an already cached plan is not retroactively rewritten; invalidation or replanning is required to observe a different choice.

The switch changes which candidate paths the planner may cost; it does not make the chosen method faster by itself. Its user context permits session- or transaction-local changes; newly performed or newly planned work sees the value.

Operational considerations

Treating enable_partition_pruning as a query hint even though it affects every plan built in its scope.

Testing an already cached prepared plan and concluding that the setting has no effect.

Masking stale statistics or cardinality errors by disabling a plan method globally.

The switch changes which candidate paths the planner may cost; it does not make the chosen method faster by itself.

Workload guidance

OLAP: Benchmark representative analytical plans with and without enable_partition_pruning. Judge planning time, memory, spill, and execution time together; a win for one report is not evidence for a global setting.

OLTP: Keep the upstream default for routine OLTP. Use a transaction- or session-local change to diagnose whether choosing plan-time and execution-time elimination of partitions contradicted by query predicates explains a regression, then repair statistics, indexes, estimates, or query shape instead of leaving a cluster-wide method ban.

SMALL: Do not use enable_partition_pruning as a permanent hint on a small host. Resource pressure may change the best method, so verify with EXPLAIN (ANALYZE, BUFFERS) and keep the change scoped to the affected workload if it is still needed.

Version history 5
  1. PG 18 → 19changed
  2. PG 16 → 17changed
  3. PG 13 → 14changed
  4. PG 11 → 12changed
  5. PG 10 → 11added

Related entries

Further reading

Definition snapshot: english-manuals:6e1f854b56f0cf4d852ca3e773b… · English manual source