{"Entry":{"collection":"guc","key":"recursive_worktable_factor","name":"recursive_worktable_factor","aliases":[],"metadata":{"baseline":false,"boot_human":"Not specified","boot_val":null,"category":"Query Tuning / Other Planner Options","category_zh":"","changed_in":[],"changes":[{"documentation_changed":false,"fields":{},"from":"14","status":"added","to":"15"}],"content_hash":"2cc7d856e0478a74f12908b2ab60fe7653147e5891cdd9662d9b26d181a07de4","context":"","default_changed_in":[],"default_history":[{"from":"15","to":"19","value":"10"}],"editorial":{"advice":{"olap":"Analytical SQL can make recursive_worktable_factor 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 recursive_worktable_factor 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 recursive_worktable_factor without a measured benefit. Prefer query-local structure or a scoped role setting over a cluster-wide override."},"mechanism":["recursive_worktable_factor estimates the average recursive working-table size as a multiple of the non-recursive seed term. The estimate feeds costs for joining the worktable to other relations.","It does not cap recursion, memory, rows, or iterations. A low-fan-out traversal can be modeled with a smaller value, while graph expansion with high fan-out may need a larger estimate.","The value is used during planning; actual recursive growth still depends on data and termination predicates. Misestimation can select an unsuitable join method inside the recursive term. Its user context permits session- or transaction-local changes; newly performed or newly planned work sees the value."],"pitfalls":["Treating recursive_worktable_factor 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: recursive_worktable_factor","url":"https://www.postgresql.org/docs/19/runtime-config-query.html#GUC-RECURSIVE-WORKTABLE-FACTOR"},{"title":"PostgreSQL 19 release notes","url":"https://www.postgresql.org/docs/19/release-19.html"}],"related":["work_mem","enable_nestloop","enable_hashjoin","default_statistics_target"],"summary":"recursive_worktable_factor — Sets the planner's estimate of the average size of a recursive query's working table. Observed in PG15–19 Beta 4; its last measured boot default is 10 in PG19 Beta 4, with user context. This is a beta-snapshot fact and can change before PostgreSQL 19 GA."},"enumvals":[],"first_version":"15","group":"Query Tuning","group_slug":"query","imported_at":"2026-09-27T17:57:31.893133+08:00","intro_commit":{"authored_at":"2022-03-24T11:47:41-04:00","discussion":["https://postgr.es/m/CANbhV-EuaLm4H3g0+BSTYHEGxJj3Kht0R+rJ8vT57Dejnh=_nA@mail.gmail.com"],"hash":"0bd7af082ace135581bb13a6bd2d88e68c66a3e0","subject":"Invent recursive_worktable_factor GUC to replace hard-wired constant.","url":"https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=0bd7af082ace135581bb13a6bd2d88e68c66a3e0"},"key":"recursive_worktable_factor","last_version":"20","max_val":"","min_val":"","name":"recursive_worktable_factor","position":333,"present_in":["15","16","17","18","19","20"],"short_desc":"Sets the planner's estimate of the average size of the working table of a recursive query, as a multiple of the estimated size of the initial non-recursive term of the query.","short_desc_zh":"","source_rev":"english-manuals:e7223951a65351407719f7050c51e33d4558bc2a25302db15584895f596dac63","unit":"","vartype":"real"}},"Definition":{"Collection":"guc","Key":"recursive_worktable_factor","SourceDatabase":"center","Version":"18","SourceTable":"guc","SourceKey":"recursive_worktable_factor","SourceRevision":"english-manuals:e7223951a65351407719f7050c51e33d4558bc2a25302db15584895f596dac63","Facts":{"boot_val":"10","category":"Query Tuning / Other Planner Options","context":"user","description":"Sets the planner's estimate of the average size of the working table of a recursive query, as a multiple of the estimated size of the initial non-recursive term of the query. This helps the planner choose the most appropriate method for joining the working table to the query's other tables. The default value is 10.0. A smaller value such as 1.0 can be helpful when the recursion has low “fan-out” from one step to the next, as for example in shortest-path queries. Graph analytics queries may benefit from larger-than-default values.","doc":{"anchor":"GUC-RECURSIVE-WORKTABLE-FACTOR","file":"runtime-config-query.html","lang":"en","sha256":"33456ca7ef52bf28e93e34b932a411db7a1b95800179add2cf867dc6ec9144bc","slug":"18"},"documented":true,"enumvals":null,"extra_desc":null,"lang":"en","max_val":"1e+06","metadata_version":"18","min_val":"0.001","name":"recursive_worktable_factor","short_desc":"Sets the planner's estimate of the average size of a recursive query's working table.","source":"pg-settings-source-snapshot","unit":null,"vartype":"real"},"ManualEvidence":{"doc":{"anchor":"GUC-RECURSIVE-WORKTABLE-FACTOR","file":"runtime-config-query.html","lang":"en","sha256":"33456ca7ef52bf28e93e34b932a411db7a1b95800179add2cf867dc6ec9144bc","slug":"18"}},"MeasuredEvidence":{"metadata_version":"18"}},"Text":{"Collection":"guc","Key":"recursive_worktable_factor","SourceDatabase":"pgweb","Version":"18","Locale":"zh-Hans","Title":"recursive_worktable_factor","Summary":"","BodyHTML":"\u003cp\u003e设置规划器对\u003ca href=\"/docs/18/queries-with.html#QUERIES-WITH-RECURSIVE\" rel=\"nofollow\"\u003e递归查询\u003c/a\u003e的工作表的平均大小的估计值，作为查询初始非递归项的估计大小的倍数。这有助于规划器选择将工作表与查询的其他表连接的最合适方法。默认值为\u003ccode\u003e10.0\u003c/code\u003e。当递归从一步到下一步的\u003cspan\u003e“\u003cspan\u003e扇出\u003c/span\u003e”\u003c/span\u003e较低时，例如最短路径查询，使用较小的值（如\u003ccode\u003e1.0\u003c/code\u003e）可能有所帮助。图分析查询可能会从大于默认值的设置中受益。\u003c/p\u003e","SourceRevision":"2026-09-11@29c86d9","ContentHash":"015fd3301ebbf2156cea72c6c42e8c317ff9abdc2138a044f03506ad78f78390","Payload":{"carried_from":"","carry_reason":"","doc_html":"\u003cp\u003e设置规划器对\u003ca href=\"/docs/18/queries-with.html#QUERIES-WITH-RECURSIVE\" title=\"7.8.2. 递归查询\"\u003e递归查询\u003c/a\u003e的工作表的平均大小的估计值，作为查询初始非递归项的估计大小的倍数。这有助于规划器选择将工作表与查询的其他表连接的最合适方法。默认值为\u003ccode class=\"literal\"\u003e10.0\u003c/code\u003e。当递归从一步到下一步的\u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003e扇出\u003c/span\u003e”\u003c/span\u003e较低时，例如最短路径查询，使用较小的值（如\u003ccode class=\"literal\"\u003e1.0\u003c/code\u003e）可能有所帮助。图分析查询可能会从大于默认值的设置中受益。\u003c/p\u003e","doc_same_as":""}},"RequestedLocale":"zh-Hans","Fallback":false,"Versions":["15","16","17","18","19","20"],"Locales":["en","zh-Hans"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
