Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wMqlh-000OM2-0i for pgsql-hackers@arkaria.postgresql.org; Tue, 12 May 2026 17:19:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wMqle-005GiY-00 for pgsql-hackers@arkaria.postgresql.org; Tue, 12 May 2026 17:19:38 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wMqld-005GiQ-1s for pgsql-hackers@lists.postgresql.org; Tue, 12 May 2026 17:19:37 +0000 Received: from forward103d.mail.yandex.net ([178.154.239.214]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wMqlY-00000000EeX-2TB5 for pgsql-hackers@lists.postgresql.org; Tue, 12 May 2026 17:19:36 +0000 Received: from mail-nwsmtp-smtp-production-main-72.klg.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-72.klg.yp-c.yandex.net [IPv6:2a02:6b8:c42:27a5:0:640:93ca:0]) by forward103d.mail.yandex.net (Yandex) with ESMTPS id 39DDBC0057; Tue, 12 May 2026 20:19:29 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-72.klg.yp-c.yandex.net (smtp) with ESMTPSA id PJOoUO7Q1Gk0-otG2fNPm; Tue, 12 May 2026 20:19:28 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1778606368; bh=wR+mvpW1vz8YSQ+B8JljJqU7ohjYUT9lIkKKikqModI=; h=From:In-Reply-To:Cc:Date:References:To:Subject:Message-ID; b=RTuqDbq0ep7eF54QJxiu5Wg44WQXfxu3SAoTls0d90mvfQanawJuDM2pGk4kks3tW zibI2AjzQmKi1lYzkMzqSjE8Q0GbwpxIvXbzsD3VzUtcdneEj1VWagDcUfkfhx7j3+ fFisv25A8AVMB4bWhY+8rdKn8KdQlEvKy09zn0/I= Authentication-Results: mail-nwsmtp-smtp-production-main-72.klg.yp-c.yandex.net; dkim=pass header.i=@yandex.ru Message-ID: <3c077371-bdcb-4537-aabe-eb944d8e1d07@yandex.ru> Date: Tue, 12 May 2026 20:19:27 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: pull-up subquery if JOIN-ON contains refs to upper-query To: solaimurugan vellaipandiyan Cc: Alena Rybakina , Ilia Evdokimov , David Rowley , Ranier Vilela , PostgreSQL Hackers , Petr Petrov References: <0b1f670d-b39d-4966-bf32-f0d502ebc564@postgrespro.ru> <46bc4eaf-58c5-42ab-8041-d3380a0768de@postgrespro.ru> <9b041978-06e3-4a50-8a5d-dacbb054f23e@tantorlabs.com> <8d7cbbf6-ddc0-4696-8af2-a68d740e14f2@postgrespro.ru> <6078f7e1-4b29-4b31-bd28-b84149e404e4@postgrespro.ru> <975a3736-a8b5-49b3-8009-4d4e86867aa1@postgrespro.ru> <0adbf75a-2059-4bb7-b878-c33892dbc1f0@tantorlabs.com> <300d7bb0-345c-4c0b-a0ef-4de573fcc94b@postgrespro.ru> <32446f52-1b18-499a-a77b-d6b66ad0f4cf@tantorlabs.com> <87a6fcbf-929a-408a-9471-28be3080254a@postgrespro.ru> <4e9d279c-83c1-42d3-b74d-7366ecd7f085@tantorlabs.com> <386165c3-3c01-4a85-b618-7919e64a52de@postgrespro.ru> <6b0da757-c63e-4abd-8fda-4f38e7dfd222@postgrespro.ru> Content-Language: en-US From: Alena Rybakina In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, thank you for your valuable feedback. If you have time you can test it on sqlsmith (https://github.com/anse1/sqlsmith) - it will give some corner cases that should be observed. On 11.05.2026 08:20, solaimurugan vellaipandiyan wrote: > Hi Alena, > > I did some additional testing on the latest patch and the behavior > looks good in my environment so far. > > I verified the original EXISTS pull-up case and confirmed that after > applying the patch the planner generates optimized Semi Join plans > instead of EXISTS(SubPlan). > I also tested several additional cases discussed in the thread, including: > 1.NOT EXISTS queries > 2. constant qual conditions > 3. ANY array conditions > 4. LEFT JOIN cases > 5. FULL JOIN cases > For the FULL JOIN scenarios, I checked both the execution plans and > actual query results. In one case the planner simplified the query > into a Hash Join plan, but the final query results remained correct. > I additionally ran: > - make check > - make -C contrib check > Both completed successfully in my environment and I did not observe > planner crashes or incorrect query results during testing. > Overall, the patch seems to improve planner behavior consistently for > these EXISTS pull-up scenarios. > > Regards, > Solaimurugan V > > -- ----------- Best regards, Alena Rybakina