Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit38dd3ae

Browse files
committed
The attached patch fixes a build problem with GEQO when using the
PX recombination operator, changes some elog() messages from LOGto DEBUG1, puts some debugging functions inside the appropriate#ifdef (not enabled by default), and makes a few other minorcleanups.BTW, the elog() change is motivated by at least one user whohas sent a concerned email to -general asking exactly what the"ERX recombination operator" is, and what it is doing to theirDBMS.Neil Conway
1 parentaec814b commit38dd3ae

File tree

5 files changed

+29
-34
lines changed

5 files changed

+29
-34
lines changed

‎src/backend/optimizer/geqo/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#
66
# Copyright (c) 1994, Regents of the University of California
77
#
8-
# $Header: /cvsroot/pgsql/src/backend/optimizer/geqo/Makefile,v 1.16 2000/08/31 16:10:08 petere Exp $
8+
# $Header: /cvsroot/pgsql/src/backend/optimizer/geqo/Makefile,v 1.17 2002/07/20 04:59:10 momjian Exp $
99
#
1010
#-------------------------------------------------------------------------
1111

@@ -14,7 +14,7 @@ top_builddir = ../../../..
1414
include$(top_builddir)/src/Makefile.global
1515

1616
OBJS =geqo_copy.o geqo_eval.o geqo_main.o geqo_misc.o\
17-
geqo_pool.o geqo_recombination.o\
17+
geqo_mutation.ogeqo_pool.o geqo_recombination.o\
1818
geqo_selection.o\
1919
geqo_erx.o geqo_pmx.o geqo_cx.o geqo_px.o geqo_ox1.o geqo_ox2.o
2020

‎src/backend/optimizer/geqo/geqo_main.c

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/*------------------------------------------------------------------------
22
*
33
* geqo_main.c
4-
* solutionof the query optimization problem
4+
* solutionto the query optimization problem
55
* by means of a Genetic Algorithm (GA)
66
*
77
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: geqo_main.c,v 1.31 2002/06/2020:29:29 momjian Exp $
10+
* $Id: geqo_main.c,v 1.32 2002/07/2004:59:10 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -29,6 +29,7 @@
2929

3030
#include"optimizer/geqo.h"
3131
#include"optimizer/geqo_misc.h"
32+
#include"optimizer/geqo_mutation.h"
3233
#include"optimizer/geqo_pool.h"
3334
#include"optimizer/geqo_selection.h"
3435

@@ -46,7 +47,6 @@ intGeqo_random_seed;
4647
staticintgimme_pool_size(intnr_rel);
4748
staticintgimme_number_generations(intpool_size,inteffort);
4849

49-
5050
/* define edge recombination crossover [ERX] per default */
5151
#if !defined(ERX)&& \
5252
!defined(PMX)&& \
@@ -120,30 +120,30 @@ geqo(Query *root, int number_of_rels, List *initial_rels)
120120
daddy=alloc_chromo(pool->string_length);
121121

122122
#if defined (ERX)
123-
elog(LOG,"geqo_main: using edge recombination crossover [ERX]");
123+
elog(DEBUG1,"geqo_main: using edge recombination crossover [ERX]");
124124
/* allocate edge table memory */
125125
edge_table=alloc_edge_table(pool->string_length);
126126
#elif defined(PMX)
127-
elog(LOG,"geqo_main: using partially matched crossover [PMX]");
127+
elog(DEBUG1,"geqo_main: using partially matched crossover [PMX]");
128128
/* allocate chromosome kid memory */
129129
kid=alloc_chromo(pool->string_length);
130130
#elif defined(CX)
131-
elog(LOG,"geqo_main: using cycle crossover [CX]");
131+
elog(DEBUG1,"geqo_main: using cycle crossover [CX]");
132132
/* allocate city table memory */
133133
kid=alloc_chromo(pool->string_length);
134134
city_table=alloc_city_table(pool->string_length);
135135
#elif defined(PX)
136-
elog(LOG,"geqo_main: using position crossover [PX]");
136+
elog(DEBUG1,"geqo_main: using position crossover [PX]");
137137
/* allocate city table memory */
138138
kid=alloc_chromo(pool->string_length);
139139
city_table=alloc_city_table(pool->string_length);
140140
#elif defined(OX1)
141-
elog(LOG,"geqo_main: using order crossover [OX1]");
141+
elog(DEBUG1,"geqo_main: using order crossover [OX1]");
142142
/* allocate city table memory */
143143
kid=alloc_chromo(pool->string_length);
144144
city_table=alloc_city_table(pool->string_length);
145145
#elif defined(OX2)
146-
elog(LOG,"geqo_main: using order crossover [OX2]");
146+
elog(DEBUG1,"geqo_main: using order crossover [OX2]");
147147
/* allocate city table memory */
148148
kid=alloc_chromo(pool->string_length);
149149
city_table=alloc_city_table(pool->string_length);
@@ -155,19 +155,13 @@ geqo(Query *root, int number_of_rels, List *initial_rels)
155155

