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 1t8SgI-004KUg-Tj for pgsql-general@arkaria.postgresql.org; Tue, 05 Nov 2024 23:09:50 +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 1t8SgG-001Mvv-6m for pgsql-general@arkaria.postgresql.org; Tue, 05 Nov 2024 23:09:48 +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.94.2) (envelope-from ) id 1t8SgF-001Mvm-R0 for pgsql-general@lists.postgresql.org; Tue, 05 Nov 2024 23:09:48 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t8SgD-000NKe-FM for pgsql-general@postgresql.org; Tue, 05 Nov 2024 23:09:47 +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 4A5N9fDs3119568; Tue, 5 Nov 2024 18:09:41 -0500 From: Tom Lane To: David Rowley cc: ma lz , "pgsql-general@postgresql.org" Subject: Re: Why not do distinct before SetOp In-reply-to: References: <2631313.1730733484@sss.pgh.pa.us> Comments: In-reply-to David Rowley message dated "Wed, 06 Nov 2024 11:11:51 +1300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3119566.1730848181.1@sss.pgh.pa.us> Date: Tue, 05 Nov 2024 18:09:41 -0500 Message-ID: <3119567.1730848181@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk David Rowley writes: > On Tue, 5 Nov 2024 at 04:18, Tom Lane wrote: >> A different idea that occurred to me while looking at this is: >> why have we got all this machinery to add and check a flag >> column, rather than arranging things so that the two input >> relations are "outer" and "inner" children of the SetOp? > I've no idea why it's not like that. The current design is quite > strange and feels dated. It might be worth making that change as even > if we gave joins better support for IS NOT DISTINCT FROM and made > INTERSECT use INNER JOIN instead and EXCEPT use anti join, we'd still > need nodeSetOp.c for INTERSECT ALL and EXCEPT ALL. Yeah. We'd still need it, and besides which it seems like a fairly small project, unlike the other thing which could take multiple years to get to an acceptable state. Of course, I might be overestimating the performance benefit we'd get. But I'm tempted to give it a try. regards, tom lane