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.94.2) (envelope-from ) id 1v5wom-00EQMM-5H for pgsql-hackers@arkaria.postgresql.org; Tue, 07 Oct 2025 01:48:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1v5woi-00CW99-Mr for pgsql-hackers@arkaria.postgresql.org; Tue, 07 Oct 2025 01:48:41 +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.94.2) (envelope-from ) id 1v5woi-00CW8v-Dj for pgsql-hackers@lists.postgresql.org; Tue, 07 Oct 2025 01:48:41 +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.96) (envelope-from ) id 1v5wog-000mAF-2h for pgsql-hackers@lists.postgresql.org; Tue, 07 Oct 2025 01:48:40 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 5971mZEd2248555; Mon, 6 Oct 2025 21:48:35 -0400 From: Tom Lane To: David Rowley cc: PostgreSQL Developers Subject: Re: Teaching planner to short-circuit empty UNION/EXCEPT/INTERSECT inputs In-reply-to: References: <976130.1759375308@sss.pgh.pa.us> <1064547.1759418336@sss.pgh.pa.us> <1196118.1759438964@sss.pgh.pa.us> <1507624.1759592628@sss.pgh.pa.us> Comments: In-reply-to David Rowley message dated "Tue, 07 Oct 2025 14:19:05 +1300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2248553.1759801715.1@sss.pgh.pa.us> Date: Mon, 06 Oct 2025 21:48:35 -0400 Message-ID: <2248554.1759801715@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk David Rowley writes: > The reason I didn't go down the route of SETOP_VAR was that it's still > a hack, it's just making it look a bit more official. I suppose the > correct way to fix all this and get rid of the varno==0 stuff forever > is to have a proper top-level RTE for the top-level set operation and > make it so each child is an OTHER_MEMBER rel at that query level. It > felt like going a bit too far to do something like that to fix this > bug, so I didn't explore that further. Yeah, I think "more RTEs" is the ultimate solution here, but it's never risen to the top of my to-do list either. I was kind of thinking about an RTE per set-op child, though. Not sure if one for the top-level op, or one for an intermediate op, would help; though it's certainly possible it would. regards, tom lane