summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2007-04-21 21:01:45 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2007-04-21 21:01:45 +0000
commitafcf09dd9034f24e34dd46f69938882ab5b103d2 (patch)
tree497edd9a542b2bc9312afe2f39341f7b95a892c5 /src/include
parentac7e6c0665a377fb0e4e5b12cfc762c1b14e425e (diff)
Some further performance tweaks for planning large inheritance trees that
are mostly excluded by constraints: do the CE test a bit earlier to save some adjust_appendrel_attrs() work on excluded children, and arrange to use array indexing rather than rt_fetch() to fetch RTEs in the main body of the planner. The latter is something I'd wanted to do for awhile anyway, but seeing list_nth_cell() as 35% of the runtime gets one's attention.
Diffstat (limited to 'src/include')
-rw-r--r--src/include/nodes/relation.h20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/include/nodes/relation.h b/src/include/nodes/relation.h
index 2c26d121ef4..57af937830f 100644
--- a/src/include/nodes/relation.h
+++ b/src/include/nodes/relation.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/nodes/relation.h,v 1.140 2007/04/06 22:33:43 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/nodes/relation.h,v 1.141 2007/04/21 21:01:45 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -109,6 +109,14 @@ typedef struct PlannerInfo
int simple_rel_array_size; /* allocated size of array */
/*
+ * simple_rte_array is the same length as simple_rel_array and holds
+ * pointers to the associated rangetable entries. This lets us avoid
+ * rt_fetch(), which can be a bit slow once large inheritance sets have
+ * been expanded.
+ */
+ RangeTblEntry **simple_rte_array; /* rangetable as an array */
+
+ /*
* join_rel_list is a list of all join-relation RelOptInfos we have
* considered in this planning run. For small problems we just scan the
* list to do lookups, but when there are many join relations we build a
@@ -167,6 +175,16 @@ typedef struct PlannerInfo
} PlannerInfo;
+/*
+ * In places where it's known that simple_rte_array[] must have been prepared
+ * already, we just index into it to fetch RTEs. In code that might be
+ * executed before or after entering query_planner(), use this macro.
+ */
+#define planner_rt_fetch(rti, root) \
+ ((root)->simple_rte_array ? (root)->simple_rte_array[rti] : \
+ rt_fetch(rti, (root)->parse->rtable))
+
+
/*----------
* RelOptInfo
* Per-relation information for planning/optimization