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

Commit9359694

Browse files
committed
Be more realistic about plans involving Materialize nodes: take their
cost into account while planning.
1 parent829cedc commit9359694

File tree

19 files changed

+320
-160
lines changed

19 files changed

+320
-160
lines changed

‎src/backend/executor/execAmi.c

Lines changed: 41 additions & 19 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: execAmi.c,v 1.64 2002/06/20 20:29:27 momjian Exp $
9+
*$Id: execAmi.c,v 1.65 2002/11/30 05:21:01 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -170,14 +170,10 @@ ExecReScan(Plan *node, ExprContext *exprCtxt, Plan *parent)
170170
}
171171
}
172172

173-
/* ----------------------------------------------------------------
174-
*ExecMarkPos
175-
*
176-
*Marks the current scan position.
173+
/*
174+
* ExecMarkPos
177175
*
178-
*XXX Needs to be extended to include all the node types,
179-
*or at least all the ones that can be directly below a mergejoin.
180-
* ----------------------------------------------------------------
176+
* Marks the current scan position.
181177
*/
182178
void
183179
ExecMarkPos(Plan*node)
@@ -192,6 +188,10 @@ ExecMarkPos(Plan *node)
192188
ExecIndexMarkPos((IndexScan*)node);
193189
break;
194190

191+
caseT_TidScan:
192+
ExecTidMarkPos((TidScan*)node);
193+
break;
194+
195195
caseT_FunctionScan:
196196
ExecFunctionMarkPos((FunctionScan*)node);
197197
break;
@@ -204,10 +204,6 @@ ExecMarkPos(Plan *node)
204204
ExecSortMarkPos((Sort*)node);
205205
break;
206206

207-
caseT_TidScan:
208-
ExecTidMarkPos((TidScan*)node);
209-
break;
210-
211207
default:
212208
/* don't make hard error unless caller asks to restore... */
213209
elog(LOG,"ExecMarkPos: node type %d not supported",
@@ -216,14 +212,10 @@ ExecMarkPos(Plan *node)
216212
}
217213
}
218214

219-
/* ----------------------------------------------------------------
220-
*ExecRestrPos
221-
*
222-
*restores the scan position previously saved with ExecMarkPos()
215+
/*
216+
* ExecRestrPos
223217
*
224-
*XXX Needs to be extended to include all the node types,
225-
*or at least all the ones that can be directly below a mergejoin.
226-
* ----------------------------------------------------------------
218+
* restores the scan position previously saved with ExecMarkPos()
227219
*/
228220
void
229221
ExecRestrPos(Plan*node)
@@ -238,6 +230,10 @@ ExecRestrPos(Plan *node)
238230
ExecIndexRestrPos((IndexScan*)node);
239231
break;
240232

233+
caseT_TidScan:
234+
ExecTidRestrPos((TidScan*)node);
235+
break;
236+
241237
caseT_FunctionScan:
242238
ExecFunctionRestrPos((FunctionScan*)node);
243239
break;
@@ -256,3 +252,29 @@ ExecRestrPos(Plan *node)
256252
break;
257253
}
258254
}
255+
256+
/*
257+
* ExecSupportsMarkRestore - does a plan type support mark/restore?
258+
*
259+
* XXX Ideally, all plan node types would support mark/restore, and this
260+
* wouldn't be needed. For now, this had better match the routines above.
261+
*/
262+
bool
263+
ExecSupportsMarkRestore(NodeTagplantype)
264+
{
265+
switch (plantype)
266+
{
267+
caseT_SeqScan:
268+
caseT_IndexScan:
269+
caseT_TidScan:
270+
caseT_FunctionScan:
271+
caseT_Material:
272+
caseT_Sort:
273+
return true;
274+
275+
default:
276+
break;
277+
}
278+
279+
return false;
280+
}

‎src/backend/executor/nodeSeqscan.c

Lines changed: 3 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/executor/nodeSeqscan.c,v 1.37 2002/09/04 20:31:18 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/executor/nodeSeqscan.c,v 1.38 2002/11/30 05:21:01 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -19,9 +19,8 @@
1919
*ExecInitSeqScancreates and initializes a seqscan node.
2020
*ExecEndSeqScanreleases any storage allocated.
2121
*ExecSeqReScanrescans the relation
22-
*ExecMarkPosmarks scan position
23-
*ExecRestrPosrestores scan position
24-
*
22+
*ExecSeqMarkPosmarks scan position
23+
*ExecSeqRestrPosrestores scan position
2524
*/
2625
#include"postgres.h"
2726

