public inbox for [email protected]  
help / color / mirror / Atom feed
From: Richard Guo <[email protected]>
To: Tom Lane <[email protected]>
Cc: PostgreSQL-development <[email protected]>
Subject: Re: Retiring is_pushed_down
Date: Tue, 14 Jan 2025 19:41:42 +0900
Message-ID: <CAMbWs4-2JwuXUXF8AVQw=6UE8sfOwqe_mdfDDX+wpXD6s9VVvw@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <CAMbWs49pDTmHbgjXa4xjxbA+pY=7ebZ=YUg1waQqQw8DERgQ-g@mail.gmail.com>
	<[email protected]>

On Fri, Sep 27, 2024 at 5:06 AM Tom Lane <[email protected]> wrote:
> So I'm worried that the point about lateral refs is still a problem
> in your version.  To be clear, the hazard is that if a WHERE clause
> ends up getting placed at an outer join that's higher than any of
> the OJs specifically listed in its required_relids, we'd misinterpret
> it as being a join clause for that OJ although it should be a filter
> clause.

Sorry it took me so long to get back to this thread.

I don't quite understand how this could happen.  If a WHERE clause is
placed on an outer join but does not include the outer join's ojrelid
in its required_relids, then it must only refer to the non-nullable
side.  In that case, we should be able to push this clause down to the
non-nullable side of the outer join.

Perhaps this issue could occur with a lateral join, but I wasn't able
to construct such a query.  I wonder if you happen to have an example
on hand.

> If we went this route, we'd basically be replacing the is_pushed_down
> field with a JoinDomain field, which is surely not simpler.  But it
> seems more crisply defined and perhaps more amenable to my long-term
> desire to be able to use the EquivalenceClass machinery with outer
> join clauses.  (The idea being that an EC would describe equalities
> that hold within a JoinDomain, but not necessarily elsewhere.)

Exactly.  At first, I thought that with JoinDomain, we could avoid
checking if a clause's required_relids exceeds the scope of the join
in RINFO_IS_PUSHED_DOWN, so RINFO_IS_PUSHED_DOWN can be reduced to:

#define RINFO_IS_PUSHED_DOWN(rinfo, joinrelids) \
    (bms_is_subset(joinrelids, (rinfo)->jdomain->jd_relids))

However, if the outer join was commuted with another one according to
Identity 3, simply checking whether the JoinDomain is above or below
the outer join is not sufficient.  We'll still need to check if the
clause's required_relids exceeds the scope of the join, as we do
currently.

But I agree that changing to use JoinDomain is more amenable to the
goal of using ECs with outer join clauses.

Thanks
Richard






view thread (9+ messages)

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: Retiring is_pushed_down
  In-Reply-To: <CAMbWs4-2JwuXUXF8AVQw=6UE8sfOwqe_mdfDDX+wpXD6s9VVvw@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox