{"Entry":{"collection":"guc","key":"geqo_threshold","name":"geqo_threshold","aliases":[],"metadata":{"baseline":true,"boot_human":"Not specified","boot_val":null,"category":"Query Tuning / Genetic Query Optimizer","category_zh":"","changed_in":[],"changes":[{"documentation_changed":true,"fields":{},"from":"7.4","status":"changed","to":"8.0"},{"documentation_changed":true,"fields":{},"from":"8.1","status":"changed","to":"8.2"},{"documentation_changed":true,"fields":{},"from":"8.4","status":"changed","to":"9.0"}],"content_hash":"bc5485f661af4373841855a8f0c561438dd84818b5a280c550906e7630a8662d","context":"","default_changed_in":[],"default_history":[{"from":"9.0","to":"19","value":"12"}],"derived_content_hash":"67bc78cb8fbfa722ad8223f878346b8ef825fb65cae1eb7962598146ee207892","editorial":{"advice":{"olap":"For recurring many-table reports, test geqo_threshold with multiple geqo_seed values and compare planning plus execution time. A single lucky seed is not a stable production policy.","oltp":"Keep geqo_threshold at its upstream default unless planning time for many-way joins is measured as a problem. Prefer simplifying generated SQL or fixing join estimates before expanding a randomized search budget globally.","small":"Avoid increasing geqo_threshold in ways that consume disproportionate planning CPU on a small host. The default adaptive values are safer than copying a large-system GEQO budget."},"mechanism":["It counts FROM items and switches eligible join problems to GEQO at or above the threshold; a FULL OUTER JOIN construct counts as one item.","GEQO trades bounded planning time for a heuristic search that can miss the best join order. It still costs scan and join paths with the ordinary planner cost model after constructing candidates.","The setting is read during planning, and GEQO's randomized search means plan quality can vary with seed and search budget. Collapse limits can change the number of relations exposed to the join search and therefore whether the threshold is crossed. Its user context permits session- or transaction-local changes; newly performed or newly planned work sees the value."],"pitfalls":["Judging plan quality from one randomized GEQO run.","Changing a GEQO knob without accounting for geqo_threshold and collapse limits.","Spending much more planning CPU for a marginal or unstable execution-time gain.","Assuming GEQO guarantees the globally best join order."],"references":[{"title":"PostgreSQL 19 Beta 4: geqo_threshold","url":"https://www.postgresql.org/docs/19/runtime-config-query.html#GUC-GEQO-THRESHOLD"},{"title":"PostgreSQL 19 release notes","url":"https://www.postgresql.org/docs/19/release-19.html"}],"related":["geqo","geqo_effort","join_collapse_limit","from_collapse_limit","geqo_seed"],"summary":"geqo_threshold — Sets the threshold of FROM items beyond which GEQO is used. Observed in PG9.0–19 Beta 4; its last measured boot default is 12 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.32968+08:00","intro_commit":{},"key":"geqo_threshold","last_version":"20","max_val":"","min_val":"","name":"geqo_threshold","position":159,"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:5acb90a6e7888c81d644fb17938537b9f7b77409440da689d78745a7042fcd72","receipt_sha256":"e983e7db8096d56aa9204d5e47f19cd6d9f02c212ee1c0823cef02b94b0741f4","repair":"wiki-repair-20261023"},"short_desc":"Use genetic query optimization to plan queries with at least this many FROM items involved.","short_desc_zh":"","source_rev":"wiki-repair-20261023:95723f645555a4df07648f7bcc99c06d2a33a84aa83a81ef403036344191acd3","unit":"","vartype":"integer"}},"Definition":{"Collection":"guc","Key":"geqo_threshold","SourceDatabase":"center","Version":"18","SourceTable":"guc","SourceKey":"geqo_threshold","SourceRevision":"wiki-repair-20261023:95723f645555a4df07648f7bcc99c06d2a33a84aa83a81ef403036344191acd3","Facts":{"boot_val":"12","category":"Query Tuning / Genetic Query Optimizer","context":"user","description":"Use genetic query optimization to plan queries with at least this many FROM items involved. (Note that a FULL OUTER JOIN construct counts as only one FROM item.) The default is 12. For simpler queries it is usually best to use the regular, exhaustive-search planner, but for queries with many tables the exhaustive search takes too long, often longer than the penalty of executing a suboptimal plan. Thus, a threshold on the size of the query is a convenient way to manage use of GEQO.","description_zh":"对涉及至少这么多个 FROM 项的查询，使用遗传查询优化来生成计划。（注意，一个 FULL OUTER JOIN 结构只计为一个 FROM 项。）默认值是 12。对于更简单的查询，通常最好使用常规的穷举搜索规划器；但对于涉及很多表的查询，穷举搜索花费的时间太长，往往超过执行次优计划所增加的耗时。因此，以查询规模为阈值，可以方便地控制 GEQO 的使用。","description_zh_html":"\u003cp\u003e对涉及至少这么多个 \u003ccode class=\"literal\"\u003eFROM\u003c/code\u003e 项的查询，使用遗传查询优化来生成计划。（注意，一个 \u003ccode class=\"literal\"\u003eFULL OUTER JOIN\u003c/code\u003e 结构只计为一个 \u003ccode class=\"literal\"\u003eFROM\u003c/code\u003e 项。）默认值是 12。对于更简单的查询，通常最好使用常规的穷举搜索规划器；但对于涉及很多表的查询，穷举搜索花费的时间太长，往往超过执行次优计划所增加的耗时。因此，以查询规模为阈值，可以方便地控制 GEQO 的使用。\u003c/p\u003e","doc":{"anchor":"GUC-GEQO-THRESHOLD","file":"runtime-config-query.html","lang":"en","sha256":"33456ca7ef52bf28e93e34b932a411db7a1b95800179add2cf867dc6ec9144bc","slug":"18"},"documented":true,"enumvals":null,"extra_desc":null,"lang":"en","max_val":"2147483647","metadata_version":"18","min_val":"2","name":"geqo_threshold","short_desc":"Sets the threshold of FROM items beyond which GEQO is used.","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":"integer","zh_from":"same-version-pgdoc"},"ManualEvidence":{"doc":{"anchor":"GUC-GEQO-THRESHOLD","file":"runtime-config-query.html","lang":"en","sha256":"33456ca7ef52bf28e93e34b932a411db7a1b95800179add2cf867dc6ec9144bc","slug":"18"}},"MeasuredEvidence":{"metadata_version":"18"}},"Text":{"Collection":"guc","Key":"geqo_threshold","SourceDatabase":"center","Version":"18","Locale":"en","Title":"geqo_threshold","Summary":"Use genetic query optimization to plan queries with at least this many FROM items involved. (Note that a FULL OUTER JOIN construct counts as only one FROM item.) The default is 12. For simpler queries it is usually best to use the regular, exhaustive-search planner, but for queries with many tables the exhaustive search takes too long, often longer than the penalty of executing a suboptimal plan. Thus, a threshold on the size of the query is a convenient way to manage use of GEQO.","BodyHTML":"\u003cp\u003eUse genetic query optimization to plan queries with at least this many FROM items involved. (Note that a FULL OUTER JOIN construct counts as only one FROM item.) The default is 12. For simpler queries it is usually best to use the regular, exhaustive-search planner, but for queries with many tables the exhaustive search takes too long, often longer than the penalty of executing a suboptimal plan. Thus, a threshold on the size of the query is a convenient way to manage use of GEQO.\u003c/p\u003e","SourceRevision":"wiki-repair-20261023:95723f645555a4df07648f7bcc99c06d2a33a84aa83a81ef403036344191acd3","ContentHash":"524e3b822a4592fcc6c9b09b30e1e90ee861af40d0b7fffa689d22c4b44287cf","Payload":{"description":"Use genetic query optimization to plan queries with at least this many FROM items involved. (Note that a FULL OUTER JOIN construct counts as only one FROM item.) The default is 12. For simpler queries it is usually best to use the regular, exhaustive-search planner, but for queries with many tables the exhaustive search takes too long, often longer than the penalty of executing a suboptimal plan. Thus, a threshold on the size of the query is a convenient way to manage use of GEQO."}},"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}
