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 <lena(dot)ribackina(at)yandex(dot)ru>, Peter Petrov <pspetrov91(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, 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-28 15:56:05
Message-ID: 8e10784c-4e6f-405e-bcc2-19bee5e19a9b@tantorlabs.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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.

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.

--
Best regards,
Ilia Evdokimov,
Tantor Labs LLC,
https://tantorlabs.com/

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Rahul Yadav 2026-09-28 16:02:52 Re: [PATCH v1] Fix for Bug#19724 - ALTER TYPE ... ALTER ATTRIBUTE triggers internal error for base type of domain with check
Previous Message Bertrand Drouvot 2026-09-28 15:46:08 Re: Persist slot invalidations before publishing them