Re: pull-up subquery if JOIN-ON contains refs to upper-query

From: Ilia Evdokimov <ilya(dot)evdokimov(at)tantorlabs(dot)com>
To: Alena Rybakina <a(dot)rybakina(at)postgrespro(dot)ru>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Peter Petrov <p(dot)petrov(at)postgrespro(dot)ru>
Cc: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>
Subject: Re: pull-up subquery if JOIN-ON contains refs to upper-query
Date: 2025-04-03 13:56:52
Message-ID: 32446f52-1b18-499a-a77b-d6b66ad0f4cf@tantorlabs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On 02.04.2025 19:39, Alena Rybakina wrote:
>
> I see that I need to add a walker that, when traversing the tree,
> determines whether there are conditions under which pull-up is
> impossible - the presence of
> volatility of functions and other restrictions, and leave the
> transformation for the var objects that I added before, I described it
> here.
>

I have some concerns about pulling up every clause from the subquery
with one column. In particular, not every clause is safe or beneficial
to pull up: OR-clauses, CASE expressions, nested sublinks could
significantly change how the planner estimates the number of rows or
applies filters, especially when they are not true join predicates.
Pulling them up might lead to worse plans, or even change the semantics
in subtle ways. I think before applying such transformations, we should
make sure they are not only safe but actually improve the resulting plan.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Yugo NAGATA 2025-04-03 14:04:18 Re: Extend ALTER DEFAULT PRIVILEGES for large objects
Previous Message Andres Freund 2025-04-03 13:54:00 Re: AIX support