Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 8a1468a

Browse files
committed
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.
1 parent 097df38 commit 8a1468a

File tree

18 files changed

+1045
-511
lines changed

18 files changed

+1045
-511
lines changed

src/backend/nodes/copyfuncs.c

+23-1
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-
* $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.324 2005/12/28 01:29:59 tgl Exp $
18+
* $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.325 2006/01/31 21:39:23 tgl Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -1322,6 +1322,25 @@ _copyInClauseInfo(InClauseInfo *from)
13221322
return newnode;
13231323
}
13241324

1325+
/*
1326+
* _copyAppendRelInfo
1327+
*/
1328+
static AppendRelInfo *
1329+
_copyAppendRelInfo(AppendRelInfo *from)
1330+
{
1331+
AppendRelInfo *newnode = makeNode(AppendRelInfo);
1332+
1333+
COPY_SCALAR_FIELD(parent_relid);
1334+
COPY_SCALAR_FIELD(child_relid);
1335+
COPY_SCALAR_FIELD(parent_reltype);
1336+
COPY_SCALAR_FIELD(child_reltype);
1337+
COPY_NODE_FIELD(col_mappings);
1338+
COPY_NODE_FIELD(translated_vars);
1339+
COPY_SCALAR_FIELD(parent_reloid);
1340+
1341+
return newnode;
1342+
}
1343+
13251344
/* ****************************************************************
13261345
* parsenodes.h copy functions
13271346
* ****************************************************************
@@ -2945,6 +2964,9 @@ copyObject(void *from)
29452964
case T_InClauseInfo:
29462965
retval = _copyInClauseInfo(from);
29472966
break;
2967+
case T_AppendRelInfo:
2968+
retval = _copyAppendRelInfo(from);
2969+
break;
29482970

29492971
/*
29502972
* VALUE NODES

src/backend/nodes/equalfuncs.c

+18-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* Portions Copyright (c) 1994, Regents of the University of California
1919
*
2020
* IDENTIFICATION
21-
* $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.260 2005/12/28 01:29:59 tgl Exp $
21+
* $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.261 2006/01/31 21:39:23 tgl Exp $
2222
*
2323
*-------------------------------------------------------------------------
2424
*/
@@ -644,6 +644,20 @@ _equalInClauseInfo(InClauseInfo *a, InClauseInfo *b)
644644
return true;
645645
}
646646

647+
static bool
648+
_equalAppendRelInfo(AppendRelInfo *a, AppendRelInfo *b)
649+
{
650+
COMPARE_SCALAR_FIELD(parent_relid);
651+
COMPARE_SCALAR_FIELD(child_relid);
652+
COMPARE_SCALAR_FIELD(parent_reltype);
653+
COMPARE_SCALAR_FIELD(child_reltype);
654+
COMPARE_NODE_FIELD(col_mappings);
655+
COMPARE_NODE_FIELD(translated_vars);
656+
COMPARE_SCALAR_FIELD(parent_reloid);
657+
658+
return true;
659+
}
660+
647661

648662
/*
649663
* Stuff from parsenodes.h
@@ -1984,6 +1998,9 @@ equal(void *a, void *b)
19841998
case T_InClauseInfo:
19851999
retval = _equalInClauseInfo(a, b);
19862000
break;
2001+
case T_AppendRelInfo:
2002+
retval = _equalAppendRelInfo(a, b);
2003+
break;
19872004
case T_List:
19882005
case T_IntList:
19892006
case T_OidList:

src/backend/nodes/outfuncs.c

+21-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.266 2005/12/28 01:29:59 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.267 2006/01/31 21:39:23 tgl Exp $
1212
*
1313
* NOTES
1414
* Every node type that can appear in stored rules' parsetrees *must*
@@ -1178,6 +1178,7 @@ _outPlannerInfo(StringInfo str, PlannerInfo *node)
11781178
WRITE_NODE_FIELD(full_join_clauses);
11791179
WRITE_NODE_FIELD(oj_info_list);
11801180
WRITE_NODE_FIELD(in_info_list);
1181+
WRITE_NODE_FIELD(append_rel_list);
11811182
WRITE_NODE_FIELD(query_pathkeys);
11821183
WRITE_NODE_FIELD(group_pathkeys);
11831184
WRITE_NODE_FIELD(sort_pathkeys);
@@ -1204,8 +1205,8 @@ _outRelOptInfo(StringInfo str, RelOptInfo *node)
12041205
WRITE_NODE_FIELD(cheapest_unique_path);
12051206
WRITE_UINT_FIELD(relid);
12061207
WRITE_ENUM_FIELD(rtekind, RTEKind);
1207-
WRITE_UINT_FIELD(min_attr);
1208-
WRITE_UINT_FIELD(max_attr);
1208+
WRITE_INT_FIELD(min_attr);
1209+
WRITE_INT_FIELD(max_attr);
12091210
WRITE_NODE_FIELD(indexlist);
12101211
WRITE_UINT_FIELD(pages);
12111212
WRITE_FLOAT_FIELD(tuples, "%.0f");
@@ -1295,6 +1296,20 @@ _outInClauseInfo(StringInfo str, InClauseInfo *node)
12951296
WRITE_NODE_FIELD(sub_targetlist);
12961297
}
12971298

1299+
static void
1300+
_outAppendRelInfo(StringInfo str, AppendRelInfo *node)
1301+
{
1302+
WRITE_NODE_TYPE("APPENDRELINFO");
1303+
1304+
WRITE_UINT_FIELD(parent_relid);
1305+
WRITE_UINT_FIELD(child_relid);
1306+
WRITE_OID_FIELD(parent_reltype);
1307+
WRITE_OID_FIELD(child_reltype);
1308+
WRITE_NODE_FIELD(col_mappings);
1309+
WRITE_NODE_FIELD(translated_vars);
1310+
WRITE_OID_FIELD(parent_reloid);
1311+
}
1312+
12981313
/*****************************************************************************
12991314
*
13001315
* Stuff from parsenodes.h.
@@ -2048,6 +2063,9 @@ _outNode(StringInfo str, void *obj)
20482063
case T_InClauseInfo:
20492064
_outInClauseInfo(str, obj);
20502065
break;
2066+
case T_AppendRelInfo:
2067+
_outAppendRelInfo(str, obj);
2068+
break;
20512069

20522070
case T_CreateStmt:
20532071
_outCreateStmt(str, obj);

0 commit comments

Comments
 (0)