Enables or disables genetic query optimization.
At a glance
| Property | Value |
|---|---|
| Parameter | geqo |
| Category | Query Planning |
| Default | on |
| Value type | boolean (on/off) |
| Change scope | Per-session (SET) |
| Available in | PostgreSQL 12, 13, 14, 15, 16, 17, 18, 19 (added in 12) |
What it does
Enables or disables genetic query optimization. This is on by default. It is usually best not to turn it off in production; the geqo_threshold variable provides more granular control of GEQO.
(Description quoted from the official PostgreSQL documentation.)
How to apply a change
Can be set per session with SET, per role/database with ALTER ROLE/DATABASE ... SET, or globally in postgresql.conf.
Inspect the current value and source with SHOW geqo; or SELECT name, setting, unit, context, source FROM pg_settings WHERE name = 'geqo';.
Tuning guidance
Leave the genetic optimizer on; it only engages past geqo_threshold joins. Turn it off only to force exhaustive search on a specific complex query you are hand-tuning.