Skip to content

Commit 3fdb9bb

Browse files
committed
Fix optimizer and make faster.
1 parent 55d0465 commit 3fdb9bb

File tree

15 files changed

+60
-145
lines changed

15 files changed

+60
-145
lines changed

src/backend/nodes/copyfuncs.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.67 1999/02/11 14:58:48 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.68 1999/02/12 05:56:45 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -1026,7 +1026,6 @@ _copyRelOptInfo(RelOptInfo * from)
10261026
newnode->width = from->width;
10271027
Node_Copy(from, newnode, targetlist);
10281028
Node_Copy(from, newnode, pathlist);
1029-
Node_Copy(from, newnode, unorderedpath);
10301029
Node_Copy(from, newnode, cheapestpath);
10311030
newnode->pruneable = from->pruneable;
10321031

src/backend/nodes/freefuncs.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/nodes/Attic/freefuncs.c,v 1.7 1999/02/11 14:58:49 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/nodes/Attic/freefuncs.c,v 1.8 1999/02/12 05:56:45 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -724,7 +724,6 @@ _freeRelOptInfo(RelOptInfo *node)
724724

725725
freeObject(node->targetlist);
726726
freeObject(node->pathlist);
727-
freeObject(node->unorderedpath);
728727
freeObject(node->cheapestpath);
729728

730729
if (node->classlist)

src/backend/nodes/outfuncs.c

Lines changed: 2 additions & 3 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-
* $Id: outfuncs.c,v 1.69 1999/02/11 14:58:49 momjian Exp $
8+
* $Id: outfuncs.c,v 1.70 1999/02/12 05:56:46 momjian Exp $
99
*
1010
* NOTES
1111
* Every (plan) node in POSTGRES has an associated "out" routine which
@@ -879,8 +879,7 @@ _outRelOptInfo(StringInfo str, RelOptInfo *node)
879879
*/
880880

881881
appendStringInfo(str,
882-
" :unorderedpath @ 0x%x :cheapestpath @ 0x%x :pruneable %s :restrictinfo ",
883-
(int) node->unorderedpath,
882+
" :cheapestpath @ 0x%x :pruneable %s :restrictinfo ",
884883
(int) node->cheapestpath,
885884
node->pruneable ? "true" : "false");
886885
_outNode(str, node->restrictinfo);

