File tree 3 files changed +41
-7
lines changed
3 files changed +41
-7
lines changed Original file line number Diff line number Diff line change @@ -1903,13 +1903,6 @@ deconstruct_distribute_oj_quals(PlannerInfo *root,
1903
1903
int save_last_rinfo_serial ;
1904
1904
ListCell * lc ;
1905
1905
1906
- /*
1907
- * Put any OJ relids that were removed from min_righthand back into
1908
- * ojscope, else distribute_qual_to_rels will complain.
1909
- */
1910
- ojscope = bms_join (ojscope , bms_intersect (sjinfo -> commute_below ,
1911
- sjinfo -> syn_righthand ));
1912
-
1913
1906
/* Identify the outer joins this one commutes with */
1914
1907
joins_above = sjinfo -> commute_above_r ;
1915
1908
joins_below = bms_intersect (sjinfo -> commute_below ,
Original file line number Diff line number Diff line change @@ -4982,6 +4982,32 @@ select id from a where id in (
4982
4982
-> Seq Scan on b
4983
4983
(5 rows)
4984
4984
4985
+ -- check optimization with oddly-nested outer joins
4986
+ explain (costs off)
4987
+ select a1.id from
4988
+ (a a1 left join a a2 on true)
4989
+ left join
4990
+ (a a3 left join a a4 on a3.id = a4.id)
4991
+ on a2.id = a3.id;
4992
+ QUERY PLAN
4993
+ ------------------------------
4994
+ Nested Loop Left Join
4995
+ -> Seq Scan on a a1
4996
+ -> Materialize
4997
+ -> Seq Scan on a a2
4998
+ (4 rows)
4999
+
5000
+ explain (costs off)
5001
+ select a1.id from
5002
+ (a a1 left join a a2 on a1.id = a2.id)
5003
+ left join
5004
+ (a a3 left join a a4 on a3.id = a4.id)
5005
+ on a2.id = a3.id;
5006
+ QUERY PLAN
5007
+ ------------------
5008
+ Seq Scan on a a1
5009
+ (1 row)
5010
+
4985
5011
-- check that join removal works for a left join when joining a subquery
4986
5012
-- that is guaranteed to be unique by its GROUP BY clause
4987
5013
explain (costs off)
Original file line number Diff line number Diff line change @@ -1770,6 +1770,21 @@ select id from a where id in (
1770
1770
select b .id from b left join c on b .id = c .id
1771
1771
);
1772
1772
1773
+ -- check optimization with oddly-nested outer joins
1774
+ explain (costs off)
1775
+ select a1 .id from
1776
+ (a a1 left join a a2 on true)
1777
+ left join
1778
+ (a a3 left join a a4 on a3 .id = a4 .id )
1779
+ on a2 .id = a3 .id ;
1780
+
1781
+ explain (costs off)
1782
+ select a1 .id from
1783
+ (a a1 left join a a2 on a1 .id = a2 .id )
1784
+ left join
1785
+ (a a3 left join a a4 on a3 .id = a4 .id )
1786
+ on a2 .id = a3 .id ;
1787
+
1773
1788
-- check that join removal works for a left join when joining a subquery
1774
1789
-- that is guaranteed to be unique by its GROUP BY clause
1775
1790
explain (costs off)
You can’t perform that action at this time.
0 commit comments