enable_self_join_elimination
Read PG 18 manual ↗Enables or disables the query planner's optimization which analyses the query tree and replaces self joins with semantically equivalent single scans.
- Type
- bool
- Context
- user
- Measured default
- on
- Unit
- —
- Metadata snapshot
- 18
Definition PG 18 manual
Enables or disables the query planner's optimization which analyses the query tree and replaces self joins with semantically equivalent single scans. Takes into consideration only plain tables. The default is on.
Measured default history
| Version interval | Default |
|---|---|
| 18 – 19 | on |
Authored guidance from the GUC source snapshot; the version-specific manual above is the definition reference. View source ↗
How it works
enable_self_join_elimination controls whether the planner may choose removing provably redundant self-joins on plain tables when uniqueness and predicates preserve semantics.
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 optimization is limited to plain tables and requires proofs that removing the duplicate relation preserves results. Its user context permits session- or transaction-local changes; newly performed or newly planned work sees the value.
Operational considerations
Treating enable_self_join_elimination 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 optimization is limited to plain tables and requires proofs that removing the duplicate relation preserves results.
Workload guidance
OLAP: Self-join elimination can reduce scans and join work in generated analytical SQL. Validate plan shape and result equivalence on representative statements, remembering that the optimization is limited to plain tables and provable uniqueness.
OLTP: Keep the PG18 default on. If a regression is suspected, compare on and off in one session and inspect whether uniqueness proofs and predicates allow a redundant plain-table self-join to be removed; do not disable it cluster-wide to mask bad estimates.
SMALL: Keep on unless a reproducible PG18 planner regression is isolated. The switch does not remove arbitrary self-joins, so query and index design remain necessary when the proof conditions are absent.
Version history 1
- PG 17 → 18added
Related entries
Further reading
Definition snapshot: english-manuals:b16c5641e085e856bd9e221f9e2… · English manual source