Re: Convert ALL SubLinks to ANY SubLinks

From: wenhui qiu <qiuwenhuifx(at)gmail(dot)com>
To: Richard Guo <guofenglinux(at)gmail(dot)com>
Cc: Andrei Lepikhov <lepihov(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Convert ALL SubLinks to ANY SubLinks
Date: 2026-02-27 01:55:10
Message-ID: CAGjGUAKR34m0Sqyfe-+mzYKdZ9Ur3prKMm7UEHTC=xAWsG4aXA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

HI
> If pulling up a subquery results in a suboptimal join order due to the
> number of relations, the root cause lies in the limitations of the
> join search algorithm itself. It doesn't seem reasonable to penalize
> the general subquery flattening mechanism for that limitation, and it
> makes even less sense to fault this specific transformation, which
> simply converts ALL_SUBLINK to ANY_SUBLINK so it can benefit from the
> same hashed SubPlan and flattening mechanics that other subqueries
>already enjoy.
Agree +1

Thanks

On Fri, Feb 27, 2026 at 9:42 AM Richard Guo <guofenglinux(at)gmail(dot)com> wrote:

> On Thu, Feb 26, 2026 at 8:37 PM Andrei Lepikhov <lepihov(at)gmail(dot)com> wrote:
> > I want to correct your statement on the 'no regression' phrase. In
> > practice, users often report issues after each new sublink
> > transformation goes live.
> >
> > This happens because the transformation changes the 'join problem'
> > order. Before, the subplan's join list was handled independently, but
> > now its relations are mixed with those from higher levels. If the join
> > collapse limit is exceeded, this can sometimes cause much worse
> > performance than in earlier Postgres versions.
>
> I'm not convinced this is a regression. In scenarios where the join
> tree becomes too large, wouldn't the standard solution be for the user
> to tune join_collapse_limit (and maybe also geqo_threshold)?
>
> If pulling up a subquery results in a suboptimal join order due to the
> number of relations, the root cause lies in the limitations of the
> join search algorithm itself. It doesn't seem reasonable to penalize
> the general subquery flattening mechanism for that limitation, and it
> makes even less sense to fault this specific transformation, which
> simply converts ALL_SUBLINK to ANY_SUBLINK so it can benefit from the
> same hashed SubPlan and flattening mechanics that other subqueries
> already enjoy.
>
> - Richard
>
>
>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tatsuo Ishii 2026-02-27 02:37:33 Re: Row pattern recognition
Previous Message DEVOPS_WwIT 2026-02-27 01:52:37 Re: [PROPOSAL] Doublewrite Buffer as an alternative torn page protection to Full Page Write