enable_indexonlyscan
Read PG 18 manual ↗Enables or disables the query planner's use of index-only-scan plan types (see Section 11.9).
- Type
- bool
- Context
- user
- Measured default
- on
- Unit
- —
- Metadata snapshot
- 18
Definition PG 18 manual
Enables or disables the query planner's use of index-only-scan plan types (see Section 11.9). The default is on. The enable_indexscan setting must also be enabled to have the query planner consider index-only-scans.
Measured default history
| Version interval | Default |
|---|---|
| 9.2 – 19 | on |
Authored guidance from the GUC source snapshot; the version-specific manual above is the definition reference. View source ↗
How it works
enable_indexonlyscan controls whether the planner may choose index-only scans, which can return index tuples without heap reads when visibility information permits.
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 has no effect unless enable_indexscan is also on, and heap visits still occur for pages not marked all-visible. Its user context permits session- or transaction-local changes; newly performed or newly planned work sees the value.
Operational considerations
Treating enable_indexonlyscan 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 has no effect unless enable_indexscan is also on, and heap visits still occur for pages not marked all-visible.
Workload guidance
OLAP: Benchmark representative analytical plans with and without enable_indexonlyscan. 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 index-only scans, which can return index tuples without heap reads when visibility information permits explains a regression, then repair statistics, indexes, estimates, or query shape instead of leaving a cluster-wide method ban.
SMALL: Do not use enable_indexonlyscan 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 4
- PG 11 → 12changed
- PG 10 → 11changed
- PG 9.5 → 9.6changed
- PG 9.1 → 9.2added
Related entries
Further reading
Definition snapshot: english-manuals:59811833523d6af9ce6c2090335… · English manual source