select open change scope Open full search

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

CONFIGURATION / QUERY TUNING

enable_partitionwise_join

Read PG 18 manual ↗

Enables or disables the query planner's use of partitionwise join, which allows a join between partitioned tables to be performed by joining the matching partitions.

Type
bool
Context
user
Measured default
off
Unit
Metadata snapshot
18

Definition PG 18 manual

Enables or disables the query planner's use of partitionwise join, which allows a join between partitioned tables to be performed by joining the matching partitions. Partitionwise join currently applies only when the join conditions include all the partition keys, which must be of the same data type and have one-to-one matching sets of child partitions. With this setting enabled, the number of nodes whose memory usage is restricted by work_mem appearing in the final plan can increase linearly according to the number of partitions being scanned. This can result in a large increase in overall memory consumption during the execution of the query. Query planning also becomes significantly more expensive in terms of memory and CPU. The default value is off.

Measured default history
Version intervalDefault
11 – 19off
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_partitionwise_join controls whether the planner may choose joining one-to-one matching partitions when join keys contain compatible partition keys.

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.

It can multiply work_mem-limited nodes and planning effort roughly with the number of participating partitions. Its user context permits session- or transaction-local changes; newly performed or newly planned work sees the value.

Operational considerations

Treating enable_partitionwise_join 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.

It can multiply work_mem-limited nodes and planning effort roughly with the number of participating partitions.

Workload guidance

OLAP: Compare planning memory, planning time, total execution memory, and partition count—not execution time alone.

OLTP: Keep the upstream default off for routine OLTP. Test on at session scope only when both sides have one-to-one compatible partition layouts and the join includes every partition key; budget planning CPU and the work_mem-limited nodes created per partition.

SMALL: Leave off unless a specific partition-aligned join repeatedly benefits. Many partitions can make planning and per-node memory disproportionate on a small host even when each local join is efficient.

Version history 3
  1. PG 12 → 13changed
  2. PG 11 → 12changed
  3. PG 10 → 11added

Related entries

Further reading

Definition snapshot: english-manuals:d9a187f1685f53251b7c9b680d0… · English manual source