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

From: wenhui qiu <qiuwenhuifx(at)gmail(dot)com>
To: Japin Li <japinli(at)hotmail(dot)com>
Cc: Richard Guo <guofenglinux(at)gmail(dot)com>, 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 07:38:11
Message-ID: CAGjGUA+BTnX3oxB9+W4+wHtOTGcDtNGR78GeFnFBXkwhcTbQMw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

HI
> 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.

Thanks for updating the patch. v6 path LGTM.

Thanks

On Mon, Mar 9, 2026 at 1:14 PM Japin Li <japinli(at)hotmail(dot)com> wrote:

> On Sun, 08 Mar 2026 at 17:16, Richard Guo <guofenglinux(at)gmail(dot)com> wrote:
> > On Thu, Mar 5, 2026 at 10:57 AM Japin Li <japinli(at)hotmail(dot)com> wrote:
> >> Just a quick note: I think `foreach_ptr` is more appropriate here than
> `foreach`.
> >
> > Agreed.
> >
> > For homogeneous lists, it is better to use foreach_node so we get the
> > additional type-safety assertions in dev builds. For heterogeneous
> > lists, we should use foreach_ptr.
> >
> > 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.
> >
>
> Thanks for updating the patch. LGTM.
>
> --
> Regards,
> Japin Li
> ChengDu WenWu Information Technology Co., Ltd.
>
>
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bertrand Drouvot 2026-03-09 07:43:43 Re: relfilenode statistics
Previous Message Amit Kapila 2026-03-09 07:34:45 Re: Skipping schema changes in publication