Re: Convert NOT IN sublinks to anti-joins when safe

From: Richard Guo <guofenglinux(at)gmail(dot)com>
To: Japin Li <japinli(at)hotmail(dot)com>
Cc: Pg Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Convert NOT IN sublinks to anti-joins when safe
Date: 2026-03-09 04:01:14
Message-ID: CAMbWs48K=K06kQ3FVn6mzsk5pgEbFdUJkShY_xwN4ANj+Zwp0A@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Mar 8, 2026 at 5:16 PM Richard Guo <guofenglinux(at)gmail(dot)com> wrote:
> Attached is an updated version of the patch that replaces foreach with
> foreach_ptr or foreach_node accordingly. Nothing else has changed.
>
> I plan to do one more round of self-review on this. Unless there are
> any further thoughts or concerns, I'm hoping to commit this in a week
> or two. Please let me know if anyone spots anything else I might have
> missed.

I just finished a final self-review and noticed a subtle issue in
query_outputs_are_not_nullable(). When preparing a target expression
for the non-nullability check, the previous code flattened join
aliases Vars before grouping Vars. However, because the parser
processes FROM/JOIN clauses before the GROUP BY clause, a grouping Var
can actually wrap a join alias Var, not the reverse. So we should
flatten grouping Vars first.

Attached is an updated patch that fixes that issue. I plan to commit
this in a week or two, barring any objections.

- Richard

Attachment Content-Type Size
v6-0001-Convert-NOT-IN-sublinks-to-anti-joins-when-safe.patch application/octet-stream 61.6 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Henson Choi 2026-03-09 04:02:02 Re: Row pattern recognition
Previous Message jian he 2026-03-09 03:48:26 Re: Emitting JSON to file using COPY TO