156156
for (generation=0;generation<number_generations;generation++)
157157
{
158-
159-
/* SELECTION */
160-
geqo_selection(momma,daddy,pool,Geqo_selection_bias);/* using linear bias
161-
* function */
162-
163-
158+
/* SELECTION: using linear bias function */
159+
geqo_selection(momma,daddy,pool,Geqo_selection_bias);
164160

165161
#if defined (ERX)
166162
/* EDGE RECOMBINATION CROSSOVER */
167163
difference=gimme_edge_table(momma->string,daddy->string,pool->string_length,edge_table);
168164

169-
/* let the kid grow in momma's womb (storage) for nine months ;-) */
170-
/* sleep(23328000) -- har har har */
171165
kid=momma;
172166

173167
/* are there any edge failures ? */
@@ -209,7 +203,7 @@ geqo(Query *root, int number_of_rels, List *initial_rels)
209203
print_gen(stdout,pool,generation);
210204
#endif
211205

212-
}/* end of iterative optimization */
206+
}
213207

214208

215209
#if defined(ERX)&& defined(GEQO_DEBUG)
@@ -289,14 +283,7 @@ gimme_pool_size(int nr_rel)
289283
doublesize;
290284

291285
if (Geqo_pool_size!=0)
292-
{
293-
if (Geqo_pool_size<MIN_GEQO_POOL_SIZE)
294-
returnMIN_GEQO_POOL_SIZE;
295-
elseif (Geqo_pool_size>MAX_GEQO_POOL_SIZE)
296-
returnMAX_GEQO_POOL_SIZE;
297-
else
298-
returnGeqo_pool_size;
299-
}
286+
returnGeqo_pool_size;
300287

301288
size=pow(2.0,nr_rel+1.0);
302289

‎src/backend/optimizer/geqo/geqo_misc.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: geqo_misc.c,v 1.32 2002/06/2020:29:29 momjian Exp $
9+
* $Id: geqo_misc.c,v 1.33 2002/07/2004:59:10 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -26,6 +26,7 @@
2626
#include"optimizer/geqo_misc.h"
2727
#include"nodes/print.h"
2828

29+
#ifdefGEQO_DEBUG
2930

3031
staticfloatavg_pool(Pool*pool);
3132

@@ -92,7 +93,7 @@ print_gen(FILE *fp, Pool *pool, int generation)
9293
lowest=pool->size>1 ?pool->size-2 :0;
9394

9495
fprintf(fp,
95-
"%5d |Bst: %fWst: %f Mean: %f Avg: %f\n",
96+
"%5d |Best: %fWorst: %f Mean: %f Avg: %f\n",
9697
generation,
9798
pool->data[0].worth,
9899
pool->data[lowest].worth,
@@ -248,3 +249,5 @@ geqo_print_rel(Query *root, RelOptInfo *rel)
248249
printf("\n\tcheapest total path:\n");
249250
geqo_print_path(root,rel->cheapest_total_path,1);
250251
}
252+
253+
#endif/* GEQO_DEBUG */

‎src/include/optimizer/geqo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: geqo.h,v 1.28 2002/06/2020:29:51 momjian Exp $
9+
* $Id: geqo.h,v 1.29 2002/07/2004:59:10 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -28,7 +28,7 @@
2828
/* GEQO debug flag */
2929
/*
3030
#define GEQO_DEBUG
31-
*/
31+
*/
3232

3333
/* recombination mechanism */
3434
/*

‎src/include/optimizer/geqo_misc.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: geqo_misc.h,v 1.19 2002/06/2020:29:51 momjian Exp $
9+
* $Id: geqo_misc.h,v 1.20 2002/07/2004:59:10 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -22,9 +22,12 @@
2222
#ifndefGEQO_MISC_H
2323
#defineGEQO_MISC_H
2424

25+
#include"optimizer/geqo.h"
2526
#include"optimizer/geqo_recombination.h"
2627
#include"nodes/relation.h"
2728

29+
#ifdefGEQO_DEBUG
30+
2831
externvoidprint_pool(FILE*fp,Pool*pool,intstart,intstop);
2932
externvoidprint_gen(FILE*fp,Pool*pool,intgeneration);
3033
externvoidprint_edge_table(FILE*fp,Edge*edge_table,intnum_gene);
@@ -33,4 +36,6 @@ extern void geqo_print_rel(Query *root, RelOptInfo *rel);
3336
externvoidgeqo_print_path(Query*root,Path*path,intindent);
3437
externvoidgeqo_print_joinclauses(Query*root,List*clauses);
3538

36-
#endif/* GEQO_MISC_H */
39+
#endif/* GEQO_DEBUG */
40+
41+
#endif/* GEQO_MISC_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp