Re: Planner : anti-join on left joins

From: Richard Guo <guofenglinux(at)gmail(dot)com>
To: Tender Wang <tndrwang(at)gmail(dot)com>
Cc: 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-06 08:23:55
Message-ID: CAMbWs4-m4-50RxF4cMnCvguAscAHr=ZS9GNzy+jgDjHM++0P4w@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

Attachment Content-Type Size
v6-0001-Reduce-LEFT-JOIN-to-ANTI-JOIN-using-NOT-NULL-cons.patch application/octet-stream 15.0 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jonathan Gonzalez V. 2026-01-06 08:40:20 Re: Make PGOAUTHCAFILE in libpq-oauth work out of debug mode
Previous Message Jakub Wartak 2026-01-06 08:18:56 Re: [PATCH] Add Windows support for backtrace_functions (MSVC only)