‎src/backend/executor/nodeTidscan.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/executor/nodeTidscan.c,v 1.26 2002/09/04 20:31:18 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/executor/nodeTidscan.c,v 1.27 2002/11/30 05:21:01 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
1515
/*
1616
* INTERFACE ROUTINES
1717
*
18-
*ExecTidScanscans a relation using tids
18+
*ExecTidScanscans a relation using tids
1919
*ExecInitTidScancreates and initializes state info.
2020
*ExecTidReScanrescans the tid relation.
2121
*ExecEndTidScanreleases all storage.
2222
*ExecTidMarkPosmarks scan position.
23-
*
23+
*ExecTidRestrPosrestores scan position.
2424
*/
2525
#include"postgres.h"
2626

@@ -345,7 +345,6 @@ ExecTidMarkPos(TidScan *node)
345345
tidstate->tss_MarkTidPtr=tidstate->tss_TidPtr;
346346
}
347347

348-
#ifdefNOT_USED
349348
/* ----------------------------------------------------------------
350349
*ExecTidRestrPos
351350
*
@@ -363,7 +362,6 @@ ExecTidRestrPos(TidScan *node)
363362
tidstate=node->tidstate;
364363
tidstate->tss_TidPtr=tidstate->tss_MarkTidPtr;
365364
}
366-
#endif
367365

368366
/* ----------------------------------------------------------------
369367
*ExecInitTidScan

‎src/backend/nodes/copyfuncs.c

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* Portions Copyright (c) 1994, Regents of the University of California
1616
*
1717
* IDENTIFICATION
18-
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.224 2002/11/3000:08:16 tgl Exp $
18+
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.225 2002/11/3005:21:01 tgl Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -1142,6 +1142,27 @@ _copyResultPath(ResultPath *from)
11421142
returnnewnode;
11431143
}
11441144

1145+
/*
1146+
* _copyMaterialPath
1147+
*/
1148+
staticMaterialPath*
1149+
_copyMaterialPath(MaterialPath*from)
1150+
{
1151+
MaterialPath*newnode=makeNode(MaterialPath);
1152+
1153+
/*
1154+
* copy node superclass fields
1155+
*/
1156+
CopyPathFields((Path*)from, (Path*)newnode);
1157+
1158+
/*
1159+
* copy remainder of node
1160+
*/
1161+
COPY_NODE_FIELD(subpath);
1162+
1163+
returnnewnode;
1164+
}
1165+
11451166
/*
11461167
* CopyJoinPathFields
11471168
*
@@ -2739,6 +2760,9 @@ copyObject(void *from)
27392760
caseT_RelOptInfo:
27402761
retval=_copyRelOptInfo(from);
27412762
break;
2763+
caseT_IndexOptInfo:
2764+
retval=_copyIndexOptInfo(from);
2765+
break;
27422766
caseT_Path:
27432767
retval=_copyPath(from);
27442768
break;
@@ -2754,6 +2778,9 @@ copyObject(void *from)
27542778
caseT_ResultPath:
27552779
retval=_copyResultPath(from);
27562780
break;
2781+
caseT_MaterialPath:
2782+
retval=_copyMaterialPath(from);
2783+
break;
27572784
caseT_NestPath:
27582785
retval=_copyNestPath(from);
27592786
break;
@@ -2772,9 +2799,6 @@ copyObject(void *from)
27722799
caseT_JoinInfo:
27732800
retval=_copyJoinInfo(from);
27742801
break;
2775-
caseT_IndexOptInfo:
2776-
retval=_copyIndexOptInfo(from);
2777-
break;
27782802
caseT_InnerIndexscanInfo:
27792803
retval=_copyInnerIndexscanInfo(from);
27802804
break;

‎src/backend/nodes/equalfuncs.c

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* Portions Copyright (c) 1994, Regents of the University of California
2121
*
2222
* IDENTIFICATION
23-
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.169 2002/11/2521:29:36 tgl Exp $
23+
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.170 2002/11/30 05:21:01 tgl Exp $
2424
*
2525
*-------------------------------------------------------------------------
2626
*/
@@ -456,6 +456,16 @@ _equalResultPath(ResultPath *a, ResultPath *b)
456456
return true;
457457
}
458458