src/backend/nodes/readfuncs.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.54 1999/02/11 14:58:49 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.55 1999/02/12 05:56:46 momjian Exp $
1111
*
1212
* NOTES
1313
* Most of the read functions for plan nodes are tested. (In fact, they
@@ -1334,12 +1334,6 @@ _readRelOptInfo()
13341334
* This can be changed later, if necessary.
13351335
*/
13361336

1337-
token = lsptok(NULL, &length); /* get :unorderpath */
1338-
token = lsptok(NULL, &length); /* get @ */
1339-
token = lsptok(NULL, &length); /* now read it */
1340-
1341-
sscanf(token, "%x", (unsigned int *) &local_node->unorderedpath);
1342-
13431337
token = lsptok(NULL, &length); /* get :cheapestpath */
13441338
token = lsptok(NULL, &length); /* get @ */
13451339
token = lsptok(NULL, &length); /* now read it */

src/backend/optimizer/geqo/geqo_eval.c

Lines changed: 2 additions & 4 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-
* $Id: geqo_eval.c,v 1.27 1999/02/10 21:02:34 momjian Exp $
8+
* $Id: geqo_eval.c,v 1.28 1999/02/12 05:56:47 momjian Exp $
99
*
1010
*-------------------------------------------------------------------------
1111
*/
@@ -161,8 +161,7 @@ gimme_tree(Query *root, Gene *tour, int rel_count, int num_gene, RelOptInfo *out
161161
new_rel = (RelOptInfo *) lfirst(new_rels);
162162
rel_count++;
163163

164-
/* process new_rel->cheapestpath, new_rel->unorderedpath */
165-
geqo_rel_paths(new_rel);
164+
geqo_set_cheapest(new_rel);
166165

167166
/* processing of other new_rel attributes */
168167
if (new_rel->size <= 0)
@@ -282,7 +281,6 @@ init_join_rel(RelOptInfo *outer_rel, RelOptInfo *inner_rel, JoinInfo * joininfo)
282281
joinrel->width = 0;
283282
/* joinrel->targetlist = NIL;*/
284283
joinrel->pathlist = NIL;
285-
joinrel->unorderedpath = (Path *) NULL;
286284
joinrel->cheapestpath = (Path *) NULL;
287285
joinrel->pruneable = true;
288286
joinrel->classlist = NULL;

src/backend/optimizer/geqo/geqo_paths.c

Lines changed: 6 additions & 52 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-
* $Id: geqo_paths.c,v 1.16 1999/02/11 14:58:50 momjian Exp $
8+
* $Id: geqo_paths.c,v 1.17 1999/02/12 05:56:48 momjian Exp $
99
*
1010
*-------------------------------------------------------------------------
1111
*/
@@ -29,7 +29,6 @@
2929

3030

3131
static List *geqo_prune_rel(RelOptInfo *rel, List *other_rels);
32-
static Path *set_paths(RelOptInfo *rel, Path *unorderedpath);
3332

3433
/*
3534
* geqo-prune-rels--
@@ -92,62 +91,17 @@ geqo_prune_rel(RelOptInfo *rel, List *other_rels)
9291
}
9392

9493
/*
95-
* geqo-rel-paths--
94+
* geqo-set-cheapest--
9695
* For a relation 'rel' (which corresponds to a join
97-
* relation), set pointers to the unordered path and cheapest paths
98-
* (if the unordered path isn't the cheapest, it is pruned), and
99-
* reset the relation's size field to reflect the join.
100-
*
101-
* Returns nothing of interest.
102-
*
96+
* relation), set pointers to the cheapest path
10397
*/
10498
void
105-
geqo_rel_paths(RelOptInfo *rel)
99+
geqo_set_cheapest(RelOptInfo *rel)
106100
{
107-
List *y = NIL;
108-
Path *path = (Path *) NULL;
109-
JoinPath *cheapest = (JoinPath *) NULL;
110-
111-
rel->size = 0;
112-
foreach(y, rel->pathlist)
113-
{
114-
path = (Path *) lfirst(y);
115-
116-
if (!path->pathorder->ord.sortop)
117-
break;
118-
}
101+
JoinPath *cheapest = (JoinPath *)set_cheapest(rel, rel->pathlist);
119102

120-
cheapest = (JoinPath *) set_paths(rel, path);
121103
if (IsA_JoinPath(cheapest))
122104
rel->size = compute_joinrel_size(cheapest);
123-
}
124-
125-
126-
/*
127-
* set-path--
128-
* Compares the unordered path for a relation with the cheapest path. If
129-
* the unordered path is not cheapest, it is pruned.
130-
*
131-
* Resets the pointers in 'rel' for unordered and cheapest paths.
132-
*
133-
* Returns the cheapest path.
134-
*
135-
*/
136-
static Path *
137-
set_paths(RelOptInfo *rel, Path *unorderedpath)
138-
{
139-
Path *cheapest = set_cheapest(rel, rel->pathlist);
140-
141-
/* don't prune if not pruneable -- JMH, 11/23/92 */
142-
if (unorderedpath != cheapest
143-
&& rel->pruneable)
144-
{
145-
146-
rel->unorderedpath = (Path *) NULL;
147-
rel->pathlist = lremove(unorderedpath, rel->pathlist);
148-
}
149105
else
150-
rel->unorderedpath = (Path *) unorderedpath;
151-
152-
return cheapest;
106+
rel->size = 0;
153107
}

src/backend/optimizer/path/allpaths.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.27 1999/02/10 21:02:36 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.28 1999/02/12 05:56:49 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -139,7 +139,7 @@ find_rel_paths(Query *root, List *rels)
139139
lastpath = rel->pathlist;
140140
while (lnext(lastpath) != NIL)
141141
lastpath = lnext(lastpath);
142-
prune_rel_path(rel, (Path *) lfirst(lastpath));
142+
set_cheapest(rel, rel->pathlist);
143143

144144
/*
145145
* if there is a qualification of sequential scan the selec. value
@@ -223,7 +223,7 @@ find_join_paths(Query *root, List *outer_rels, int levels_needed)
223223
xfunc_trypullup((RelOptInfo *) lfirst(x));
224224
#endif
225225

226-
prune_rel_paths(new_rels);
226+
rels_set_cheapest(new_rels);
227227

228228
if (BushyPlanFlag)
229229
{

src/backend/optimizer/path/joinrels.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinrels.c,v 1.18 1999/02/10 21:02:39 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinrels.c,v 1.19 1999/02/12 05:56:50 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -216,7 +216,6 @@ init_join_rel(RelOptInfo *outer_rel, RelOptInfo *inner_rel, JoinInfo * joininfo)
216216
joinrel->width = 0;
217217
/* joinrel->targetlist = NIL;*/
218218
joinrel->pathlist = NIL;
219-
joinrel->unorderedpath = (Path *) NULL;
220219
joinrel->cheapestpath = (Path *) NULL;
221220
joinrel->pruneable = true;
222221
joinrel->classlist = NULL;

src/backend/optimizer/path/prune.c

Lines changed: 7 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/prune.c,v 1.27 1999/02/11 14:58:54 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/prune.c,v 1.28 1999/02/12 05:56:51 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -77,42 +77,28 @@ prune_joinrel(RelOptInfo *rel, List *other_rels)
7777
rel->pathlist,
7878
other_rel->pathlist);
7979
else
80-
result = nconc(result, lcons(other_rel, NIL));
80+
result = lappend(result, other_rel);
8181
}
8282
return result;
8383
}
8484

