mirror of
https://github.com/postgres/postgres.git
synced 2025-07-15 19:21:59 +03:00
Don't scan partitioned tables.
Partitioned tables do not contain any data; only their unpartitioned descendents need to be scanned. However, the partitioned tables still need to be locked, even though they're not scanned. To make that work, Append and MergeAppend relations now need to carry a list of (unscanned) partitioned relations that must be locked, and InitPlan must lock all partitioned result relations. Aside from the obvious advantage of avoiding some work at execution time, this has two other advantages. First, it may improve the planner's decision-making in some cases since the empty relation might throw things off. Second, it paves the way to getting rid of the storage for partitioned tables altogether. Amit Langote, reviewed by me. Discussion: http://postgr.es/m/6837c359-45c4-8044-34d1-736756335a15@lab.ntt.co.jp
This commit is contained in:
@ -90,6 +90,7 @@ _copyPlannedStmt(const PlannedStmt *from)
|
||||
COPY_NODE_FIELD(planTree);
|
||||
COPY_NODE_FIELD(rtable);
|
||||
COPY_NODE_FIELD(resultRelations);
|
||||
COPY_NODE_FIELD(nonleafResultRelations);
|
||||
COPY_NODE_FIELD(subplans);
|
||||
COPY_BITMAPSET_FIELD(rewindPlanIDs);
|
||||
COPY_NODE_FIELD(rowMarks);
|
||||
@ -200,6 +201,7 @@ _copyModifyTable(const ModifyTable *from)
|
||||
COPY_SCALAR_FIELD(operation);
|
||||
COPY_SCALAR_FIELD(canSetTag);
|
||||
COPY_SCALAR_FIELD(nominalRelation);
|
||||
COPY_NODE_FIELD(partitioned_rels);
|
||||
COPY_NODE_FIELD(resultRelations);
|
||||
COPY_SCALAR_FIELD(resultRelIndex);
|
||||
COPY_NODE_FIELD(plans);
|
||||
@ -235,6 +237,7 @@ _copyAppend(const Append *from)
|
||||
/*
|
||||
* copy remainder of node
|
||||
*/
|
||||
COPY_NODE_FIELD(partitioned_rels);
|
||||
COPY_NODE_FIELD(appendplans);
|
||||
|
||||
return newnode;
|
||||
@ -256,6 +259,7 @@ _copyMergeAppend(const MergeAppend *from)
|
||||
/*
|
||||
* copy remainder of node
|
||||
*/
|
||||
COPY_NODE_FIELD(partitioned_rels);
|
||||
COPY_NODE_FIELD(mergeplans);
|
||||
COPY_SCALAR_FIELD(numCols);
|
||||
COPY_POINTER_FIELD(sortColIdx, from->numCols * sizeof(AttrNumber));
|
||||
@ -2204,6 +2208,20 @@ _copyAppendRelInfo(const AppendRelInfo *from)
|
||||
return newnode;
|
||||
}
|
||||
|
||||
/*
|
||||
* _copyPartitionedChildRelInfo
|
||||
*/
|
||||
static PartitionedChildRelInfo *
|
||||
_copyPartitionedChildRelInfo(const PartitionedChildRelInfo *from)
|
||||
{
|
||||
PartitionedChildRelInfo *newnode = makeNode(PartitionedChildRelInfo);
|
||||
|
||||
COPY_SCALAR_FIELD(parent_relid);
|
||||
COPY_NODE_FIELD(child_rels);
|
||||
|
||||
return newnode;
|
||||
}
|
||||
|
||||
/*
|
||||
* _copyPlaceHolderInfo
|
||||
*/
|
||||
@ -4894,6 +4912,9 @@ copyObject(const void *from)
|
||||
case T_AppendRelInfo:
|
||||
retval = _copyAppendRelInfo(from);
|
||||
break;
|
||||
case T_PartitionedChildRelInfo:
|
||||
retval = _copyPartitionedChildRelInfo(from);
|
||||
break;
|
||||
case T_PlaceHolderInfo:
|
||||
retval = _copyPlaceHolderInfo(from);
|
||||
break;
|
||||
|
Reference in New Issue
Block a user