459+
staticbool
460+
_equalMaterialPath(MaterialPath*a,MaterialPath*b)
461+
{
462+
if (!_equalPath((Path*)a, (Path*)b))
463+
return false;
464+
COMPARE_NODE_FIELD(subpath);
465+
466+
return true;
467+
}
468+
459469
staticbool
460470
_equalJoinPath(JoinPath*a,JoinPath*b)
461471
{
@@ -1704,12 +1714,27 @@ equal(void *a, void *b)
17041714
caseT_RelOptInfo:
17051715
retval=_equalRelOptInfo(a,b);
17061716
break;
1717+
caseT_IndexOptInfo:
1718+
retval=_equalIndexOptInfo(a,b);
1719+
break;
17071720
caseT_Path:
17081721
retval=_equalPath(a,b);
17091722
break;
17101723
caseT_IndexPath:
17111724
retval=_equalIndexPath(a,b);
17121725
break;
1726+
caseT_TidPath:
1727+
retval=_equalTidPath(a,b);
1728+
break;
1729+
caseT_AppendPath:
1730+
retval=_equalAppendPath(a,b);
1731+
break;
1732+
caseT_ResultPath:
1733+
retval=_equalResultPath(a,b);
1734+
break;
1735+
caseT_MaterialPath:
1736+
retval=_equalMaterialPath(a,b);
1737+
break;
17131738
caseT_NestPath:
17141739
retval=_equalNestPath(a,b);
17151740
break;
@@ -1731,18 +1756,6 @@ equal(void *a, void *b)
17311756
caseT_InnerIndexscanInfo:
17321757
retval=_equalInnerIndexscanInfo(a,b);
17331758
break;
1734-
caseT_TidPath:
1735-
retval=_equalTidPath(a,b);
1736-
break;
1737-
caseT_AppendPath:
1738-
retval=_equalAppendPath(a,b);
1739-
break;
1740-
caseT_ResultPath:
1741-
retval=_equalResultPath(a,b);
1742-
break;
1743-
caseT_IndexOptInfo:
1744-
retval=_equalIndexOptInfo(a,b);
1745-
break;
17461759

17471760
caseT_List:
17481761
{

‎src/backend/nodes/outfuncs.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.184 2002/11/3000:08:16 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.185 2002/11/3005:21:02 tgl Exp $
1212
*
1313
* NOTES
1414
* Every node type that can appear in stored rules' parsetrees *must*
@@ -1010,6 +1010,16 @@ _outResultPath(StringInfo str, ResultPath *node)
10101010
WRITE_NODE_FIELD(constantqual);
10111011
}
10121012

1013+
staticvoid
1014+
_outMaterialPath(StringInfostr,MaterialPath*node)
1015+
{
1016+
WRITE_NODE_TYPE("MATERIALPATH");
1017+
1018+
_outPathInfo(str, (Path*)node);
1019+
1020+
WRITE_NODE_FIELD(subpath);
1021+
}
1022+
10131023
staticvoid
10141024
_outNestPath(StringInfostr,NestPath*node)
10151025
{
@@ -1557,6 +1567,9 @@ _outNode(StringInfo str, void *obj)
15571567
caseT_ResultPath:
15581568
_outResultPath(str,obj);
15591569
break;
1570+
caseT_MaterialPath:
1571+
_outMaterialPath(str,obj);
1572+
break;
15601573
caseT_NestPath:
15611574
_outNestPath(str,obj);
15621575
break;

‎src/backend/optimizer/README

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,8 @@ RelOptInfo - a relation or joined relations
259259
IndexPath - index scans
260260
TidPath - scan by CTID
261261
AppendPath - append multiple subpaths together
262-
ResultPath - a Result plan (used for variable-free tlist or qual)
262+
ResultPath - a Result plan node (used for variable-free tlist or qual)
263+
MaterialPath - a Material plan node
263264
NestPath - nested-loop joins
264265
MergePath - merge joins
265266
HashPath - hash joins

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp