Re: Retiring is_pushed_down

From: Richard Guo <guofenglinux(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Retiring is_pushed_down
Date: 2025-01-14 10:41:42
Message-ID: CAMbWs4-2JwuXUXF8AVQw=6UE8sfOwqe_mdfDDX+wpXD6s9VVvw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Sep 27, 2024 at 5:06 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> 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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2025-01-14 10:47:21 Re: Modern SHA2- based password hashes for pgcrypto
Previous Message Peter Eisentraut 2025-01-14 09:58:20 Re: Virtual generated columns