> > Please see the section titled "Tuning existential predicates" in the
> > following TinyURL link for an opinion on COUNT(*):http://tinyurl.com/2t3gac
[quoted text clipped - 4 lines]
> That said, I'm sure I'm overlooking something obvious to the more
> experienced so what am I missing?
Hi, Ray.
I'm not saying you're missing anything. I think Serge's argument (the
author of the opinion I included) is that there's no sense counting up
a bunch of things only to throw this number away.
The better thing about EXISTS is that the minute a single row tests
true, the search stops, so there's the potential for a much faster
test.
Anyway, I think we're splitting hairs here. As in all things,
individual results will vary. Do what works :-)
Regards,
--Jeff
Ray - 01 Mar 2007 20:52 GMT
> I'm not saying you're missing anything. I think Serge's argument (the
> author of the opinion I included) is that there's no sense counting up
> a bunch of things only to throw this number away.
Thanks, Jeff. In fact I WAS missing a couple of things. First was the
explicit optimization of the select, which I now understand.
> The better thing about EXISTS is that the minute a single row tests
> true, the search stops, so there's the potential for a much faster
> test.
Does that mean that DB2 will actually short circuit the select in the
infocenter example for exists?
EXISTS (SELECT * FROM TEMPL WHERE SALARY < 10000)
Brian Tkatch - 01 Mar 2007 21:45 GMT
>> I'm not saying you're missing anything. I think Serge's argument (the
>> author of the opinion I included) is that there's no sense counting up
[quoted text clipped - 11 lines]
>
> EXISTS (SELECT * FROM TEMPL WHERE SALARY < 10000)
I think it should. EXISTS (SELECT * is the classic example of
short-circuiting.
B.