Re: Why not do distinct before SetOp
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: David Rowley <dgrowleyml@gmail.com>
Cc: ma lz <ma100@hotmail.com>,
"pgsql-general@postgresql.org" <pgsql-general@postgresql.org>
Date: 2024-11-05T23:09:41Z
Lists: pgsql-general
David Rowley <dgrowleyml@gmail.com> writes: > On Tue, 5 Nov 2024 at 04:18, Tom Lane <tgl@sss.pgh.pa.us> 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