Re: Planner : anti-join on left joins

From: wenhui qiu <qiuwenhuifx(at)gmail(dot)com>
To: Richard Guo <guofenglinux(at)gmail(dot)com>
Cc: Tender Wang <tndrwang(at)gmail(dot)com>, Nicolas Adenis-Lamarre <nicolas(dot)adenis(dot)lamarre(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: Planner : anti-join on left joins
Date: 2026-01-10 09:13:28
Message-ID: CAGjGUA+8uaR412ZZ0iNAHLn7-qMMKPdrTQxAZrnJvT6s0pMJ8w@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

HI Richard
> The logic 'strict for b.z' effectively applies only if b.z happens to
> be the join key b.y. To avoid confusion, I have rephrased the comment
> to make this distinction clear.

> I've also included a commit message, refined the comments throughout,
> and added test cases in the updated patch.

> Feedback and testing are very welcome.
The v6 path correctly extends LEFT→ANTI join reduction using NOT NULL
constraints, carefully accounting for nullability introduced by lower-level
outer joins; the approach is sound, well-contained, and adequately covered
by regression tests. LGTM

Thanks

On Tue, Jan 6, 2026 at 4:24 PM Richard Guo <guofenglinux(at)gmail(dot)com> wrote:

> On Tue, Jan 6, 2026 at 10:47 AM Tender Wang <tndrwang(at)gmail(dot)com> wrote:
> > ...
> > SELECT ... FROM a LEFT JOIN b ON (a.x = b.y) WHERE b.z IS NULL;
> > * If we can prove that b.z must be non-null for any matching row, either
> > * because the join clause is strict for b.z, or because b.z is defined
> NOT
> > * NULL by table constraints,
> > ...
> > How can the strict join clause influence b.z?
>
> The logic 'strict for b.z' effectively applies only if b.z happens to
> be the join key b.y. To avoid confusion, I have rephrased the comment
> to make this distinction clear.
>
> I've also included a commit message, refined the comments throughout,
> and added test cases in the updated patch.
>
> Feedback and testing are very welcome.
>
> - Richard
>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Henson Choi 2026-01-10 09:20:16 Re: Row pattern recognition
Previous Message John Naylor 2026-01-10 08:46:12 Re: Correct comment wording in extension.c