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

From: Alena Rybakina <lena(dot)ribackina(at)yandex(dot)ru>
To: Ilia Evdokimov <ilya(dot)evdokimov(at)tantorlabs(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Peter Petrov <pspetrov91(at)gmail(dot)com>, Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>, David Rowley <dgrowleyml(at)gmail(dot)com>, solaimurugan vellaipandiyan <drsolaimurugan(dot)v(at)gmail(dot)com>
Subject: Re: pull-up subquery if JOIN-ON contains refs to upper-query
Date: 2026-09-30 09:47:42
Message-ID: 0bfb1006-82d5-43ee-a550-3076cefbfd8d@yandex.ru
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I attached the previous version in that letter by mistake, so v10 is
actual now with included tests and some more comments about queries in
regression test.

On 30.09.2026 12:42, Alena Rybakina wrote:
> Hi! Thank you for the review!
>
> On 28.09.2026 18:56, Ilia Evdokimov wrote:
>> Hi Alena,
>>
>> Thanks for v8. The walker is much easier to follow now, and all of
>> Peter's points look addressed to me.
>>
>> I compared the results of random EXISTS/NOT EXISTS queries with and
>> without the pull-up (adding OFFSET 0 to the sub-select blocks it).
>> The queries had nested inner and outer joins in the sub-select,
>> correlated and uncorrelated quals in the ON clauses, and NULLs in the
>> data. About 13.5k queries ran, and about 1250 of them go through the
>> new code path. I found no wrong results and no assertion failures, so
>> the approach looks correct to me.
> Thank you for testing! I haven't found any issues either during
> Smith's test or in a one-hour SQLancer run.
>>
>> My main comment is about the regression tests. A few things are
>> missing in the regression tests:
>>
>> 1. anti join cases
>> 2. query results not only EXPLAIN output
>> 3. An EXISTS sublink in the ON clause of an outer join in the parent
>> query, where the moved qual interacts with the available_rels check.
>>
> Agreed and added tests. Thanks!
>

Attachment Content-Type Size
v10-0001-Allow-pulling-up-EXISTS-sublinks-with-correlated.patch text/plain 32.9 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bingshuai Li 2026-09-30 09:58:11 RE: Bug in logical decoding with DDL and subtransactions
Previous Message Rui Zhao 2026-09-30 09:43:07 Re: Do we want to avoid checksumming extra files in the datadir? [was: BUG #19647]