Skip to content

Commit d244df9

Browse files
committed
More optimizer speedups.
1 parent 129543e commit d244df9

File tree

17 files changed

+192
-131
lines changed

17 files changed

+192
-131
lines changed

src/backend/nodes/copyfuncs.c

Lines changed: 9 additions & 9 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.66 1999/02/10 03:52:34 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.67 1999/02/11 14:58:48 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -1093,26 +1093,26 @@ CopyPathFields(Path *from, Path *newnode)
10931093

10941094
newnode->path_cost = from->path_cost;
10951095

1096-
newnode->path_order = makeNode(PathOrder);
1097-
newnode->path_order->ordtype = from->path_order->ordtype;
1098-
if (from->path_order->ordtype == SORTOP_ORDER)
1096+
newnode->pathorder = makeNode(PathOrder);
1097+
newnode->pathorder->ordtype = from->pathorder->ordtype;
1098+
if (from->pathorder->ordtype == SORTOP_ORDER)
10991099
{
11001100
int len,
11011101
i;
1102-
Oid *ordering = from->path_order->ord.sortop;
1102+
Oid *ordering = from->pathorder->ord.sortop;
11031103

11041104
if (ordering)
11051105
{
11061106
for (len = 0; ordering[len] != 0; len++)
11071107
;
1108-
newnode->path_order->ord.sortop = (Oid *) palloc(sizeof(Oid) * (len + 1));
1108+
newnode->pathorder->ord.sortop = (Oid *) palloc(sizeof(Oid) * (len + 1));
11091109
for (i = 0; i < len; i++)
1110-
newnode->path_order->ord.sortop[i] = ordering[i];
1111-
newnode->path_order->ord.sortop[len] = 0;
1110+
newnode->pathorder->ord.sortop[i] = ordering[i];
1111+
newnode->pathorder->ord.sortop[len] = 0;
11121112
}
11131113
}
11141114
else
1115-
Node_Copy(from, newnode, path_order->ord.merge);
1115+
Node_Copy(from, newnode, pathorder->ord.merge);
11161116

11171117
Node_Copy(from, newnode, pathkeys);
11181118

src/backend/nodes/equalfuncs.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.29 1999/02/10 21:02:33 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.30 1999/02/11 14:58:48 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -337,33 +337,33 @@ _equalPath(Path *a, Path *b)
337337
/*
338338
* if (a->path_cost != b->path_cost) return(false);
339339
*/
340-
if (a->path_order->ordtype == SORTOP_ORDER)
340+
if (a->pathorder->ordtype == SORTOP_ORDER)
341341
{
342342
int i = 0;
343343

344-
if (a->path_order->ord.sortop == NULL ||
345-
b->path_order->ord.sortop == NULL)
344+
if (a->pathorder->ord.sortop == NULL ||
345+
b->pathorder->ord.sortop == NULL)
346346
{
347-
if (a->path_order->ord.sortop != b->path_order->ord.sortop)
347+
if (a->pathorder->ord.sortop != b->pathorder->ord.sortop)
348348
return false;
349349
}
350350
else
351351
{
352-
while (a->path_order->ord.sortop[i] != 0 &&
353-
b->path_order->ord.sortop[i] != 0)
352+
while (a->pathorder->ord.sortop[i] != 0 &&
353+
b->pathorder->ord.sortop[i] != 0)
354354
{
355-
if (a->path_order->ord.sortop[i] != b->path_order->ord.sortop[i])
355+
if (a->pathorder->ord.sortop[i] != b->pathorder->ord.sortop[i])
356356
return false;
357357
i++;
358358
}
359-
if (a->path_order->ord.sortop[i] != 0 ||
360-
b->path_order->ord.sortop[i] != 0)
359+
if (a->pathorder->ord.sortop[i] != 0 ||
360+
b->pathorder->ord.sortop[i] != 0)
361361
return false;
362362
}
363363
}
364364
else
365365
{
366-
if (!equal(a->path_order->ord.merge, b->path_order->ord.merge))
366+
if (!equal(a->pathorder->ord.merge, b->pathorder->ord.merge))
367367
return false;
368368
}
369369
if (!equal(a->pathkeys, b->pathkeys))

src/backend/nodes/freefuncs.c

Lines changed: 6 additions & 6 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.6 1999/02/10 21:02:33 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/nodes/Attic/freefuncs.c,v 1.7 1999/02/11 14:58:49 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -756,15 +756,15 @@ _freeRelOptInfo(RelOptInfo *node)
756756
static void
757757
FreePathFields(Path *node)
758758
{
759-
if (node->path_order->ordtype == SORTOP_ORDER)
759+
if (node->pathorder->ordtype == SORTOP_ORDER)
760760
{
761-
if (node->path_order->ord.sortop)
762-
pfree(node->path_order->ord.sortop);
761+
if (node->pathorder->ord.sortop)
762+
pfree(node->pathorder->ord.sortop);
763763
}
764764
else
765-
freeObject(node->path_order->ord.merge);
765+
freeObject(node->pathorder->ord.merge);
766766

767-
pfree(node->path_order); /* is it an object, but we don't have
767+
pfree(node->pathorder); /* is it an object, but we don't have
768768
separate free for it */
769769

770770
freeObject(node->pathkeys);

src/backend/nodes/outfuncs.c

Lines changed: 11 additions & 11 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.68 1999/02/10 03:52:35 momjian Exp $
8+
* $Id: outfuncs.c,v 1.69 1999/02/11 14:58:49 momjian Exp $
99
*
1010
* NOTES
1111
* Every (plan) node in POSTGRES has an associated "out" routine which
@@ -964,8 +964,8 @@ _outPath(StringInfo str, Path *node)
964964
node->path_cost);
965965
_outNode(str, node->pathkeys);
966966

967-
appendStringInfo(str, " :path_order ");
968-
_outNode(str, node->path_order);
967+
appendStringInfo(str, " :pathorder ");
968+
_outNode(str, node->pathorder);
969969
}
970970

971971
/*
@@ -980,8 +980,8 @@ _outIndexPath(StringInfo str, IndexPath *node)
980980
node->path.path_cost);
981981
_outNode(str, node->path.pathkeys);
982982

983-
appendStringInfo(str, " :path_order ");
984-
_outNode(str, node->path.path_order);
983+
appendStringInfo(str, " :pathorder ");
984+
_outNode(str, node->path.pathorder);
985985

986986
appendStringInfo(str, " :indexid ");
987987
_outIntList(str, node->indexid);
@@ -1002,8 +1002,8 @@ _outJoinPath(StringInfo str, JoinPath *node)
10021002
node->path.path_cost);
10031003
_outNode(str, node->path.pathkeys);
10041004

1005-
appendStringInfo(str, " :path_order ");
1006-
_outNode(str, node->path.path_order);
1005+
appendStringInfo(str, " :pathorder ");
1006+
_outNode(str, node->path.pathorder);
10071007

10081008
appendStringInfo(str, " :pathinfo ");
10091009
_outNode(str, node->pathinfo);
@@ -1033,8 +1033,8 @@ _outMergePath(StringInfo str, MergePath *node)
10331033
node->jpath.path.path_cost);
10341034
_outNode(str, node->jpath.path.pathkeys);
10351035

1036-
appendStringInfo(str, " :path_order ");
1037-
_outNode(str, node->jpath.path.path_order);
1036+
appendStringInfo(str, " :pathorder ");
1037+
_outNode(str, node->jpath.path.pathorder);
10381038

10391039
appendStringInfo(str, " :pathinfo ");
10401040
_outNode(str, node->jpath.pathinfo);
@@ -1073,8 +1073,8 @@ _outHashPath(StringInfo str, HashPath *node)
10731073
node->jpath.path.path_cost);
10741074
_outNode(str, node->jpath.path.pathkeys);
10751075

1076-
appendStringInfo(str, " :path_order ");
1077-
_outNode(str, node->jpath.path.path_order);
1076+
appendStringInfo(str, " :pathorder ");
1077+
_outNode(str, node->jpath.path.pathorder);
10781078

10791079
appendStringInfo(str, " :pathinfo ");
10801080
_outNode(str, node->jpath.pathinfo);

src/backend/nodes/readfuncs.c

Lines changed: 11 additions & 11 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.53 1999/02/10 03:52:36 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.54 1999/02/11 14:58:49 momjian Exp $
1111
*
1212
* NOTES
1313
* Most of the read functions for plan nodes are tested. (In fact, they
@@ -1522,8 +1522,8 @@ _readPath()
15221522
token = lsptok(NULL, &length); /* now read it */
15231523
local_node->path_cost = (Cost) atof(token);
15241524

1525-
token = lsptok(NULL, &length); /* get :path_order */
1526-
local_node->path_order = nodeRead(true); /* now read it */
1525+
token = lsptok(NULL, &length); /* get :pathorder */
1526+
local_node->pathorder = nodeRead(true); /* now read it */
15271527

15281528
token = lsptok(NULL, &length); /* get :pathkeys */
15291529
local_node->pathkeys = nodeRead(true); /* now read it */
@@ -1554,8 +1554,8 @@ _readIndexPath()
15541554
token = lsptok(NULL, &length); /* now read it */
15551555
local_node->path.path_cost = (Cost) atof(token);
15561556

1557-
token = lsptok(NULL, &length); /* get :path_order */
1558-
local_node->path.path_order = nodeRead(true); /* now read it */
1557+
token = lsptok(NULL, &length); /* get :pathorder */
1558+
local_node->path.pathorder = nodeRead(true); /* now read it */
15591559

15601560
token = lsptok(NULL, &length); /* get :pathkeys */
15611561
local_node->path.pathkeys = nodeRead(true); /* now read it */
@@ -1593,8 +1593,8 @@ _readJoinPath()
15931593
token = lsptok(NULL, &length); /* now read it */
15941594
local_node->path.path_cost = (Cost) atof(token);
15951595

1596-
token = lsptok(NULL, &length); /* get :path_order */
1597-
local_node->path.path_order = nodeRead(true); /* now read it */
1596+
token = lsptok(NULL, &length); /* get :pathorder */
1597+
local_node->path.pathorder = nodeRead(true); /* now read it */
15981598

15991599
token = lsptok(NULL, &length); /* get :pathkeys */
16001600
local_node->path.pathkeys = nodeRead(true); /* now read it */
@@ -1658,8 +1658,8 @@ _readMergePath()
16581658

16591659
local_node->jpath.path.path_cost = (Cost) atof(token);
16601660

1661-
token = lsptok(NULL, &length); /* get :path_order */
1662-
local_node->jpath.path.path_order = nodeRead(true); /* now read it */
1661+
token = lsptok(NULL, &length); /* get :pathorder */
1662+
local_node->jpath.path.pathorder = nodeRead(true); /* now read it */
16631663

16641664
token = lsptok(NULL, &length); /* get :pathkeys */
16651665
local_node->jpath.path.pathkeys = nodeRead(true); /* now read it */
@@ -1732,8 +1732,8 @@ _readHashPath()
17321732

17331733
local_node->jpath.path.path_cost = (Cost) atof(token);
17341734

1735-
token = lsptok(NULL, &length); /* get :path_order */
1736-
local_node->jpath.path.path_order = nodeRead(true); /* now read it */
1735+
token = lsptok(NULL, &length); /* get :pathorder */
1736+
local_node->jpath.path.pathorder = nodeRead(true); /* now read it */
17371737

17381738
token = lsptok(NULL, &length); /* get :pathkeys */
17391739
local_node->jpath.path.pathkeys = nodeRead(true); /* now read it */

src/backend/optimizer/geqo/geqo_paths.c

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-
* $Id: geqo_paths.c,v 1.15 1999/02/10 21:02:35 momjian Exp $
8+
* $Id: geqo_paths.c,v 1.16 1999/02/11 14:58:50 momjian Exp $
99
*
1010
*-------------------------------------------------------------------------
1111
*/
@@ -113,7 +113,7 @@ geqo_rel_paths(RelOptInfo *rel)
113113
{
114114
path = (Path *) lfirst(y);
115115

116-
if (!path->path_order->ord.sortop)
116+
if (!path->pathorder->ord.sortop)
117117
break;
118118
}
119119

src/backend/optimizer/path/indxpath.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.42 1999/02/10 21:02:38 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.43 1999/02/11 14:58:50 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1290,9 +1290,9 @@ index_innerjoin(Query *root, RelOptInfo *rel, List *clausegroup_list,
12901290

12911291
pathnode->path.pathtype = T_IndexScan;
12921292
pathnode->path.parent = rel;
1293-
pathnode->path.path_order = makeNode(PathOrder);
1294-
pathnode->path.path_order->ordtype = SORTOP_ORDER;
1295-
pathnode->path.path_order->ord.sortop = index->ordering;
1293+
pathnode->path.pathorder = makeNode(PathOrder);
1294+
pathnode->path.pathorder->ordtype = SORTOP_ORDER;
1295+
pathnode->path.pathorder->ord.sortop = index->ordering;
12961296
pathnode->path.pathkeys = NIL;
12971297

12981298
pathnode->indexid = index->relids;

src/backend/optimizer/path/joinpath.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/joinpath.c,v 1.19 1999/02/10 21:02:38 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.20 1999/02/11 14:58:52 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -327,7 +327,7 @@ match_unsorted_outer(RelOptInfo *joinrel,
327327

328328
outerpath = (Path *) lfirst(i);
329329

330-
outerpath_ordering = outerpath->path_order;
330+
outerpath_ordering = outerpath->pathorder;
331331

332332
if (outerpath_ordering)
333333
{
@@ -470,7 +470,7 @@ match_unsorted_inner(RelOptInfo *joinrel,
470470

471471
innerpath = (Path *) lfirst(i);
472472

473-
innerpath_ordering = innerpath->path_order;
473+
innerpath_ordering = innerpath->pathorder;
474474

475475
if (innerpath_ordering)
476476
{

src/backend/optimizer/path/joinutils.c

Lines changed: 5 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/Attic/joinutils.c,v 1.17 1999/02/11 05:29:07 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/joinutils.c,v 1.18 1999/02/11 14:58:53 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -214,10 +214,12 @@ match_paths_joinkeys(List *joinkeys,
214214
foreach(i, paths)
215215
{
216216
Path *path = (Path *) lfirst(i);
217-
217+
int more_sort;
218+
218219
key_match = every_func(joinkeys, path->pathkeys, which_subkey);
219220

220-
if (equal_path_ordering(ordering, path->path_order) &&
221+
if (pathorder_match(ordering, path->pathorder, &more_sort) &&
222+
more_sort == 0 &&
221223
length(joinkeys) == length(path->pathkeys) && key_match)
222224
{
223225

src/backend/optimizer/path/mergeutils.c

Lines changed: 6 additions & 6 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/mergeutils.c,v 1.16 1999/02/10 03:52:41 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/mergeutils.c,v 1.17 1999/02/11 14:58:53 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -52,17 +52,17 @@ group_clauses_by_order(List *restrictinfo_list,
5252
* Create a new mergeinfo node and add it to 'mergeinfo-list'
5353
* if one does not yet exist for this merge ordering.
5454
*/
55-
PathOrder *path_order;
55+
PathOrder *pathorder;
5656
MergeInfo *xmergeinfo;
5757
Expr *clause = restrictinfo->clause;
5858
Var *leftop = get_leftop(clause);
5959
Var *rightop = get_rightop(clause);
6060
JoinKey *jmkeys;
6161

62-
path_order = makeNode(PathOrder);
63-
path_order->ordtype = MERGE_ORDER;
64-
path_order->ord.merge = merge_ordering;
65-
xmergeinfo = match_order_mergeinfo(path_order, mergeinfo_list);
62+
pathorder = makeNode(PathOrder);
63+
pathorder->ordtype = MERGE_ORDER;
64+
pathorder->ord.merge = merge_ordering;
65+
xmergeinfo = match_order_mergeinfo(pathorder, mergeinfo_list);
6666
if (inner_relid == leftop->varno)
6767
{
6868
jmkeys = makeNode(JoinKey);

0 commit comments

Comments
 (0)