DB Internals AtlasPostgreSQL 18.6 Home About

Parameter · Query Tuning / Genetic Query Optimizer

geqo_generations

GEQO: number of iterations of the algorithm. 0 means use a suitable default value.

  • Default: 0
  • Type: integer
  • Range: 0 … 2147483647
  • Applies: Session (any user)

In plain words

Each generation, the genetic optimizer breeds one new join order from two good ones and throws away the worst. More generations give the population time to improve, at the cost of planning time. Zero means "as many as the pool size".

For DBAs and operators

In PostgreSQL's GEQO, a "generation" produces exactly one child (steady-state genetic algorithm), so this is the number of additional join trees costed after the initial pool. Useful values are in the range 100 to 1000 per the docs; 0 picks the pool size.

Too few generations means the result is little better than the best random order of the initial pool. Too many hardly helps once the population has converged (all members are similar). If plans for the same large query vary between runs, more generations (or more effort) usually stabilize them; geqo_seed makes them repeatable but does not make them better.

How to change it

Any user can change it for their session with SET.

See it in context

Planner cost model

Related parameters

geqo_pool_size geqo_effort geqo_seed

All Query Tuning parameters