mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
Restructure planner's handling of inheritance. Rather than processing
inheritance trees on-the-fly, which pretty well constrained us to considering only one way of planning inheritance, expand inheritance sets during the planner prep phase, and build a side data structure that can be consulted later to find which RTEs are members of which inheritance sets. As proof of concept, use the data structure to plan joins against inheritance sets more efficiently: we can now use indexes on the set members in inner-indexscan joins. (The generated plans could be improved further, but it'll take some executor changes.) This data structure will also support handling UNION ALL subqueries in the same way as inheritance sets, but that aspect of it isn't finished yet.
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/rewrite/rewriteManip.c,v 1.95 2006/01/06 20:11:12 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/rewrite/rewriteManip.c,v 1.96 2006/01/31 21:39:24 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -183,6 +183,17 @@ OffsetVarNodes_walker(Node *node, OffsetVarNodes_context *context)
|
||||
}
|
||||
/* fall through to examine children */
|
||||
}
|
||||
if (IsA(node, AppendRelInfo))
|
||||
{
|
||||
AppendRelInfo *appinfo = (AppendRelInfo *) node;
|
||||
|
||||
if (context->sublevels_up == 0)
|
||||
{
|
||||
appinfo->parent_relid += context->offset;
|
||||
appinfo->child_relid += context->offset;
|
||||
}
|
||||
/* fall through to examine children */
|
||||
}
|
||||
if (IsA(node, Query))
|
||||
{
|
||||
/* Recurse into subselects */
|
||||
@@ -323,6 +334,19 @@ ChangeVarNodes_walker(Node *node, ChangeVarNodes_context *context)
|
||||
}
|
||||
/* fall through to examine children */
|
||||
}
|
||||
if (IsA(node, AppendRelInfo))
|
||||
{
|
||||
AppendRelInfo *appinfo = (AppendRelInfo *) node;
|
||||
|
||||
if (context->sublevels_up == 0)
|
||||
{
|
||||
if (appinfo->parent_relid == context->rt_index)
|
||||
appinfo->parent_relid = context->new_index;
|
||||
if (appinfo->child_relid == context->rt_index)
|
||||
appinfo->child_relid = context->new_index;
|
||||
}
|
||||
/* fall through to examine children */
|
||||
}
|
||||
if (IsA(node, Query))
|
||||
{
|
||||
/* Recurse into subselects */
|
||||
@@ -527,16 +551,11 @@ rangeTableEntry_used_walker(Node *node,
|
||||
return true;
|
||||
/* fall through to examine children */
|
||||
}
|
||||
if (IsA(node, InClauseInfo))
|
||||
{
|
||||
InClauseInfo *ininfo = (InClauseInfo *) node;
|
||||
/* Shouldn't need to handle planner auxiliary nodes here */
|
||||
Assert(!IsA(node, OuterJoinInfo));
|
||||
Assert(!IsA(node, InClauseInfo));
|
||||
Assert(!IsA(node, AppendRelInfo));
|
||||
|
||||
if (context->sublevels_up == 0 &&
|
||||
(bms_is_member(context->rt_index, ininfo->lefthand) ||
|
||||
bms_is_member(context->rt_index, ininfo->righthand)))
|
||||
return true;
|
||||
/* fall through to examine children */
|
||||
}
|
||||
if (IsA(node, Query))
|
||||
{
|
||||
/* Recurse into subselects */
|
||||
|
Reference in New Issue
Block a user