id="runtime-config-query-geqo">
<title>Genetic Query Optimizer</title>
<para>
The genetic query optimizer (GEQO) is an algorithm that does query
planning using heuristic searching. This reduces planning time for
complex queries (those joining many relations), at the cost of producing
plans that are sometimes inferior to those found by the normal
exhaustive-search algorithm.
For more information see <xref linkend="geqo"/>.
</para>
<variablelist>
<varlistentry id="guc-geqo" xreflabel="geqo">
<term><varname>geqo</varname> (<type>boolean</type>)
<indexterm>
<primary>genetic query optimization</primary>
</indexterm>
<indexterm>
<primary>GEQO</primary>
<see>genetic query optimization</see>
</indexterm>
<indexterm>
<primary><varname>geqo</varname> configuration parameter</primary>
</indexterm>
</term>
<listitem>
<para>
Enables or disables genetic query optimization.
This is on by default. It is usually best not to turn it off in
production; the <varname>geqo_threshold</varname> variable provides
more granular control of GEQO.
</para>
</listitem>
</varlistentry>
<varlistentry id="guc-geqo-threshold" xreflabel="geqo_threshold">
<term><varname>geqo_threshold</varname> (<type>integer</type>)
<indexterm>
<primary><varname>geqo_threshold</varname> configuration parameter</primary>
</indexterm>
</term>
<listitem>
<para>
Use genetic query optimization to plan queries with at least
this many <literal>FROM</literal> items involved. (Note that a
<literal>FULL OUTER JOIN</literal> construct counts as only one <literal>FROM</literal>
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.
</para>
</listitem>
</varlistentry>
<varlistentry id="guc-geqo-effort" xreflabel="geqo_effort">
<term><varname>geqo_effort</varname> (<type>integer</type>)
<indexterm>
<primary><varname>geqo_effort</varname> configuration parameter</primary>
</indexterm>
</term>
<listitem>
<para>
Controls the trade-off between planning time and query plan
quality in GEQO. This variable must be an integer in the
range from 1 to 10. The default value is five. Larger values
increase the time spent doing query planning, but also
increase the likelihood that an efficient query plan will be
chosen.
</para>
<para>
<varname>geqo_effort</varname> doesn't actually do anything
directly; it is only used to compute the default values for
the other variables that influence GEQO behavior (described
below). If you prefer, you can set the other parameters by
hand instead.
</para>
</listitem>
</varlistentry>
<varlistentry id="guc-geqo-pool-size" xreflabel="geqo_pool_size">
<term><varname>geqo_pool_size</varname> (<type>integer</type>)
<indexterm>
<primary><varname>geqo_pool_size</varname> configuration parameter</primary>
</indexterm>
</term>
<listitem>
<para>
Controls the pool size used by GEQO, that is the
number of individuals in the genetic population. It must be
at least two, and useful values are typically 100 to 1000. If
it is set to zero (the default setting) then a suitable
value is chosen based on <varname>geqo_effort</varname> and
the number of tables in the query.
</para>
</listitem>
</varlistentry>