Type: integer
Default: 12
Min: 2
Max: 2147483647
Context: user
Restart: false

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.


With new, faster processors it's tempting to raise the geqo_threshold a little, such as to 16 or 18. Increasing more than that is unwise as query planning time goes up geometrically.