8585
/*
86-
* prune-rel-paths--
86+
* rels-set-cheapest
8787
* For each relation entry in 'rel-list' (which corresponds to a join
88-
* relation), set pointers to the unordered path and cheapest paths
89-
* (if the unordered path isn't the cheapest, it is pruned), and
90-
* reset the relation's size field to reflect the join.
91-
*
92-
* Returns nothing of interest.
93-
*
88+
* relation), set pointers to the cheapest path
9489
*/
9590
void
96-
prune_rel_paths(List *rel_list)
91+
rels_set_cheapest(List *rel_list)
9792
{
9893
List *x = NIL;
99-
List *y = NIL;
100-
Path *path = NULL;
10194
RelOptInfo *rel = (RelOptInfo *) NULL;
102-
JoinPath *cheapest = (JoinPath *) NULL;
95+
JoinPath *cheapest;
10396

10497
foreach(x, rel_list)
10598
{
10699
rel = (RelOptInfo *) lfirst(x);
107-
rel->size = 0;
108-
foreach(y, rel->pathlist)
109-
{
110-
path = (Path *) lfirst(y);
111100

112-
if (!path->pathorder->ord.sortop)
113-
break;
114-
}
115-
cheapest = (JoinPath *) prune_rel_path(rel, path);
101+
cheapest = (JoinPath *) set_cheapest(rel, rel->pathlist);
116102
if (IsA_JoinPath(cheapest))
117103
rel->size = compute_joinrel_size(cheapest);
118104
else
@@ -121,33 +107,6 @@ prune_rel_paths(List *rel_list)
121107
}
122108

123109

124-
/*
125-
* prune-rel-path--
126-
* Compares the unordered path for a relation with the cheapest path. If
127-
* the unordered path is not cheapest, it is pruned.
128-
*
129-
* Resets the pointers in 'rel' for unordered and cheapest paths.
130-
*
131-
* Returns the cheapest path.
132-
*
133-
*/
134-
Path *
135-
prune_rel_path(RelOptInfo *rel, Path *unorderedpath)
136-
{
137-
Path *cheapest = set_cheapest(rel, rel->pathlist);
138-
139-
/* don't prune if not pruneable -- JMH, 11/23/92 */
140-
if (unorderedpath != cheapest && rel->pruneable)
141-
{
142-
rel->unorderedpath = (Path *) NULL;
143-
rel->pathlist = lremove(unorderedpath, rel->pathlist);
144-
}
145-
else
146-
rel->unorderedpath = (Path *) unorderedpath;
147-
148-
return cheapest;
149-
}
150-
151110
/*
152111
* merge-joinrels--
153112
* Given two lists of rel nodes that are already

src/backend/optimizer/util/indexnode.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/Attic/indexnode.c,v 1.12 1999/02/10 21:02:40 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/Attic/indexnode.c,v 1.13 1999/02/12 05:56:55 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -78,7 +78,6 @@ find_secondary_index(Query *root, Oid relid)
7878
indexnode->width = 0;
7979
indexnode->targetlist = NIL;
8080
indexnode->pathlist = NIL;
81-
indexnode->unorderedpath = NULL;
8281
indexnode->cheapestpath = NULL;
8382
indexnode->pruneable = true;
8483
indexnode->restrictinfo = NIL;

0 commit comments

Comments
 (0)