{"Entry":{"collection":"guc","key":"enable_nestloop","name":"enable_nestloop","aliases":[],"metadata":{"baseline":true,"boot_human":"Not specified","boot_val":null,"category":"Query Tuning / Planner Method Configuration","category_zh":"","changed_in":[],"changes":[{"documentation_changed":true,"fields":{},"from":"7.4","status":"changed","to":"8.0"},{"documentation_changed":true,"fields":{},"from":"8.4","status":"changed","to":"9.0"}],"content_hash":"2fe2f8411e96b4052548d1a017dd1ca74f51353e65e143dde03f7682a798a967","context":"","default_changed_in":[],"default_history":[{"from":"9.0","to":"19","value":"on"}],"derived_content_hash":"59426e39ffb761446866493b87f0b2f1fe799be3a4480279ac99914c7723b4ba","editorial":{"advice":{"olap":"Benchmark representative analytical plans with and without enable_nestloop. 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 nested-loop joins, including parameterized inner scans that may be best for small outer relations explains a regression, then repair statistics, indexes, estimates, or query shape instead of leaving a cluster-wide method ban.","small":"Do not use enable_nestloop 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_nestloop controls whether the planner may choose nested-loop joins, including parameterized inner scans that may be best for small outer relations.","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.","Turning it off only discourages nested loops because some joins have no other correct implementation. Its user context permits session- or transaction-local changes; newly performed or newly planned work sees the value."],"pitfalls":["Treating enable_nestloop 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.","Turning it off only discourages nested loops because some joins have no other correct implementation."],"references":[{"title":"PostgreSQL 19 Beta 4: enable_nestloop","url":"https://www.postgresql.org/docs/19/runtime-config-query.html#GUC-ENABLE-NESTLOOP"},{"title":"PostgreSQL 19 release notes","url":"https://www.postgresql.org/docs/19/release-19.html"}],"related":["enable_hashjoin","enable_mergejoin","enable_memoize","random_page_cost","work_mem"],"summary":"enable_nestloop — Enables the planner's use of nested-loop join plans. Observed in PG9.0–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":"7.4","group":"Query Tuning","group_slug":"query","imported_at":"2026-09-27T17:57:31.213803+08:00","intro_commit":{},"key":"enable_nestloop","last_version":"20","max_val":"","min_val":"","name":"enable_nestloop","position":127,"present_in":["7.4","8.0","8.1","8.2","8.3","8.4","9.0","9.1","9.2","9.3","9.4","9.5","9.6","10","11","12","13","14","15","16","17","18","19","20"],"repair_provenance":{"original_source_revision":"english-manuals:da7ed6ba377f7aefb3282e2c67b6e7da75b4ac5d30f842975ffabbd920f18b59","receipt_sha256":"320d3f5ece7820ef8fc93f584a7df2aa7f3a6469185f3263da3e7f1e182a5666","repair":"wiki-repair-20261023"},"short_desc":"Enables or disables the query planner's use of nested-loop join plans.","short_desc_zh":"","source_rev":"wiki-repair-20261023:d1c9cc3e96b2674714d41e92995942af357d1f73d06ad4086eb5dac1695d5f33","unit":"","vartype":"bool"}},"Definition":{"Collection":"guc","Key":"enable_nestloop","SourceDatabase":"center","Version":"18","SourceTable":"guc","SourceKey":"enable_nestloop","SourceRevision":"wiki-repair-20261023:d1c9cc3e96b2674714d41e92995942af357d1f73d06ad4086eb5dac1695d5f33","Facts":{"boot_val":"on","category":"Query Tuning / Planner Method Configuration","context":"user","description":"Enables or disables the query planner's use of nested-loop join plans. It is impossible to suppress nested-loop joins entirely, but turning this variable off discourages the planner from using one if there are other methods available. The default is on.","description_zh":"允许或禁止查询规划器使用嵌套循环连接计划。它不可能完全禁止嵌套循环连接，但是关闭这个变量将使得规划器尽可能优先使用其他方法。默认值是 on。","description_zh_html":"\u003cp\u003e\n        允许或禁止查询规划器使用嵌套循环连接计划。它不可能完全禁止嵌套循环连接，但是关闭这个变量将使得规划器尽可能优先使用其他方法。默认值是 \u003ccode class=\"literal\"\u003eon\u003c/code\u003e。\n       \u003c/p\u003e","doc":{"anchor":"GUC-ENABLE-NESTLOOP","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_nestloop","short_desc":"Enables the planner's use of nested-loop join plans.","source":"pg-settings-source-snapshot","translation_provenance":{"inputs":[{"kind":"current-pgdoc-translation","path":"/Users/vonng/pgsty/pgdoc/zh/18/html/runtime-config-query.html","sha256":"38b0ec7d6c52647c7cdf6401bda43777b62b324f1821fef3ee0f0f0ddb388513"}],"kind":"same-version-pgdoc","locale":"zh-Hans","source_revision":"b1b500221dbe5437cfca004d6b04d3f6e422765d","version":"18"},"unit":null,"vartype":"bool","zh_from":"same-version-pgdoc"},"ManualEvidence":{"doc":{"anchor":"GUC-ENABLE-NESTLOOP","file":"runtime-config-query.html","lang":"en","sha256":"33456ca7ef52bf28e93e34b932a411db7a1b95800179add2cf867dc6ec9144bc","slug":"18"}},"MeasuredEvidence":{"metadata_version":"18"}},"Text":{"Collection":"guc","Key":"enable_nestloop","SourceDatabase":"center","Version":"18","Locale":"en","Title":"enable_nestloop","Summary":"Enables or disables the query planner's use of nested-loop join plans. It is impossible to suppress nested-loop joins entirely, but turning this variable off discourages the planner from using one if there are other methods available. The default is on.","BodyHTML":"\u003cp\u003eEnables or disables the query planner\u0026#39;s use of nested-loop join plans. It is impossible to suppress nested-loop joins entirely, but turning this variable off discourages the planner from using one if there are other methods available. The default is on.\u003c/p\u003e","SourceRevision":"wiki-repair-20261023:d1c9cc3e96b2674714d41e92995942af357d1f73d06ad4086eb5dac1695d5f33","ContentHash":"8072af305ae90b9f7f7fa724427e6312f64c4d4c73555346d251ba622b83f54d","Payload":{"description":"Enables or disables the query planner's use of nested-loop join plans. It is impossible to suppress nested-loop joins entirely, but turning this variable off discourages the planner from using one if there are other methods available. The default is on."}},"RequestedLocale":"en","Fallback":false,"Versions":["10","11","12","13","14","15","16","17","18","19","20","7.4","8.0","8.1","8.2","8.3","8.4","9.0","9.1","9.2","9.3","9.4","9.5","9.6"],"Locales":["en","zh-Hans"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
