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

Commit166b5c1

Browse files
committed
Another round of planner/optimizer work. This is just restructuring and
code cleanup; no major improvements yet. However, EXPLAIN does producemore intuitive outputs for nested loops with indexscans now...
1 parent69d4299 commit166b5c1

35 files changed

+1223
-1432
lines changed

‎src/backend/commands/explain.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Copyright (c) 1994-5, Regents of the University of California
66
*
7-
* $Id: explain.c,v 1.50 1999/11/23 20:06:48 momjian Exp $
7+
* $Id: explain.c,v 1.51 2000/01/09 00:26:18 tgl Exp $
88
*
99
*/
1010

@@ -256,8 +256,8 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
256256
}
257257
if (es->printCost)
258258
{
259-
appendStringInfo(str," (cost=%.2f rows=%d width=%d)",
260-
plan->cost,plan->plan_size,plan->plan_width);
259+
appendStringInfo(str," (cost=%.2f rows=%.0f width=%d)",
260+
plan->cost,plan->plan_rows,plan->plan_width);
261261
}
262262
appendStringInfo(str,"\n");
263263

‎src/backend/executor/nodeHash.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Copyright (c) 1994, Regents of the University of California
77
*
88
*
9-
*$Id: nodeHash.c,v 1.41 1999/12/16 22:19:44 wieck Exp $
9+
*$Id: nodeHash.c,v 1.42 2000/01/09 00:26:18 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -227,7 +227,7 @@ HashJoinTable
227227
ExecHashTableCreate(Hash*node)
228228
{
229229
Plan*outerNode;
230-
intntuples;
230+
doublentuples;
231231
inttupsize;
232232
doubleinner_rel_bytes;
233233
doublehash_table_bytes;
@@ -250,17 +250,17 @@ ExecHashTableCreate(Hash *node)
250250
* ----------------
251251
*/
252252
outerNode=outerPlan(node);
253-
ntuples=outerNode->plan_size;
254-
if (ntuples <=0)/* force a plausible size if no info */
255-
ntuples=1000;
253+
ntuples=outerNode->plan_rows;
254+
if (ntuples <=0.0)/* force a plausible size if no info */
255+
ntuples=1000.0;
256256

257257
/*
258258
* estimate tupsize based on footprint of tuple in hashtable... but
259259
* what about palloc overhead?
260260
*/
261261
tupsize=MAXALIGN(outerNode->plan_width)+
262262
MAXALIGN(sizeof(HashJoinTupleData));
263-
inner_rel_bytes=(double)ntuples*tupsize*FUDGE_FAC;
263+
inner_rel_bytes=ntuples*tupsize*FUDGE_FAC;
264264

265265
/*
266266
* Target hashtable size is SortMem kilobytes, but not less than
@@ -276,7 +276,7 @@ ExecHashTableCreate(Hash *node)
276276
* for an average bucket load of NTUP_PER_BUCKET (per virtual
277277
* bucket!).
278278
*/
279-
totalbuckets= (int)ceil((double)ntuples*FUDGE_FAC /NTUP_PER_BUCKET);
279+
totalbuckets= (int)ceil(ntuples*FUDGE_FAC /NTUP_PER_BUCKET);
280280

281281
/*
282282
* Count the number of buckets we think will actually fit in the

‎src/backend/nodes/copyfuncs.c

Lines changed: 35 additions & 19 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.98 1999/12/13 01:26:53 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.99 2000/01/09 00:26:22 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -75,9 +75,9 @@ static void
7575
CopyPlanFields(Plan*from,Plan*newnode)
7676
{
7777
newnode->cost=from->cost;
78-
newnode->plan_size=from->plan_size;
78+
newnode->plan_rows=from->plan_rows;
7979
newnode->plan_width=from->plan_width;
80-
newnode->plan_tupperpage=from->plan_tupperpage;
80+
/* state is NOT copied */
8181
newnode->targetlist=copyObject(from->targetlist);
8282
newnode->qual=copyObject(from->qual);
8383
newnode->lefttree=copyObject(from->lefttree);
@@ -962,25 +962,44 @@ static RelOptInfo *
962962
_copyRelOptInfo(RelOptInfo*from)
963963
{
964964
RelOptInfo*newnode=makeNode(RelOptInfo);
965-
inti,
966-
len;
967965

968-
/* ----------------
969-
*copy remainder of node
970-
* ----------------
971-
*/
972966
newnode->relids=listCopy(from->relids);
973967

974-
newnode->indexed=from->indexed;
975-
newnode->pages=from->pages;
976-
newnode->tuples=from->tuples;
977-
newnode->size=from->size;
968+
newnode->rows=from->rows;
978969
newnode->width=from->width;
970+
979971
Node_Copy(from,newnode,targetlist);
980972
Node_Copy(from,newnode,pathlist);
973+
/* XXX cheapestpath should point to a member of pathlist? */
981974
Node_Copy(from,newnode,cheapestpath);
982975
newnode->pruneable=from->pruneable;
983976

977+
newnode->indexed=from->indexed;
978+
newnode->pages=from->pages;
979+
newnode->tuples=from->tuples;
980+
981+
Node_Copy(from,newnode,restrictinfo);
982+
Node_Copy(from,newnode,joininfo);
983+
Node_Copy(from,newnode,innerjoin);
984+
985+
returnnewnode;
986+
}
987+
988+
/* ----------------
989+
*_copyIndexOptInfo
990+
* ----------------
991+
*/
992+
staticIndexOptInfo*
993+
_copyIndexOptInfo(IndexOptInfo*from)
994+
{
995+
IndexOptInfo*newnode=makeNode(IndexOptInfo);
996+
inti,
997+
len;
998+
999+
newnode->indexoid=from->indexoid;
1000+
newnode->pages=from->pages;
1001+
newnode->tuples=from->tuples;
1002+
9841003
if (from->classlist)
9851004
{
9861005
for (len=0;from->classlist[len]!=0;len++)
@@ -1015,10 +1034,6 @@ _copyRelOptInfo(RelOptInfo *from)
10151034
newnode->indproc=from->indproc;
10161035
Node_Copy(from,newnode,indpred);
10171036

1018-
Node_Copy(from,newnode,restrictinfo);
1019-
Node_Copy(from,newnode,joininfo);
1020-
Node_Copy(from,newnode,innerjoin);
1021-
10221037
returnnewnode;
10231038
}
10241039

@@ -1120,7 +1135,6 @@ _copyTidPath(TidPath *from)
11201135
staticvoid
11211136
CopyJoinPathFields(JoinPath*from,JoinPath*newnode)
11221137
{
1123-
Node_Copy(from,newnode,pathinfo);
11241138
Node_Copy(from,newnode,outerjoinpath);
11251139
Node_Copy(from,newnode,innerjoinpath);
11261140
}
@@ -1229,7 +1243,6 @@ _copyRestrictInfo(RestrictInfo *from)
12291243
* ----------------
12301244
*/
12311245
Node_Copy(from,newnode,clause);
1232-
newnode->selectivity=from->selectivity;
12331246
Node_Copy(from,newnode,subclauseindices);
12341247
newnode->mergejoinoperator=from->mergejoinoperator;
12351248
newnode->left_sortop=from->left_sortop;
@@ -1617,6 +1630,9 @@ copyObject(void *from)
16171630
caseT_Stream:
16181631
retval=_copyStream(from);
16191632
break;
1633+
caseT_IndexOptInfo:
1634+
retval=_copyIndexOptInfo(from);
1635+
break;
16201636

16211637
/*
16221638
* PARSE NODES

‎src/backend/nodes/equalfuncs.c

Lines changed: 15 additions & 4 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.54 1999/12/24 06:43:32 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.55 2000/01/09 00:26:23 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -302,6 +302,17 @@ _equalRelOptInfo(RelOptInfo *a, RelOptInfo *b)
302302
returnequali(a->relids,b->relids);
303303
}
304304

305+
staticbool
306+
_equalIndexOptInfo(IndexOptInfo*a,IndexOptInfo*b)
307+
{
308+
/* We treat IndexOptInfos as equal if they refer to the same index.
309+
* Is this sufficient?
310+
*/
311+
if (a->indexoid!=b->indexoid)
312+
return false;
313+
return true;
314+
}
315+
305316
staticbool
306317
_equalPathKeyItem(PathKeyItem*a,PathKeyItem*b)
307318
{
@@ -358,8 +369,6 @@ _equalJoinPath(JoinPath *a, JoinPath *b)
358369
{
359370
if (!_equalPath((Path*)a, (Path*)b))
360371
return false;
361-
if (!equal(a->pathinfo,b->pathinfo))
362-
return false;
363372
if (!equal(a->outerjoinpath,b->outerjoinpath))
364373
return false;
365374
if (!equal(a->innerjoinpath,b->innerjoinpath))
@@ -469,7 +478,6 @@ _equalRestrictInfo(RestrictInfo *a, RestrictInfo *b)
469478
{
470479
if (!equal(a->clause,b->clause))
471480
return false;
472-
/* do not check selectivity because of roundoff error worries */
473481
if (!equal(a->subclauseindices,b->subclauseindices))
474482
return false;
475483
if (a->mergejoinoperator!=b->mergejoinoperator)
@@ -792,6 +800,9 @@ equal(void *a, void *b)
792800
caseT_RelOptInfo:
793801
retval=_equalRelOptInfo(a,b);
794802
break;
803+
caseT_IndexOptInfo:
804+
retval=_equalIndexOptInfo(a,b);
805+
break;
795806
caseT_PathKeyItem:
796807
retval=_equalPathKeyItem(a,b);
797808
break;

‎src/backend/nodes/freefuncs.c

Lines changed: 24 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/Attic/freefuncs.c,v 1.29 1999/12/16 22:19:47 wieck Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/nodes/Attic/freefuncs.c,v 1.30 2000/01/09 00:26:23 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -730,11 +730,29 @@ _freeRelOptInfo(RelOptInfo *node)
730730

731731
freeObject(node->targetlist);
732732
freeObject(node->pathlist);
733-
/* is this right? cheapestpath will typically be a pointer into
733+
/*XXXis this right? cheapestpath will typically be a pointer into
734734
* pathlist, won't it?
735735
*/
736736
freeObject(node->cheapestpath);
737737

738+
freeObject(node->restrictinfo);
739+
freeObject(node->joininfo);
740+
freeObject(node->innerjoin);
741+
742+
pfree(node);
743+
}
744+
745+
/* ----------------
746+
*_freeIndexOptInfo
747+
* ----------------
748+
*/
749+
staticvoid
750+
_freeIndexOptInfo(IndexOptInfo*node)
751+
{
752+
/* ----------------
753+
*free remainder of node
754+
* ----------------
755+
*/
738756
if (node->classlist)
739757
pfree(node->classlist);
740758

@@ -746,10 +764,6 @@ _freeRelOptInfo(RelOptInfo *node)
746764

747765
freeObject(node->indpred);
748766

749-
freeObject(node->restrictinfo);
750-
freeObject(node->joininfo);
751-
freeObject(node->innerjoin);
752-
753767
pfree(node);
754768
}
755769

@@ -837,7 +851,6 @@ _freeTidPath(TidPath *node)
837851
staticvoid
838852
FreeJoinPathFields(JoinPath*node)
839853
{
840-
freeObject(node->pathinfo);
841854
freeObject(node->outerjoinpath);
842855
freeObject(node->innerjoinpath);
843856
}
@@ -936,7 +949,7 @@ _freeRestrictInfo(RestrictInfo *node)
936949
* ----------------
937950
*/
938951
freeObject(node->clause);
939-
/* this is certainly wrong?index RelOptInfos don't belong to
952+
/* this is certainly wrong?IndexOptInfos don't belong to
940953
* RestrictInfo...
941954
*/
942955
freeObject(node->subclauseindices);
@@ -1253,6 +1266,9 @@ freeObject(void *node)
12531266
caseT_Stream:
12541267
_freeStream(node);
12551268
break;
1269+
caseT_IndexOptInfo:
1270+
_freeIndexOptInfo(node);
1271+
break;
12561272

12571273
/*
12581274
* PARSE NODES

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp