summaryrefslogtreecommitdiff
path: root/src/include/nodes
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2015-12-11 15:52:16 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2015-12-11 15:52:39 -0500
commitdc4518814ecc2ae319c4d1679ee079e47dbd78e9 (patch)
tree5158f9a835583bc58b7f715784608c5d4b48cdf3 /src/include/nodes
parent12a54c888cf7bd9c37c4ce420e84cb52debe0184 (diff)
Get rid of the planner's LateralJoinInfo data structure.
I originally modeled this data structure on SpecialJoinInfo, but after commit acfcd45cacb6df23 that looks like a pretty poor decision. All we really need is relid sets identifying laterally-referenced rels; and most of the time, what we want to know about includes indirect lateral references, a case the LateralJoinInfo data was unsuited to compute with any efficiency. The previous commit redefined RelOptInfo.lateral_relids as the transitive closure of lateral references, so that it easily supports checking indirect references. For the places where we really do want just direct references, add a new RelOptInfo field direct_lateral_relids, which is easily set up as a copy of lateral_relids before we perform the transitive closure calculation. Then we can just drop lateral_info_list and LateralJoinInfo and the supporting code. This makes the planner's handling of lateral references noticeably more efficient, and shorter too. Such a change can't be back-patched into stable branches for fear of breaking extensions that might be looking at the planner's data structures; but it seems not too late to push it into 9.5, so I've done so.
Diffstat (limited to 'src/include/nodes')
-rw-r--r--src/include/nodes/nodes.h1
-rw-r--r--src/include/nodes/relation.h41
2 files changed, 2 insertions, 40 deletions
diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h
index 574b72df183..91505c81d9c 100644
--- a/src/include/nodes/nodes.h
+++ b/src/include/nodes/nodes.h
@@ -244,7 +244,6 @@ typedef enum NodeTag
T_RestrictInfo,
T_PlaceHolderVar,
T_SpecialJoinInfo,
- T_LateralJoinInfo,
T_AppendRelInfo,
T_PlaceHolderInfo,
T_MinMaxAggInfo,
diff --git a/src/include/nodes/relation.h b/src/include/nodes/relation.h
index 2918b07abbe..5e6c34db99b 100644
--- a/src/include/nodes/relation.h
+++ b/src/include/nodes/relation.h
@@ -213,8 +213,6 @@ typedef struct PlannerInfo
List *join_info_list; /* list of SpecialJoinInfos */
- List *lateral_info_list; /* list of LateralJoinInfos */
-
List *append_rel_list; /* list of AppendRelInfos */
List *rowMarks; /* list of PlanRowMarks */
@@ -344,6 +342,7 @@ typedef struct PlannerInfo
* (no duplicates) output from relation; NULL if not yet requested
* cheapest_parameterized_paths - best paths for their parameterizations;
* always includes cheapest_total_path, even if that's unparameterized
+ * direct_lateral_relids - rels this rel has direct LATERAL references to
* lateral_relids - required outer rels for LATERAL, as a Relids set
* (includes both direct and indirect lateral references)
*
@@ -452,6 +451,7 @@ typedef struct RelOptInfo
/* parameterization information needed for both base rels and join rels */
/* (see also lateral_vars and lateral_referencers) */
+ Relids direct_lateral_relids; /* rels directly laterally referenced */
Relids lateral_relids; /* minimum parameterization of rel */
/* information about a base rel (not set for join rels!) */
@@ -1434,43 +1434,6 @@ typedef struct SpecialJoinInfo
} SpecialJoinInfo;
/*
- * "Lateral join" info.
- *
- * Lateral references constrain the join order in a way that's somewhat like
- * outer joins, though different in detail. We construct a LateralJoinInfo
- * for each lateral cross-reference, placing them in the PlannerInfo node's
- * lateral_info_list.
- *
- * For unflattened LATERAL RTEs, we generate LateralJoinInfo(s) in which
- * lateral_rhs is the relid of the LATERAL baserel, and lateral_lhs is a set
- * of relids of baserels it references, all of which must be present on the
- * LHS to compute a parameter needed by the RHS. Typically, lateral_lhs is
- * a singleton, but it can include multiple rels if the RHS references a
- * PlaceHolderVar with a multi-rel ph_eval_at level. We disallow joining to
- * only part of the LHS in such cases, since that would result in a join tree
- * with no convenient place to compute the PHV.
- *
- * When an appendrel contains lateral references (eg "LATERAL (SELECT x.col1
- * UNION ALL SELECT y.col2)"), the LateralJoinInfos reference the parent
- * baserel not the member otherrels, since it is the parent relid that is
- * considered for joining purposes.
- *
- * If any LATERAL RTEs were flattened into the parent query, it is possible
- * that the query now contains PlaceHolderVars containing lateral references,
- * representing expressions that need to be evaluated at particular spots in
- * the jointree but contain lateral references to Vars from elsewhere. These
- * give rise to LateralJoinInfos in which lateral_rhs is the evaluation point
- * of a PlaceHolderVar and lateral_lhs is the set of lateral rels it needs.
- */
-
-typedef struct LateralJoinInfo
-{
- NodeTag type;
- Relids lateral_lhs; /* rels needed to compute a lateral value */
- Relids lateral_rhs; /* rel where lateral value is needed */
-} LateralJoinInfo;
-
-/*
* Append-relation info.
*
* When we expand an inheritable table or a UNION-ALL subselect into an