Make planning via GEQO repeatable - Mailing list pgsql-hackers

From Andres Freund
Subject Make planning via GEQO repeatable
Date
Msg-id 1247610890-8922-1-git-send-email-andres@anarazel.de
Whole thread Raw
Responses [PATCH 3/3] Document geqo_seed variable.  (Andres Freund <andres@anarazel.de>)
[PATCH 2/3] Support a 'geqo_seed' GUC to make planning via GEQO repeatable.  (Andres Freund <andres@anarazel.de>)
Re: Make planning via GEQO repeatable  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Hi,

Query planning via GEQO currently can yield a different plan on every
invokation of the planner due to its non-exhaustive nature.

This often can be inconvenient because at times there may be a very
bad plan. It also makes it very hard to reproduce a problem with GEQO.


[PATCH 1/3] Add erand48() implementation for non-unixoid systems.

I could not find any suitable PRNG with a visible/changeable state for
windows. Currently random() on windows is mapped to drand48() copied
out of FreeBSD. I copied erand48(state) from there as well.
As I have no windows with a buildsystem available at the moment this
is untested on windows!

[PATCH 2/3] Support a 'geqo_seed' GUC to make planning via GEQO repeatable.

This patch adds a GUC geqo_seed to control whether the PRNG should be
repeatable or not. If geqo_seed = 0 a global/per-backend state is
used, thus the planning is not repeatable.
If set to a value in (0,1] that number is used to initialize the
generator on every planning.

It adds a "void *join_search_private" variable to PlannerInfo to hold
the random number generator. This variable could also be used by a
join_order plugin.
Alternatively it would be possible to start passing GeqoEvalData
around everywhere, but the suggestion to extend PlannerInfo came from
Tom...

"PlannerInfo *root" is now passed to all non-static geqo related
functions. It seems cleaner to do this for all functions than only
functions internally using the random generator.

GeqoEvalData, which is sparsely used, is replaced GeqoPrivateData
which is passed via join_search_private.

[PATCH 3/3] Document geqo_seed variable.

I will submit this to the commitfest. I guess thats OK?

Andres


pgsql-hackers by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: navigation menu for documents
Next
From: Andres Freund
Date:
Subject: [PATCH 3/3] Document geqo_seed variable.