mirror of
https://github.com/postgres/postgres.git
synced 2025-06-26 12:21:12 +03:00
Get rid of the planner's LateralJoinInfo data structure.
I originally modeled this data structure on SpecialJoinInfo, but after
commit acfcd45cac
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.
This commit is contained in:
@ -2066,20 +2066,6 @@ _copySpecialJoinInfo(const SpecialJoinInfo *from)
|
||||
return newnode;
|
||||
}
|
||||
|
||||
/*
|
||||
* _copyLateralJoinInfo
|
||||
*/
|
||||
static LateralJoinInfo *
|
||||
_copyLateralJoinInfo(const LateralJoinInfo *from)
|
||||
{
|
||||
LateralJoinInfo *newnode = makeNode(LateralJoinInfo);
|
||||
|
||||
COPY_BITMAPSET_FIELD(lateral_lhs);
|
||||
COPY_BITMAPSET_FIELD(lateral_rhs);
|
||||
|
||||
return newnode;
|
||||
}
|
||||
|
||||
/*
|
||||
* _copyAppendRelInfo
|
||||
*/
|
||||
@ -4519,9 +4505,6 @@ copyObject(const void *from)
|
||||
case T_SpecialJoinInfo:
|
||||
retval = _copySpecialJoinInfo(from);
|
||||
break;
|
||||
case T_LateralJoinInfo:
|
||||
retval = _copyLateralJoinInfo(from);
|
||||
break;
|
||||
case T_AppendRelInfo:
|
||||
retval = _copyAppendRelInfo(from);
|
||||
break;
|
||||
|
@ -845,15 +845,6 @@ _equalSpecialJoinInfo(const SpecialJoinInfo *a, const SpecialJoinInfo *b)
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
_equalLateralJoinInfo(const LateralJoinInfo *a, const LateralJoinInfo *b)
|
||||
{
|
||||
COMPARE_BITMAPSET_FIELD(lateral_lhs);
|
||||
COMPARE_BITMAPSET_FIELD(lateral_rhs);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
_equalAppendRelInfo(const AppendRelInfo *a, const AppendRelInfo *b)
|
||||
{
|
||||
@ -2860,9 +2851,6 @@ equal(const void *a, const void *b)
|
||||
case T_SpecialJoinInfo:
|
||||
retval = _equalSpecialJoinInfo(a, b);
|
||||
break;
|
||||
case T_LateralJoinInfo:
|
||||
retval = _equalLateralJoinInfo(a, b);
|
||||
break;
|
||||
case T_AppendRelInfo:
|
||||
retval = _equalAppendRelInfo(a, b);
|
||||
break;
|
||||
|
@ -1847,7 +1847,6 @@ _outPlannerInfo(StringInfo str, const PlannerInfo *node)
|
||||
WRITE_NODE_FIELD(right_join_clauses);
|
||||
WRITE_NODE_FIELD(full_join_clauses);
|
||||
WRITE_NODE_FIELD(join_info_list);
|
||||
WRITE_NODE_FIELD(lateral_info_list);
|
||||
WRITE_NODE_FIELD(append_rel_list);
|
||||
WRITE_NODE_FIELD(rowMarks);
|
||||
WRITE_NODE_FIELD(placeholder_list);
|
||||
@ -1892,6 +1891,7 @@ _outRelOptInfo(StringInfo str, const RelOptInfo *node)
|
||||
WRITE_NODE_FIELD(cheapest_total_path);
|
||||
WRITE_NODE_FIELD(cheapest_unique_path);
|
||||
WRITE_NODE_FIELD(cheapest_parameterized_paths);
|
||||
WRITE_BITMAPSET_FIELD(direct_lateral_relids);
|
||||
WRITE_BITMAPSET_FIELD(lateral_relids);
|
||||
WRITE_UINT_FIELD(relid);
|
||||
WRITE_OID_FIELD(reltablespace);
|
||||
@ -2056,15 +2056,6 @@ _outSpecialJoinInfo(StringInfo str, const SpecialJoinInfo *node)
|
||||
WRITE_NODE_FIELD(semi_rhs_exprs);
|
||||
}
|
||||
|
||||
static void
|
||||
_outLateralJoinInfo(StringInfo str, const LateralJoinInfo *node)
|
||||
{
|
||||
WRITE_NODE_TYPE("LATERALJOININFO");
|
||||
|
||||
WRITE_BITMAPSET_FIELD(lateral_lhs);
|
||||
WRITE_BITMAPSET_FIELD(lateral_rhs);
|
||||
}
|
||||
|
||||
static void
|
||||
_outAppendRelInfo(StringInfo str, const AppendRelInfo *node)
|
||||
{
|
||||
@ -3355,9 +3346,6 @@ _outNode(StringInfo str, const void *obj)
|
||||
case T_SpecialJoinInfo:
|
||||
_outSpecialJoinInfo(str, obj);
|
||||
break;
|
||||
case T_LateralJoinInfo:
|
||||
_outLateralJoinInfo(str, obj);
|
||||
break;
|
||||
case T_AppendRelInfo:
|
||||
_outAppendRelInfo(str, obj);
|
||||
break;
|
||||
|
Reference in New Issue
Block a user