Home Explore Blog CI



postgresql

3rd chunk of `doc/src/sgml/geqo.sgml`
b4716bc5d7a96b6b8bfc14d427869deda8a732d3ba3624de0000000100000ad2
 </listitem>

     <listitem>
      <para>
       Mutation as genetic operator is deprecated so that no repair
       mechanisms are needed to generate legal <acronym>TSP</acronym> tours.
      </para>
     </listitem>
    </itemizedlist>
   </para>

   <para>
    Parts of the <acronym>GEQO</acronym> module are adapted from D. Whitley's
    Genitor algorithm.
   </para>

   <para>
    The <acronym>GEQO</acronym> module allows
    the <productname>PostgreSQL</productname> query optimizer to
    support large join queries effectively through
    non-exhaustive search.
   </para>

  <sect2 id="geqo-pg-intro-gen-possible-plans">
   <title>Generating Possible Plans with <acronym>GEQO</acronym></title>

   <para>
    The <acronym>GEQO</acronym> planning process uses the standard planner
    code to generate plans for scans of individual relations.  Then join
    plans are developed using the genetic approach.  As shown above, each
    candidate join plan is represented by a sequence in which to join
    the base relations.  In the initial stage, the <acronym>GEQO</acronym>
    code simply generates some possible join sequences at random.  For each
    join sequence considered, the standard planner code is invoked to
    estimate the cost of performing the query using that join sequence.
    (For each step of the join sequence, all three possible join strategies
    are considered; and all the initially-determined relation scan plans
    are available.  The estimated cost is the cheapest of these
    possibilities.)  Join sequences with lower estimated cost are considered
    <quote>more fit</quote> than those with higher cost.  The genetic algorithm
    discards the least fit candidates.  Then new candidates are generated
    by combining genes of more-fit candidates &mdash; that is, by using
    randomly-chosen portions of known low-cost join sequences to create
    new sequences for consideration.  This process is repeated until a
    preset number of join sequences have been considered; then the best
    one found at any time during the search is used to generate the finished
    plan.
   </para>

   <para>
    This process is inherently nondeterministic, because of the randomized
    choices made during both the initial population selection and subsequent
    <quote>mutation</quote> of the best candidates.  To avoid surprising changes
    of the selected plan, each run of the GEQO algorithm restarts its
    random number generator with the current <xref linkend="guc-geqo-seed"/>
    parameter setting.  As long as <varname>geqo_seed</varname> and the other
    GEQO parameters are kept fixed, the same plan will be generated for a
    given query (and other planner inputs such as statistics).  To experiment
    with different

Title: Generating Possible Plans with GEQO
Summary
The GEQO planning process generates possible query plans using a genetic approach, where candidate join plans are represented by sequences and evaluated based on their estimated cost, with the genetic algorithm selecting and combining the most fit candidates to produce the final plan.