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

Commit4a8c5d0

Browse files
committed
Create executor and planner-backend support for decoupled heap and index
scans, using in-memory tuple ID bitmaps as the intermediary. The plannerfrontend (path creation and cost estimation) is not there yet, so noneof this code can be executed. I have tested it using some hacked plannercode that is far too ugly to see the light of day, however. Committingnow so that the bulk of the infrastructure changes go in before the treedrifts under me.
1 parent04ce41c commit4a8c5d0

30 files changed

+2783
-76
lines changed

‎src/backend/commands/explain.c

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994-5, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.132 2005/04/16 20:07:35 tgl Exp $
10+
* $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.133 2005/04/19 22:35:10 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -423,6 +423,12 @@ explain_outNode(StringInfo str,
423423
caseT_Append:
424424
pname="Append";
425425
break;
426+
caseT_BitmapAnd:
427+
pname="BitmapAnd";
428+
break;
429+
caseT_BitmapOr:
430+
pname="BitmapOr";
431+
break;
426432
caseT_NestLoop:
427433
switch (((NestLoop*)plan)->join.jointype)
428434
{
@@ -498,6 +504,12 @@ explain_outNode(StringInfo str,
498504
caseT_IndexScan:
499505
pname="Index Scan";
500506
break;
507+
caseT_BitmapIndexScan:
508+
pname="Bitmap Index Scan";
509+
break;
510+
caseT_BitmapHeapScan:
511+
pname="Bitmap Heap Scan";
512+
break;
501513
caseT_TidScan:
502514
pname="Tid Scan";
503515
break;
@@ -586,6 +598,7 @@ explain_outNode(StringInfo str,
586598
}
587599
/* FALL THRU */
588600
caseT_SeqScan:
601+
caseT_BitmapHeapScan:
589602
caseT_TidScan:
590603
if (((Scan*)plan)->scanrelid>0)
591604
{
@@ -606,6 +619,10 @@ explain_outNode(StringInfo str,
606619
quote_identifier(rte->eref->aliasname));
607620
}
608621
break;
622+
caseT_BitmapIndexScan:
623+
appendStringInfo(str," on %s",
624+
quote_identifier(get_rel_name(((BitmapIndexScan*)plan)->indxid)));
625+
break;
609626
caseT_SubqueryScan:
610627
if (((Scan*)plan)->scanrelid>0)
611628
{
@@ -696,6 +713,21 @@ explain_outNode(StringInfo str,
696713
outer_plan,
697714
str,indent,es);
698715
break;
716+
caseT_BitmapIndexScan:
717+
show_scan_qual(((BitmapIndexScan*)plan)->indxqualorig, false,
718+
"Index Cond",
719+
((Scan*)plan)->scanrelid,
720+
outer_plan,
721+
str,indent,es);
722+
break;
723+
caseT_BitmapHeapScan:
724+
/* XXX do we want to show this in production? */
725+
show_scan_qual(((BitmapHeapScan*)plan)->bitmapqualorig, false,
726+
"Recheck Cond",
727+
((Scan*)plan)->scanrelid,
728+
outer_plan,
729+
str,indent,es);
730+
/* FALL THRU */
699731
caseT_SeqScan:
700732
caseT_TidScan:
701733
caseT_SubqueryScan:
@@ -857,6 +889,54 @@ explain_outNode(StringInfo str,
857889
}
858890
}
859891

892+
if (IsA(plan,BitmapAnd))
893+
{
894+
BitmapAnd*bitmapandplan= (BitmapAnd*)plan;
895+
BitmapAndState*bitmapandstate= (BitmapAndState*)planstate;
896+
ListCell*lst;
897+
intj;
898+
899+
j=0;
900+
foreach(lst,bitmapandplan->bitmapplans)
901+
{
902+
Plan*subnode= (Plan*)lfirst(lst);
903+
904+
for (i=0;i<indent;i++)
905+
appendStringInfo(str," ");
906+
appendStringInfo(str," -> ");
907+
908+
explain_outNode(str,subnode,
909+
bitmapandstate->bitmapplans[j],
910+
NULL,
911+
indent+3,es);
912+
j++;
913+
}
914+
}
915+
916+
if (IsA(plan,BitmapOr))
917+
{
918+
BitmapOr*bitmaporplan= (BitmapOr*)plan;
919+
BitmapOrState*bitmaporstate= (BitmapOrState*)planstate;
920+
ListCell*lst;
921+
intj;
922+
923+
j=0;
924+
foreach(lst,bitmaporplan->bitmapplans)
925+
{
926+
Plan*subnode= (Plan*)lfirst(lst);
927+
928+
for (i=0;i<indent;i++)
929+
appendStringInfo(str," ");
930+
appendStringInfo(str," -> ");
931+
932+
explain_outNode(str,subnode,
933+
bitmaporstate->bitmapplans[j],
934+
NULL,
935+
indent+3,es);
936+
j++;
937+
}
938+
}
939+
860940
if (IsA(plan,SubqueryScan))
861941
{
862942
SubqueryScan*subqueryscan= (SubqueryScan*)plan;

‎src/backend/executor/Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Makefile for executor
55
#
66
# IDENTIFICATION
7-
# $PostgreSQL: pgsql/src/backend/executor/Makefile,v 1.22 2003/11/29 19:51:48 pgsql Exp $
7+
# $PostgreSQL: pgsql/src/backend/executor/Makefile,v 1.23 2005/04/19 22:35:11 tgl Exp $
88
#
99
#-------------------------------------------------------------------------
1010

@@ -14,7 +14,9 @@ include $(top_builddir)/src/Makefile.global
1414

1515
OBJS = execAmi.o execGrouping.o execJunk.o execMain.o\
1616
execProcnode.o execQual.o execScan.o execTuples.o\
17-
execUtils.o functions.o instrument.o nodeAppend.o nodeAgg.o nodeHash.o\
17+
execUtils.o functions.o instrument.o nodeAppend.o nodeAgg.o\
18+
nodeBitmapAnd.o nodeBitmapOr.o\
19+
nodeBitmapHeapscan.o nodeBitmapIndexscan.o nodeHash.o\
1820
nodeHashjoin.o nodeIndexscan.o nodeMaterial.o nodeMergejoin.o\
1921
nodeNestloop.o nodeFunctionscan.o nodeResult.o nodeSeqscan.o\
2022
nodeSetOp.o nodeSort.o nodeUnique.o nodeLimit.o nodeGroup.o\

‎src/backend/executor/execAmi.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
*$PostgreSQL: pgsql/src/backend/executor/execAmi.c,v 1.82 2004/12/31 21:59:45 pgsql Exp $
9+
*$PostgreSQL: pgsql/src/backend/executor/execAmi.c,v 1.83 2005/04/19 22:35:11 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -19,6 +19,10 @@
1919
#include"executor/instrument.h"
2020
#include"executor/nodeAgg.h"
2121
#include"executor/nodeAppend.h"
22+
#include"executor/nodeBitmapAnd.h"
23+
#include"executor/nodeBitmapHeapscan.h"
24+
#include"executor/nodeBitmapIndexscan.h"
25+
#include"executor/nodeBitmapOr.h"
2226
#include"executor/nodeFunctionscan.h"
2327
#include"executor/nodeGroup.h"
2428
#include"executor/nodeGroup.h"
@@ -107,6 +111,14 @@ ExecReScan(PlanState *node, ExprContext *exprCtxt)
107111
ExecReScanAppend((AppendState*)node,exprCtxt);
108112
break;
109113

114+
caseT_BitmapAndState:
115+
ExecReScanBitmapAnd((BitmapAndState*)node,exprCtxt);
116+
break;
117+
118+
caseT_BitmapOrState:
119+
ExecReScanBitmapOr((BitmapOrState*)node,exprCtxt);
120+
break;
121+
110122
caseT_SeqScanState:
111123
ExecSeqReScan((SeqScanState*)node,exprCtxt);
112124
break;
@@ -115,6 +127,14 @@ ExecReScan(PlanState *node, ExprContext *exprCtxt)
115127
ExecIndexReScan((IndexScanState*)node,exprCtxt);
116128
break;
117129

130+
caseT_BitmapIndexScanState:
131+
ExecBitmapIndexReScan((BitmapIndexScanState*)node,exprCtxt);
132+
break;
133+
134+
caseT_BitmapHeapScanState:
135+
ExecBitmapHeapReScan((BitmapHeapScanState*)node,exprCtxt);
136+
break;
137+
118138
caseT_TidScanState:
119139
ExecTidReScan((TidScanState*)node,exprCtxt);
120140
break;
@@ -380,6 +400,7 @@ ExecMayReturnRawTuples(PlanState *node)
380400
/* Table scan nodes */
381401
caseT_SeqScanState:
382402
caseT_IndexScanState:
403+
caseT_BitmapHeapScanState:
383404
caseT_TidScanState:
384405
caseT_SubqueryScanState:
385406
caseT_FunctionScanState:

‎src/backend/executor/execProcnode.c

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*
1313
*
1414
* IDENTIFICATION
15-
* $PostgreSQL: pgsql/src/backend/executor/execProcnode.c,v 1.49 2005/04/16 20:07:35 tgl Exp $
15+
* $PostgreSQL: pgsql/src/backend/executor/execProcnode.c,v 1.50 2005/04/19 22:35:11 tgl Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -81,6 +81,10 @@
8181
#include"executor/instrument.h"
8282
#include"executor/nodeAgg.h"
8383
#include"executor/nodeAppend.h"
84+
#include"executor/nodeBitmapAnd.h"
85+
#include"executor/nodeBitmapHeapscan.h"
86+
#include"executor/nodeBitmapIndexscan.h"
87+
#include"executor/nodeBitmapOr.h"
8488
#include"executor/nodeFunctionscan.h"
8589
#include"executor/nodeGroup.h"
8690
#include"executor/nodeHash.h"
@@ -140,6 +144,14 @@ ExecInitNode(Plan *node, EState *estate)
140144
result= (PlanState*)ExecInitAppend((Append*)node,estate);
141145
break;
142146

147+
caseT_BitmapAnd:
148+
result= (PlanState*)ExecInitBitmapAnd((BitmapAnd*)node,estate);
149+
break;
150+
151+
caseT_BitmapOr:
152+
result= (PlanState*)ExecInitBitmapOr((BitmapOr*)node,estate);
153+
break;
154+
143155
/*
144156
* scan nodes
145157
*/
@@ -151,6 +163,14 @@ ExecInitNode(Plan *node, EState *estate)
151163
result= (PlanState*)ExecInitIndexScan((IndexScan*)node,estate);
152164
break;
153165

166+
caseT_BitmapIndexScan:
167+
result= (PlanState*)ExecInitBitmapIndexScan((BitmapIndexScan*)node,estate);
168+
break;
169+
170+
caseT_BitmapHeapScan:
171+
result= (PlanState*)ExecInitBitmapHeapScan((BitmapHeapScan*)node,estate);
172+
break;
173+
154174
caseT_TidScan:
155175
result= (PlanState*)ExecInitTidScan((TidScan*)node,estate);
156176
break;
@@ -290,6 +310,10 @@ ExecProcNode(PlanState *node)
290310
result=ExecAppend((AppendState*)node);
291311
break;
292312

313+
/* BitmapAndState does not yield tuples */
314+
315+
/* BitmapOrState does not yield tuples */
316+
293317
/*
294318
* scan nodes
295319
*/
@@ -301,6 +325,12 @@ ExecProcNode(PlanState *node)
301325
result=ExecIndexScan((IndexScanState*)node);
302326
break;
303327

328+
/* BitmapIndexScanState does not yield tuples */
329+
330+
caseT_BitmapHeapScanState:
331+
result=ExecBitmapHeapScan((BitmapHeapScanState*)node);
332+
break;
333+
304334
caseT_TidScanState:
305335
result=ExecTidScan((TidScanState*)node);
306336
break;
@@ -409,6 +439,18 @@ MultiExecProcNode(PlanState *node)
409439
result=MultiExecHash((HashState*)node);
410440
break;
411441

442+
caseT_BitmapIndexScanState:
443+
result=MultiExecBitmapIndexScan((BitmapIndexScanState*)node);
444+
break;
445+
446+
caseT_BitmapAndState:
447+
result=MultiExecBitmapAnd((BitmapAndState*)node);
448+
break;
449+
450+
caseT_BitmapOrState:
451+
result=MultiExecBitmapOr((BitmapOrState*)node);
452+
break;
453+
412454
default:
413455
elog(ERROR,"unrecognized node type: %d", (int)nodeTag(node));
414456
result=NULL;
@@ -442,6 +484,12 @@ ExecCountSlotsNode(Plan *node)
442484
caseT_Append:
443485
returnExecCountSlotsAppend((Append*)node);
444486

487+
caseT_BitmapAnd:
488+
returnExecCountSlotsBitmapAnd((BitmapAnd*)node);
489+
490+
caseT_BitmapOr:
491+
returnExecCountSlotsBitmapOr((BitmapOr*)node);
492+
445493
/*
446494
* scan nodes
447495
*/
@@ -451,6 +499,12 @@ ExecCountSlotsNode(Plan *node)
451499
caseT_IndexScan:
452500
returnExecCountSlotsIndexScan((IndexScan*)node);
453501

502+
caseT_BitmapIndexScan:
503+
returnExecCountSlotsBitmapIndexScan((BitmapIndexScan*)node);
504+
505+
caseT_BitmapHeapScan:
506+
returnExecCountSlotsBitmapHeapScan((BitmapHeapScan*)node);
507+
454508
caseT_TidScan:
455509
returnExecCountSlotsTidScan((TidScan*)node);
456510

@@ -554,6 +608,14 @@ ExecEndNode(PlanState *node)
554608
ExecEndAppend((AppendState*)node);
555609
break;
556610

611+
caseT_BitmapAndState:
612+
ExecEndBitmapAnd((BitmapAndState*)node);
613+
break;
614+
615+
caseT_BitmapOrState:
616+
ExecEndBitmapOr((BitmapOrState*)node);
617+
break;
618+
557619
/*
558620
* scan nodes
559621
*/
@@ -565,6 +627,14 @@ ExecEndNode(PlanState *node)
565627
ExecEndIndexScan((IndexScanState*)node);
566628
break;
567629

630+
caseT_BitmapIndexScanState:
631+
ExecEndBitmapIndexScan((BitmapIndexScanState*)node);
632+
break;
633+
634+
caseT_BitmapHeapScanState:
635+
ExecEndBitmapHeapScan((BitmapHeapScanState*)node);
636+
break;
637+
568638
caseT_TidScanState:
569639
ExecEndTidScan((TidScanState*)node);
570640
break;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp