On Thu, 1 Aug 2002, Tom Lane wrote:
> Stephan Szabo <[EMAIL PROTECTED]> writes: > > So if T1 has a #dups>0 and T2 has a #dups>0 we should get > > no rows, but what if T1' (with the clause) has a #dups>0 but > > T2' has a #dups=0? > > Um, you're right --- pushing down into the right-hand side would reduce > N, thereby possibly *increasing* the number of output rows not reducing > it. My mistake ... should have worked out the EXCEPT case in more > detail. > > This says that we can't push down at all in the EXCEPT ALL case, I > think, and I'm leery about whether we should push for EXCEPT. But > the UNION and INTERSECT cases are probably the important ones anyway. I think that we can push to the left in both (should is a separate issue). If the condition is true for all of the left hand dups, we can choose to have emitted such rows as the output of the EXCEPT ALL in the theoretical case so that the output is the same, max(0, m-n) rows. If the condition is false for any of the left hand dups, we can safely return any number of rows between 0 and max(0,m-n) rows since we can say that the difference were rows that failed the where clause. If we push the condition down, we'll get some number m1 rows that succeed the condition (with m1<m), so returning max(0, m1-n) should be safe. If the condition is false for all of the rows, m1=0 so we'll correctly return no rows. I think. ---------------------------(end of broadcast)--------------------------- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly