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

Commitfe35ffe

Browse files
committed
Major optimizer improvement for joining a large number of tables.
1 parentbe948af commitfe35ffe

File tree

21 files changed

+277
-139
lines changed

21 files changed

+277
-139
lines changed

‎src/backend/nodes/copyfuncs.c

Lines changed: 9 additions & 8 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.63 1999/02/08 04:29:03 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.64 1999/02/09 03:51:12 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -1093,25 +1093,26 @@ CopyPathFields(Path *from, Path *newnode)
10931093

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

1096-
newnode->path_order.ordtype=from->path_order.ordtype;
1097-
if (from->path_order.ordtype==SORTOP_ORDER)
1096+
newnode->path_order=makeNode(PathOrder);
1097+
newnode->path_order->ordtype=from->path_order->ordtype;
1098+
if (from->path_order->ordtype==SORTOP_ORDER)
10981099
{
10991100
intlen,
11001101
i;
1101-
Oid*ordering=from->path_order.ord.sortop;
1102+
Oid*ordering=from->path_order->ord.sortop;
11021103

11031104
if (ordering)
11041105
{
11051106
for (len=0;ordering[len]!=0;len++)
11061107
;
1107-
newnode->path_order.ord.sortop= (Oid*)palloc(sizeof(Oid)* (len+1));
1108+
newnode->path_order->ord.sortop= (Oid*)palloc(sizeof(Oid)* (len+1));
11081109
for (i=0;i<len;i++)
1109-
newnode->path_order.ord.sortop[i]=ordering[i];
1110-
newnode->path_order.ord.sortop[len]=0;
1110+
newnode->path_order->ord.sortop[i]=ordering[i];
1111+
newnode->path_order->ord.sortop[len]=0;
11111112
}
11121113
}
11131114
else
1114-
Node_Copy(from,newnode,path_order.ord.merge);
1115+
Node_Copy(from,newnode,path_order->ord.merge);
11151116

11161117
Node_Copy(from,newnode,keys);
11171118

‎src/backend/nodes/equalfuncs.c

Lines changed: 13 additions & 13 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.26 1999/02/08 04:29:04 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.27 1999/02/09 03:51:12 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->path_order->ordtype==SORTOP_ORDER)
341341
{
342342
inti=0;
343343

344-
if (a->path_order.ord.sortop==NULL||
345-
b->path_order.ord.sortop==NULL)
344+
if (a->path_order->ord.sortop==NULL||
345+
b->path_order->ord.sortop==NULL)
346346
{
347-
if (a->path_order.ord.sortop!=b->path_order.ord.sortop)
347+
if (a->path_order->ord.sortop!=b->path_order->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->path_order->ord.sortop[i]!=0&&
353+
b->path_order->ord.sortop[i]!=0)
354354
{
355-
if (a->path_order.ord.sortop[i]!=b->path_order.ord.sortop[i])
355+
if (a->path_order->ord.sortop[i]!=b->path_order->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->path_order->ord.sortop[i]!=0||
360+
b->path_order->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->path_order->ord.merge,b->path_order->ord.merge))
367367
return false;
368368
}
369369
if (!equal(a->keys,b->keys))
@@ -433,9 +433,9 @@ _equalHashPath(HashPath *a, HashPath *b)
433433
return false;
434434
if (!equal((a->path_hashclauses), (b->path_hashclauses)))
435435
return false;
436-
if (!equal((a->outerhashkeys), (b->outerhashkeys)))
436+
if (!equal(a->outerhashkeys,b->outerhashkeys))
437437
return false;
438-
if (!equal((a->innerhashkeys), (b->innerhashkeys)))
438+
if (!equal(a->innerhashkeys,b->innerhashkeys))
439439
return false;
440440
return true;
441441
}

‎src/backend/nodes/freefuncs.c

Lines changed: 8 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.2 1999/02/08 04:29:04 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/nodes/Attic/freefuncs.c,v 1.3 1999/02/09 03:51:12 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -756,13 +756,16 @@ _freeRelOptInfo(RelOptInfo * node)
756756
staticvoid
757757
FreePathFields(Path*node)
758758
{
759-
if (node->path_order.ordtype==SORTOP_ORDER)
759+
if (node->path_order->ordtype==SORTOP_ORDER)
760760
{
761-
if (node->path_order.ord.sortop)
762-
pfree(node->path_order.ord.sortop);
761+
if (node->path_order->ord.sortop)
762+
pfree(node->path_order->ord.sortop);
763763
}
764764
else
765-
freeObject(node->path_order.ord.merge);
765+
freeObject(node->path_order->ord.merge);
766+
767+
pfree(node->path_order);/* is it an object, but we don't have
768+
separate free for it */
766769

767770
freeObject(node->keys);
768771

@@ -1171,7 +1174,6 @@ freeObject(void *node)
11711174

11721175
switch (nodeTag(node))
11731176
{
1174-
11751177
/*
11761178
* PLAN NODES
11771179
*/

‎src/backend/nodes/list.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/nodes/list.c,v 1.15 1998/09/01 04:29:05 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/nodes/list.c,v 1.16 1999/02/09 03:51:13 momjian Exp $
1111
*
1212
* NOTES
1313
* XXX a few of the following functions are duplicated to handle
@@ -368,8 +368,8 @@ member(void *l1, List *l2)
368368
List*i;
369369

370370
foreach(i,l2)
371-
if (equal((Node*)(lfirst(i)), (Node*)l1))
372-
return true;
371+
if (equal((Node*)l1, (Node*)lfirst(i)))
372+
return true;
373373
return false;
374374
}
375375

‎src/backend/nodes/outfuncs.c

Lines changed: 49 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: outfuncs.c,v 1.65 1999/02/05 19:59:25 momjian Exp $
8+
* $Id: outfuncs.c,v 1.66 1999/02/09 03:51:13 momjian Exp $
99
*
1010
* NOTES
1111
* Every (plan) node in POSTGRES has an associated "out" routine which
@@ -855,7 +855,7 @@ _outEState(StringInfo str, EState *node)
855855
*Stuff from relation.h
856856
*/
857857
staticvoid
858-
_outRelOptInfo(StringInfostr,RelOptInfo*node)
858+
_outRelOptInfo(StringInfostr,RelOptInfo*node)
859859
{
860860
appendStringInfo(str," RELOPTINFO :relids ");
861861
_outIntList(str,node->relids);
@@ -924,6 +924,35 @@ _outRowMark(StringInfo str, RowMark *node)
924924
appendStringInfo(str," ROWMARK :rti %u :info %u",node->rti,node->info);
925925
}
926926

927+
/*
928+
*Path is a subclass of Node.
929+
*/
930+
staticvoid
931+
_outPathOrder(StringInfostr,PathOrder*node)
932+
{
933+
appendStringInfo(str," PATHORDER :ordtype %d ",
934+
node->ordtype);
935+
if (node->ordtype==SORTOP_ORDER)
936+
{
937+
inti;
938+
939+
appendStringInfo(str," :sortop ");
940+
if (node->ord.sortop==NULL)
941+
appendStringInfo(str,"<>");
942+
else
943+
{
944+
for (i=0;node->ord.sortop[i]!=0;i++)
945+
appendStringInfo(str," %d ",node->ord.sortop[i]);
946+
appendStringInfo(str," %d ",0);
947+
}
948+
}
949+
else
950+
{
951+
appendStringInfo(str," :merge ");
952+
_outNode(str,node->ord.merge);
953+
}
954+
}
955+
927956
/*
928957
*Path is a subclass of Node.
929958
*/
@@ -934,6 +963,9 @@ _outPath(StringInfo str, Path *node)
934963
node->pathtype,
935964
node->path_cost);
936965
_outNode(str,node->keys);
966+
967+
appendStringInfo(str," :path_order ");
968+
_outNode(str,node->path_order);
937969
}
938970

939971
/*
@@ -948,6 +980,9 @@ _outIndexPath(StringInfo str, IndexPath *node)
948980
node->path.path_cost);
949981
_outNode(str,node->path.keys);
950982

983+
appendStringInfo(str," :path_order ");
984+
_outNode(str,node->path.path_order);
985+
951986
appendStringInfo(str," :indexid ");
952987
_outIntList(str,node->indexid);
953988

@@ -967,6 +1002,9 @@ _outJoinPath(StringInfo str, JoinPath *node)
9671002
node->path.path_cost);
9681003
_outNode(str,node->path.keys);
9691004

1005+
appendStringInfo(str," :path_order ");
1006+
_outNode(str,node->path.path_order);
1007+
9701008
appendStringInfo(str," :pathinfo ");
9711009
_outNode(str,node->pathinfo);
9721010

@@ -995,6 +1033,9 @@ _outMergePath(StringInfo str, MergePath *node)
9951033
node->jpath.path.path_cost);
9961034
_outNode(str,node->jpath.path.keys);
9971035

1036+
appendStringInfo(str," :path_order ");
1037+
_outNode(str,node->jpath.path.path_order);
1038+
9981039
appendStringInfo(str," :pathinfo ");
9991040
_outNode(str,node->jpath.pathinfo);
10001041

@@ -1032,6 +1073,9 @@ _outHashPath(StringInfo str, HashPath *node)
10321073
node->jpath.path.path_cost);
10331074
_outNode(str,node->jpath.path.keys);
10341075

1076+
appendStringInfo(str," :path_order ");
1077+
_outNode(str,node->jpath.path.path_order);
1078+
10351079
appendStringInfo(str," :pathinfo ");
10361080
_outNode(str,node->jpath.pathinfo);
10371081

@@ -1548,6 +1592,9 @@ _outNode(StringInfo str, void *obj)
15481592
caseT_RowMark:
15491593
_outRowMark(str,obj);
15501594
break;
1595+
caseT_PathOrder:
1596+
_outPathOrder(str,obj);
1597+
break;
15511598
caseT_Path:
15521599
_outPath(str,obj);
15531600
break;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp