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 1wldr0-000Iv2-1u for pgsql-bugs@arkaria.postgresql.org; Mon, 20 Jul 2026 02:35:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wldr0-001o4h-0n for pgsql-bugs@arkaria.postgresql.org; Mon, 20 Jul 2026 02:35:37 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wldqz-001o4Y-3C for pgsql-bugs@lists.postgresql.org; Mon, 20 Jul 2026 02:35:37 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wldqx-00000000C20-2Foi for pgsql-bugs@lists.postgresql.org; Mon, 20 Jul 2026 02:35:37 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.18.1/8.18.1) with ESMTP id 66K2ZSMP1065900; Sun, 19 Jul 2026 22:35:28 -0400 From: Tom Lane To: Richard Guo cc: Matheus Alcantara , leis@in.tum.de, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #19553: Wrong results from nested LEFT JOINs over an empty subquery (regression since v16) In-reply-to: References: <19553-4561747f93f368a7@postgresql.org> <3824828.1784244210@sss.pgh.pa.us> <3957687.1784308823@sss.pgh.pa.us> <298498.1784398271@sss.pgh.pa.us> Comments: In-reply-to Richard Guo message dated "Mon, 20 Jul 2026 11:33:23 +0900" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1065898.1784514928.1@sss.pgh.pa.us> Date: Sun, 19 Jul 2026 22:35:28 -0400 Message-ID: <1065899.1784514928@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Richard Guo writes: > It occurred to me that we can skip the new get_relids_in_jointree() > scan altogether when there are no PHVs anywhere in the query > (root->glob->lastPHId==0), since then the find_dependent_phvs() checks > are no-ops anyway. This is also consistent with how we check > root->glob->lastPHId in find_dependent_phvs() and > find_dependent_phvs_in_jointree(). Attached is a trivial patch doing > that. WFM. regards, tom lane