OSDN Git Service

Make GEQO's planning deterministic by having it start from a predictable
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 16 Jul 2009 20:55:44 +0000 (20:55 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 16 Jul 2009 20:55:44 +0000 (20:55 +0000)
commitf5bc74192d2ffb32952a06c62b3458d28ff7f98f
treed582b83c6ba2ff21d2970660806d353c6ac496ee
parentc43feefa806c81d68115ed03a7f723720cefad31
Make GEQO's planning deterministic by having it start from a predictable
random number seed each time.  This is how it used to work years ago, but
we got rid of the seed reset because it was resetting the main random()
sequence and thus having undesirable effects on the rest of the system.
To fix, establish a private random number state for each execution of
geqo(), and initialize the state using the new GUC variable geqo_seed.
People who want to experiment with different random searches can do so
by changing geqo_seed, but you'll always get the same plan for the same
value of geqo_seed (if holding all other planner inputs constant, of course).

The new state is kept in PlannerInfo by adding a "void *" field reserved
for use by join_search hooks.  Most of the rather bulky code changes in
this commit are just arranging to pass PlannerInfo around to all the GEQO
functions (many of which formerly didn't receive it).

Andres Freund, with some editorialization by Tom
27 files changed:
doc/src/sgml/config.sgml
doc/src/sgml/geqo.sgml
src/backend/optimizer/geqo/Makefile
src/backend/optimizer/geqo/geqo_copy.c
src/backend/optimizer/geqo/geqo_cx.c
src/backend/optimizer/geqo/geqo_erx.c
src/backend/optimizer/geqo/geqo_eval.c
src/backend/optimizer/geqo/geqo_main.c
src/backend/optimizer/geqo/geqo_mutation.c
src/backend/optimizer/geqo/geqo_ox1.c
src/backend/optimizer/geqo/geqo_ox2.c
src/backend/optimizer/geqo/geqo_pmx.c
src/backend/optimizer/geqo/geqo_pool.c
src/backend/optimizer/geqo/geqo_px.c
src/backend/optimizer/geqo/geqo_random.c [new file with mode: 0644]
src/backend/optimizer/geqo/geqo_recombination.c
src/backend/optimizer/geqo/geqo_selection.c
src/backend/utils/misc/guc.c
src/backend/utils/misc/postgresql.conf.sample
src/include/nodes/relation.h
src/include/optimizer/geqo.h
src/include/optimizer/geqo_copy.h
src/include/optimizer/geqo_mutation.h
src/include/optimizer/geqo_pool.h
src/include/optimizer/geqo_random.h
src/include/optimizer/geqo_recombination.h
src/include/optimizer/geqo_selection.h