1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +03:00

Create executor and planner-backend support for decoupled heap and index

scans, using in-memory tuple ID bitmaps as the intermediary.  The planner
frontend (path creation and cost estimation) is not there yet, so none
of this code can be executed.  I have tested it using some hacked planner
code that is far too ugly to see the light of day, however.  Committing
now so that the bulk of the infrastructure changes go in before the tree
drifts under me.
This commit is contained in:
Tom Lane
2005-04-19 22:35:18 +00:00
parent 04ce41ca62
commit 4a8c5d0375
30 changed files with 2783 additions and 76 deletions

View File

@ -15,7 +15,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.301 2005/04/07 01:51:38 neilc Exp $
* $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.302 2005/04/19 22:35:13 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -148,6 +148,48 @@ _copyAppend(Append *from)
return newnode;
}
/*
* _copyBitmapAnd
*/
static BitmapAnd *
_copyBitmapAnd(BitmapAnd *from)
{
BitmapAnd *newnode = makeNode(BitmapAnd);
/*
* copy node superclass fields
*/
CopyPlanFields((Plan *) from, (Plan *) newnode);
/*
* copy remainder of node
*/
COPY_NODE_FIELD(bitmapplans);
return newnode;
}
/*
* _copyBitmapOr
*/
static BitmapOr *
_copyBitmapOr(BitmapOr *from)
{
BitmapOr *newnode = makeNode(BitmapOr);
/*
* copy node superclass fields
*/
CopyPlanFields((Plan *) from, (Plan *) newnode);
/*
* copy remainder of node
*/
COPY_NODE_FIELD(bitmapplans);
return newnode;
}
/*
* CopyScanFields
@ -222,6 +264,52 @@ _copyIndexScan(IndexScan *from)
return newnode;
}
/*
* _copyBitmapIndexScan
*/
static BitmapIndexScan *
_copyBitmapIndexScan(BitmapIndexScan *from)
{
BitmapIndexScan *newnode = makeNode(BitmapIndexScan);
/*
* copy node superclass fields
*/
CopyScanFields((Scan *) from, (Scan *) newnode);
/*
* copy remainder of node
*/
COPY_SCALAR_FIELD(indxid);
COPY_NODE_FIELD(indxqual);
COPY_NODE_FIELD(indxqualorig);
COPY_NODE_FIELD(indxstrategy);
COPY_NODE_FIELD(indxsubtype);
return newnode;
}
/*
* _copyBitmapHeapScan
*/
static BitmapHeapScan *
_copyBitmapHeapScan(BitmapHeapScan *from)
{
BitmapHeapScan *newnode = makeNode(BitmapHeapScan);
/*
* copy node superclass fields
*/
CopyScanFields((Scan *) from, (Scan *) newnode);
/*
* copy remainder of node
*/
COPY_NODE_FIELD(bitmapqualorig);
return newnode;
}
/*
* _copyTidScan
*/
@ -2598,6 +2686,12 @@ copyObject(void *from)
case T_Append:
retval = _copyAppend(from);
break;
case T_BitmapAnd:
retval = _copyBitmapAnd(from);
break;
case T_BitmapOr:
retval = _copyBitmapOr(from);
break;
case T_Scan:
retval = _copyScan(from);
break;
@ -2607,6 +2701,12 @@ copyObject(void *from)
case T_IndexScan:
retval = _copyIndexScan(from);
break;
case T_BitmapIndexScan:
retval = _copyBitmapIndexScan(from);
break;
case T_BitmapHeapScan:
retval = _copyBitmapHeapScan(from);
break;
case T_TidScan:
retval = _copyTidScan(from);
break;

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.246 2005/04/06 16:34:05 tgl Exp $
* $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.247 2005/04/19 22:35:14 tgl Exp $
*
* NOTES
* Every node type that can appear in stored rules' parsetrees *must*
@ -308,6 +308,26 @@ _outAppend(StringInfo str, Append *node)
WRITE_BOOL_FIELD(isTarget);
}
static void
_outBitmapAnd(StringInfo str, BitmapAnd *node)
{
WRITE_NODE_TYPE("BITMAPAND");
_outPlanInfo(str, (Plan *) node);
WRITE_NODE_FIELD(bitmapplans);
}
static void
_outBitmapOr(StringInfo str, BitmapOr *node)
{
WRITE_NODE_TYPE("BITMAPOR");
_outPlanInfo(str, (Plan *) node);
WRITE_NODE_FIELD(bitmapplans);
}
static void
_outScan(StringInfo str, Scan *node)
{
@ -340,6 +360,30 @@ _outIndexScan(StringInfo str, IndexScan *node)
WRITE_ENUM_FIELD(indxorderdir, ScanDirection);
}
static void
_outBitmapIndexScan(StringInfo str, BitmapIndexScan *node)
{
WRITE_NODE_TYPE("BITMAPINDEXSCAN");
_outScanInfo(str, (Scan *) node);
WRITE_OID_FIELD(indxid);
WRITE_NODE_FIELD(indxqual);
WRITE_NODE_FIELD(indxqualorig);
WRITE_NODE_FIELD(indxstrategy);
WRITE_NODE_FIELD(indxsubtype);
}
static void
_outBitmapHeapScan(StringInfo str, BitmapHeapScan *node)
{
WRITE_NODE_TYPE("BITMAPHEAPSCAN");
_outScanInfo(str, (Scan *) node);
WRITE_NODE_FIELD(bitmapqualorig);
}
static void
_outTidScan(StringInfo str, TidScan *node)
{
@ -968,9 +1012,6 @@ _outPath(StringInfo str, Path *node)
_outPathInfo(str, (Path *) node);
}
/*
* IndexPath is a subclass of Path.
*/
static void
_outIndexPath(StringInfo str, IndexPath *node)
{
@ -986,6 +1027,18 @@ _outIndexPath(StringInfo str, IndexPath *node)
WRITE_FLOAT_FIELD(rows, "%.0f");
}
static void
_outBitmapHeapPath(StringInfo str, BitmapHeapPath *node)
{
WRITE_NODE_TYPE("BITMAPHEAPPATH");
_outPathInfo(str, (Path *) node);
WRITE_NODE_FIELD(bitmapqual);
WRITE_BOOL_FIELD(isjoininner);
WRITE_FLOAT_FIELD(rows, "%.0f");
}
static void
_outTidPath(StringInfo str, TidPath *node)
{
@ -1620,6 +1673,12 @@ _outNode(StringInfo str, void *obj)
case T_Append:
_outAppend(str, obj);
break;
case T_BitmapAnd:
_outBitmapAnd(str, obj);
break;
case T_BitmapOr:
_outBitmapOr(str, obj);
break;
case T_Scan:
_outScan(str, obj);
break;
@ -1629,6 +1688,12 @@ _outNode(StringInfo str, void *obj)
case T_IndexScan:
_outIndexScan(str, obj);
break;
case T_BitmapIndexScan:
_outBitmapIndexScan(str, obj);
break;
case T_BitmapHeapScan:
_outBitmapHeapScan(str, obj);
break;
case T_TidScan:
_outTidScan(str, obj);
break;
@ -1783,6 +1848,9 @@ _outNode(StringInfo str, void *obj)
case T_IndexPath:
_outIndexPath(str, obj);
break;
case T_BitmapHeapPath:
_outBitmapHeapPath(str, obj);
break;
case T_TidPath:
_outTidPath(str, obj);
break;

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/nodes/print.c,v 1.74 2005/04/06 16:34:05 tgl Exp $
* $PostgreSQL: pgsql/src/backend/nodes/print.c,v 1.75 2005/04/19 22:35:15 tgl Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
@ -493,12 +493,20 @@ plannode_type(Plan *p)
return "RESULT";
case T_Append:
return "APPEND";
case T_BitmapAnd:
return "BITMAPAND";
case T_BitmapOr:
return "BITMAPOR";
case T_Scan:
return "SCAN";
case T_SeqScan:
return "SEQSCAN";
case T_IndexScan:
return "INDEXSCAN";
case T_BitmapIndexScan:
return "BITMAPINDEXSCAN";
case T_BitmapHeapScan:
return "BITMAPHEAPSCAN";
case T_TidScan:
return "TIDSCAN";
case T_SubqueryScan:
@ -551,7 +559,8 @@ print_plan_recursive(Plan *p, Query *parsetree, int indentLevel, char *label)
p->startup_cost, p->total_cost,
p->plan_rows, p->plan_width);
if (IsA(p, Scan) ||
IsA(p, SeqScan))
IsA(p, SeqScan) ||
IsA(p, BitmapHeapScan))
{
RangeTblEntry *rte;
@ -584,27 +593,48 @@ print_plan_recursive(Plan *p, Query *parsetree, int indentLevel, char *label)
if (IsA(p, Append))
{
ListCell *l;
int whichplan = 0;
Append *appendplan = (Append *) p;
foreach(l, appendplan->appendplans)
{
Plan *subnode = (Plan *) lfirst(l);
/*
* I don't think we need to fiddle with the range table here,
* bjm
*/
print_plan_recursive(subnode, parsetree, indentLevel + 3, "a: ");
}
}
whichplan++;
if (IsA(p, BitmapAnd))
{
ListCell *l;
BitmapAnd *bitmapandplan = (BitmapAnd *) p;
foreach(l, bitmapandplan->bitmapplans)
{
Plan *subnode = (Plan *) lfirst(l);
print_plan_recursive(subnode, parsetree, indentLevel + 3, "a: ");
}
}
if (IsA(p, BitmapOr))
{
ListCell *l;
BitmapOr *bitmaporplan = (BitmapOr *) p;
foreach(l, bitmaporplan->bitmapplans)
{
Plan *subnode = (Plan *) lfirst(l);
print_plan_recursive(subnode, parsetree, indentLevel + 3, "a: ");
}
}
}
/* print_plan
prints just the plan node types */
/*
* print_plan
*
* prints just the plan node types
*/
void
print_plan(Plan *p, Query *parsetree)
{

View File

@ -23,7 +23,7 @@
* Copyright (c) 2003-2005, PostgreSQL Global Development Group
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/nodes/tidbitmap.c,v 1.1 2005/04/17 22:24:02 tgl Exp $
* $PostgreSQL: pgsql/src/backend/nodes/tidbitmap.c,v 1.2 2005/04/19 22:35:15 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -160,7 +160,7 @@ tbm_create(long maxbytes)
hash_ctl.hash = tag_hash;
hash_ctl.hcxt = CurrentMemoryContext;
tbm->pagetable = hash_create("TIDBitmap",
nbuckets,
128, /* start small and extend */
&hash_ctl,
HASH_ELEM | HASH_FUNCTION | HASH_CONTEXT);