{"Entry":{"collection":"guc","key":"from_collapse_limit","name":"from_collapse_limit","aliases":[],"metadata":{"baseline":true,"boot_human":"Not specified","boot_val":null,"category":"Query Tuning / Other Planner Options","category_zh":"","changed_in":[],"changes":[{"documentation_changed":true,"fields":{},"from":"8.1","status":"changed","to":"8.2"},{"documentation_changed":true,"fields":{},"from":"8.2","status":"changed","to":"8.3"},{"documentation_changed":true,"fields":{},"from":"8.3","status":"changed","to":"8.4"},{"documentation_changed":true,"fields":{},"from":"8.4","status":"changed","to":"9.0"},{"documentation_changed":true,"fields":{},"from":"9.0","status":"changed","to":"9.1"},{"documentation_changed":true,"fields":{},"from":"9.5","status":"changed","to":"9.6"},{"documentation_changed":true,"fields":{},"from":"13","status":"changed","to":"14"},{"documentation_changed":true,"fields":{},"from":"16","status":"changed","to":"17"}],"content_hash":"d1721a8364d77b15a5284d6ead9ae94ba10a45ab454e761df8f395d211b882f1","context":"","default_changed_in":[],"default_history":[{"from":"9.0","to":"19","value":"8"}],"editorial":{"advice":{"olap":"Analytical SQL can make from_collapse_limit more visible because joins, cursors, or recursion are larger. Benchmark the full statement family and inspect estimates rather than copying a single successful value.","oltp":"Keep from_collapse_limit at its upstream default unless representative plans show a repeatable, workload-wide problem. Test a local override first and include planning latency as well as execution latency.","small":"On a small host, avoid increasing planning search or memory pressure through from_collapse_limit without a measured benefit. Prefer query-local structure or a scoped role setting over a cluster-wide override."},"mechanism":["from_collapse_limit bounds how far the planner merges eligible subqueries into the parent FROM list. Flattening exposes more join orders and predicate movement opportunities but enlarges the search space.","If flattening would produce more FROM items than the limit, the subquery boundary is retained. Smaller values can reduce planning time while hiding a better global join order.","The resulting relation count interacts with join_collapse_limit and geqo_threshold; raising this limit can unexpectedly move the query from exhaustive planning into GEQO. Its user context permits session- or transaction-local changes; newly performed or newly planned work sees the value."],"pitfalls":["Treating from_collapse_limit as an executor resource limit rather than a planning assumption or policy.","Testing only one parameter set or one data distribution.","Expecting an already cached plan to be rewritten automatically.","Using a global override to hide stale statistics or fragile SQL structure."],"references":[{"title":"PostgreSQL 19 Beta 4: from_collapse_limit","url":"https://www.postgresql.org/docs/19/runtime-config-query.html#GUC-FROM-COLLAPSE-LIMIT"},{"title":"PostgreSQL 19 release notes","url":"https://www.postgresql.org/docs/19/release-19.html"}],"related":["join_collapse_limit","geqo_threshold","geqo","plan_cache_mode"],"summary":"from_collapse_limit — Sets the FROM-list size beyond which subqueries are not collapsed. Observed in PG9.0–19 Beta 4; its last measured boot default is 8 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.28771+08:00","intro_commit":{},"key":"from_collapse_limit","last_version":"20","max_val":"","min_val":"","name":"from_collapse_limit","position":150,"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"],"short_desc":"The planner will merge sub-queries into upper queries if the resulting FROM list would have no more than this many items.","short_desc_zh":"","source_rev":"english-manuals:1a9394a73352a9c1bf9278991ada350eb3e6af4d01edfac0b2656989225f2bea","unit":"","vartype":"integer"}},"Definition":{"Collection":"guc","Key":"from_collapse_limit","SourceDatabase":"center","Version":"18","SourceTable":"guc","SourceKey":"from_collapse_limit","SourceRevision":"english-manuals:1a9394a73352a9c1bf9278991ada350eb3e6af4d01edfac0b2656989225f2bea","Facts":{"boot_val":"8","category":"Query Tuning / Other Planner Options","context":"user","description":"The planner will merge sub-queries into upper queries if the resulting FROM list would have no more than this many items. Smaller values reduce planning time but might yield inferior query plans. The default is eight. For more information see Section 14.3. Setting this value to geqo_threshold or more may trigger use of the GEQO planner, resulting in non-optimal plans. See Section 19.7.3.","doc":{"anchor":"GUC-FROM-COLLAPSE-LIMIT","file":"runtime-config-query.html","lang":"en","sha256":"33456ca7ef52bf28e93e34b932a411db7a1b95800179add2cf867dc6ec9144bc","slug":"18"},"documented":true,"enumvals":null,"extra_desc":"The planner will merge subqueries into upper queries if the resulting FROM list would have no more than this many items.","lang":"en","max_val":"2147483647","metadata_version":"18","min_val":"1","name":"from_collapse_limit","short_desc":"Sets the FROM-list size beyond which subqueries are not collapsed.","source":"pg-settings-source-snapshot","unit":null,"vartype":"integer"},"ManualEvidence":{"doc":{"anchor":"GUC-FROM-COLLAPSE-LIMIT","file":"runtime-config-query.html","lang":"en","sha256":"33456ca7ef52bf28e93e34b932a411db7a1b95800179add2cf867dc6ec9144bc","slug":"18"}},"MeasuredEvidence":{"metadata_version":"18"}},"Text":{"Collection":"guc","Key":"from_collapse_limit","SourceDatabase":"pgweb","Version":"18","Locale":"zh-Hans","Title":"from_collapse_limit","Summary":"","BodyHTML":"\u003cp\u003e如果生成的\u003ccode\u003eFROM\u003c/code\u003e列表不超过这么多项，规划器将把子查询融合到上层查询。较小的值可以减少规划时间，但是可能会生成较差的查询计划。默认值是 8。详见\u003ca href=\"/docs/18/explicit-joins.html\" rel=\"nofollow\"\u003e第 14.3 节\u003c/a\u003e。\u003c/p\u003e\u003cp\u003e将这个值设置为\u003ca href=\"/docs/18/runtime-config-query.html#GUC-GEQO-THRESHOLD\" rel=\"nofollow\"\u003egeqo_threshold\u003c/a\u003e或更大，可能触发使用 GEQO 规划器，从而产生非最优计划。见\u003ca href=\"/docs/18/runtime-config-query.html#RUNTIME-CONFIG-QUERY-GEQO\" rel=\"nofollow\"\u003e第 19.7.3 节\u003c/a\u003e。\u003c/p\u003e","SourceRevision":"2026-09-11@29c86d9","ContentHash":"3b42fc0607f181fe252c9ea82ba091e1eeae7ebaf6d527a1be08a17f61cad52d","Payload":{"carried_from":"","carry_reason":"","doc_html":"\u003cp\u003e如果生成的\u003ccode class=\"literal\"\u003eFROM\u003c/code\u003e列表不超过这么多项，规划器将把子查询融合到上层查询。较小的值可以减少规划时间，但是可能会生成较差的查询计划。默认值是 8。详见\u003ca href=\"/docs/18/explicit-joins.html\" title=\"14.3. 用显式JOIN子句控制规划器\"\u003e第 14.3 节\u003c/a\u003e。\u003c/p\u003e\u003cp\u003e将这个值设置为\u003ca href=\"/docs/18/runtime-config-query.html#GUC-GEQO-THRESHOLD\"\u003egeqo_threshold\u003c/a\u003e或更大，可能触发使用 GEQO 规划器，从而产生非最优计划。见\u003ca href=\"/docs/18/runtime-config-query.html#RUNTIME-CONFIG-QUERY-GEQO\" title=\"19.7.3. 遗传查询优化器\"\u003e第 19.7.3 节\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","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}
