From: | Richard Guo <guofenglinux(at)gmail(dot)com> |
---|---|
To: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Tighten a little bit the computation of potential commutator pairs |
Date: | 2023-06-02 07:05:31 |
Message-ID: | CAMbWs4_9NXHCwwTwsw6njyJ4u_wOejGwPjDaaWZFg1LKAhg6_Q@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
In make_outerjoininfo, I think we can additionally check a property
that's needed to apply OJ identity 3: the lower OJ in the RHS cannot be
a member of inner_join_rels because we do not try to commute with any of
lower inner joins.
--- a/src/backend/optimizer/plan/initsplan.c
+++ b/src/backend/optimizer/plan/initsplan.c
@@ -1593,7 +1593,8 @@ make_outerjoininfo(PlannerInfo *root,
}
else if (jointype == JOIN_LEFT &&
otherinfo->jointype == JOIN_LEFT &&
- otherinfo->lhs_strict)
+ otherinfo->lhs_strict &&
+ !bms_is_member(otherinfo->ojrelid, inner_join_rels))
{
/* Identity 3 applies, so remove the ordering restriction */
min_righthand = bms_del_member(min_righthand,
This check will help to avoid bogus commute_xxx bits in some cases, such
as in query
explain (costs off)
select * from a left join
(b left join c on b.i = c.i inner join d on true)
on a.i = b.i;
It will help us know that the b/c join and the join of a cannot commute
and thus save us from generating cloned clauses for 'b.i = c.i'. Plus,
it is very cheap. So I think it's worth doing. Any thoughts?
Thanks
Richard
From | Date | Subject | |
---|---|---|---|
Next Message | Ants Aasma | 2023-06-02 08:01:42 | Re: Do we want a hashset type? |
Previous Message | Tristan Partin | 2023-06-02 04:06:04 | Re: [PATCH] Missing dep on Catalog.pm in meson rules |