*/
innerrelid = bms_singleton_member(sjinfo->min_righthand);
- /*
- * Compute the relid set for the join we are considering. We can
- * assume things are done in syntactic order.
- */
- joinrelids = bms_union(sjinfo->syn_lefthand, sjinfo->syn_righthand);
+ /* Compute the relid set for the join we are considering */
+ joinrelids = bms_union(sjinfo->min_lefthand, sjinfo->min_righthand);
if (sjinfo->ojrelid != 0)
joinrelids = bms_add_member(joinrelids, sjinfo->ojrelid);
if (!rel_supports_distinctness(root, innerrel))
return false;
- /* Compute the syntactic relid set for the join we are considering */
- inputrelids = bms_union(sjinfo->syn_lefthand, sjinfo->syn_righthand);
+ /* Compute the relid set for the join we are considering */
+ inputrelids = bms_union(sjinfo->min_lefthand, sjinfo->min_righthand);
Assert(sjinfo->ojrelid != 0);
joinrelids = bms_copy(inputrelids);
joinrelids = bms_add_member(joinrelids, sjinfo->ojrelid);
-> Seq Scan on d
(9 rows)
+-- join removal is not possible here
+explain (costs off)
+select 1 from a t1
+ left join (a t2 left join a t3 on t2.id = 1) on t2.id = 1;
+ QUERY PLAN
+--------------------------------------------------------
+ Nested Loop Left Join
+ -> Seq Scan on a t1
+ -> Materialize
+ -> Nested Loop Left Join
+ Join Filter: (t2.id = 1)
+ -> Index Only Scan using a_pkey on a t2
+ Index Cond: (id = 1)
+ -> Seq Scan on a t3
+(8 rows)
+
-- check join removal works when uniqueness of the join condition is enforced
-- by a UNION
explain (costs off)
select d.* from d left join (select distinct * from b) s
on d.a = s.id;
+-- join removal is not possible here
+explain (costs off)
+select 1 from a t1
+ left join (a t2 left join a t3 on t2.id = 1) on t2.id = 1;
+
-- check join removal works when uniqueness of the join condition is enforced
-- by a UNION
explain (costs off)