summaryrefslogtreecommitdiff
path: root/src/include/nodes/relation.h
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2007-01-22 20:00:40 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2007-01-22 20:00:40 +0000
commit4f06c688c7b4726ac9f5279d4a9f32408eec5356 (patch)
tree6bf75e7cdf88035988d4bf414e56889ea00d87b1 /src/include/nodes/relation.h
parent45e07369383ff1631dea76cae6d222c2f16ad70e (diff)
Put back planner's ability to cache the results of mergejoinscansel(),
which I had removed in the first cut of the EquivalenceClass rewrite to simplify that patch a little. But it's still important --- in a four-way join problem mergejoinscansel() was eating about 40% of the planning time according to gprof. Also, improve the EquivalenceClass code to re-use join RestrictInfos rather than generating fresh ones for each join considered. This saves some memory space but more importantly improves the effectiveness of caching planning info in RestrictInfos.
Diffstat (limited to 'src/include/nodes/relation.h')
-rw-r--r--src/include/nodes/relation.h24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/include/nodes/relation.h b/src/include/nodes/relation.h
index a83a20d21b5..c67c067a5f2 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.133 2007/01/20 20:45:40 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/nodes/relation.h,v 1.134 2007/01/22 20:00:40 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -397,6 +397,7 @@ typedef struct EquivalenceClass
List *ec_opfamilies; /* btree operator family OIDs */
List *ec_members; /* list of EquivalenceMembers */
List *ec_sources; /* list of generating RestrictInfos */
+ List *ec_derives; /* list of derived RestrictInfos */
Relids ec_relids; /* all relids appearing in ec_members */
bool ec_has_const; /* any pseudoconstants in ec_members? */
bool ec_has_volatile; /* the (sole) member is a volatile expr */
@@ -890,6 +891,9 @@ typedef struct RestrictInfo
/* cache space for mergeclause processing; NULL if not yet set */
EquivalenceClass *left_ec; /* EquivalenceClass containing lefthand */
EquivalenceClass *right_ec; /* EquivalenceClass containing righthand */
+ EquivalenceMember *left_em; /* EquivalenceMember for lefthand */
+ EquivalenceMember *right_em; /* EquivalenceMember for righthand */
+ List *scansel_cache; /* list of MergeScanSelCache structs */
/* transient workspace for use while considering a specific join path */
bool outer_is_left; /* T = outer var on left, F = on right */
@@ -903,6 +907,24 @@ typedef struct RestrictInfo
} RestrictInfo;
/*
+ * Since mergejoinscansel() is a relatively expensive function, and would
+ * otherwise be invoked many times while planning a large join tree,
+ * we go out of our way to cache its results. Each mergejoinable
+ * RestrictInfo carries a list of the specific sort orderings that have
+ * been considered for use with it, and the resulting selectivities.
+ */
+typedef struct MergeScanSelCache
+{
+ /* Ordering details (cache lookup key) */
+ Oid opfamily; /* btree opfamily defining the ordering */
+ int strategy; /* sort direction (ASC or DESC) */
+ bool nulls_first; /* do NULLs come before normal values? */
+ /* Results */
+ Selectivity leftscansel; /* scan fraction for clause left side */
+ Selectivity rightscansel; /* scan fraction for clause right side */
+} MergeScanSelCache;
+
+/*
* Inner indexscan info.
*
* An inner indexscan is one that uses one or more joinclauses as index