{"Entry":{"collection":"guc","key":"enable_indexonlyscan","name":"enable_indexonlyscan","aliases":[],"metadata":{"baseline":false,"boot_human":"Not specified","boot_val":null,"category":"Query Tuning / Planner Method Configuration","category_zh":"","changed_in":[],"changes":[{"documentation_changed":false,"fields":{},"from":"9.1","status":"added","to":"9.2"},{"documentation_changed":true,"fields":{},"from":"9.5","status":"changed","to":"9.6"},{"documentation_changed":true,"fields":{},"from":"10","status":"changed","to":"11"},{"documentation_changed":true,"fields":{},"from":"11","status":"changed","to":"12"}],"content_hash":"e6b828b1cc74cdea07a20b8a7c65caf337166c8bb85980c672631ff8522fa2ed","context":"","default_changed_in":[],"default_history":[{"from":"9.2","to":"19","value":"on"}],"editorial":{"advice":{"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."},"mechanism":["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."],"pitfalls":["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."],"references":[{"title":"PostgreSQL 19 Beta 4: enable_indexonlyscan","url":"https://www.postgresql.org/docs/19/runtime-config-query.html#GUC-ENABLE-INDEXONLYSCAN"},{"title":"PostgreSQL 19 release notes","url":"https://www.postgresql.org/docs/19/release-19.html"}],"related":["enable_indexscan","enable_bitmapscan","enable_seqscan","random_page_cost","track_counts"],"summary":"enable_indexonlyscan — Enables the planner's use of index-only-scan plans. Observed in PG9.2–19 Beta 4; its last measured boot default is on in PG19 Beta 4, with user context. This is a beta-snapshot fact and can change before PostgreSQL 19 GA."},"enumvals":[],"first_version":"9.2","group":"Query Tuning","group_slug":"query","imported_at":"2026-09-27T17:57:31.19699+08:00","intro_commit":{"authored_at":"2011-10-07T20:13:02-04:00","discussion":[],"hash":"a2822fb9337a21f98ac4ce850bb4145acf47ca27","subject":"Support index-only scans using the visibility map to avoid heap fetches.","url":"https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=a2822fb9337a21f98ac4ce850bb4145acf47ca27"},"key":"enable_indexonlyscan","last_version":"20","max_val":"","min_val":"","name":"enable_indexonlyscan","position":122,"present_in":["9.2","9.3","9.4","9.5","9.6","10","11","12","13","14","15","16","17","18","19","20"],"short_desc":"Enables or disables the query planner's use of index-only-scan plan types (see Section 11.9).","short_desc_zh":"","source_rev":"english-manuals:4fe520fea426c8124c9c83a4918369c82e5e2eaad910e77b8d71d0f25a5cc68f","unit":"","vartype":"bool"}},"Definition":{"Collection":"guc","Key":"enable_indexonlyscan","SourceDatabase":"center","Version":"18","SourceTable":"guc","SourceKey":"enable_indexonlyscan","SourceRevision":"english-manuals:4fe520fea426c8124c9c83a4918369c82e5e2eaad910e77b8d71d0f25a5cc68f","Facts":{"boot_val":"on","category":"Query Tuning / Planner Method Configuration","context":"user","description":"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.","doc":{"anchor":"GUC-ENABLE-INDEXONLYSCAN","file":"runtime-config-query.html","lang":"en","sha256":"33456ca7ef52bf28e93e34b932a411db7a1b95800179add2cf867dc6ec9144bc","slug":"18"},"documented":true,"enumvals":null,"extra_desc":null,"lang":"en","max_val":null,"metadata_version":"18","min_val":null,"name":"enable_indexonlyscan","short_desc":"Enables the planner's use of index-only-scan plans.","source":"pg-settings-source-snapshot","unit":null,"vartype":"bool"},"ManualEvidence":{"doc":{"anchor":"GUC-ENABLE-INDEXONLYSCAN","file":"runtime-config-query.html","lang":"en","sha256":"33456ca7ef52bf28e93e34b932a411db7a1b95800179add2cf867dc6ec9144bc","slug":"18"}},"MeasuredEvidence":{"metadata_version":"18"}},"Text":{"Collection":"guc","Key":"enable_indexonlyscan","SourceDatabase":"pgweb","Version":"18","Locale":"zh-Hans","Title":"enable_indexonlyscan","Summary":"","BodyHTML":"\u003cp\u003e启用或禁用查询规划器对仅索引扫描计划类型的使用（参见\u003ca href=\"/docs/18/indexes-index-only-scans.html\" rel=\"nofollow\"\u003e第 11.9 节\u003c/a\u003e）。默认值为 \u003ccode\u003eon\u003c/code\u003e。还必须启用\u003ca href=\"/docs/18/runtime-config-query.html#GUC-ENABLE-INDEXSCAN\" rel=\"nofollow\"\u003eenable_indexscan\u003c/a\u003e，查询规划器才会考虑仅索引扫描。\u003c/p\u003e","SourceRevision":"2026-09-11@29c86d9","ContentHash":"600208225e9c0a1aadacf6bc19b491a3f2c826366aef3554e8eeed768e46453e","Payload":{"carried_from":"","carry_reason":"","doc_html":"\u003cp\u003e启用或禁用查询规划器对仅索引扫描计划类型的使用（参见\u003ca href=\"/docs/18/indexes-index-only-scans.html\" title=\"11.9. 仅索引扫描和覆盖索引\"\u003e第 11.9 节\u003c/a\u003e）。默认值为 \u003ccode class=\"literal\"\u003eon\u003c/code\u003e。还必须启用\u003ca href=\"/docs/18/runtime-config-query.html#GUC-ENABLE-INDEXSCAN\"\u003eenable_indexscan\u003c/a\u003e，查询规划器才会考虑仅索引扫描。\u003c/p\u003e","doc_same_as":""}},"RequestedLocale":"zh-Hans","Fallback":false,"Versions":["10","11","12","13","14","15","16","17","18","19","20","9.2","9.3","9.4","9.5","9.6"],"Locales":["en","zh-Hans"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
