> DB2 8.2 LUW FP14
>
[quoted text clipped - 10 lines]
>
> aj
IN, ANY and EXISTS are all ANSI SQL 92.
A IN (B)
is equivalent to
A = ANY (B)
In fact the SQL standard defines IN by using the ANY syntax.
EXISTS is entirely different. Probably you meant to imply some correlated
subquery in place of some simple subqueries in your other examples. Without
seeing the actual queries, DDL etc I won't speculate on whether such queries
might be equivalent.

Signature
David Portas
>DB2 8.2 LUW FP14
>
[quoted text clipped - 10 lines]
>
>aj
Yes. IN means the compiler needs to put together a result set, and see
if it matches. EXISTS wll use any availible INDEX.
For smaller reult sets IN() is usually faster, for larger use EXISTS.
In some cases execution time will be the same, in others, there may be
a significant difference.
B.
Knut Stolze - 25 Jul 2007 19:18 GMT
>>DB2 8.2 LUW FP14
>>
[quoted text clipped - 13 lines]
> Yes. IN means the compiler needs to put together a result set, and see
> if it matches. EXISTS wll use any availible INDEX.
I wouldn't draw such a conclusion. The optimizer could rewrite one form
into the other and, thus, result in the same access plan.

Signature
Knut Stolze
DB2 z/OS Utilities Development
IBM Germany
Brian Tkatch - 25 Jul 2007 19:49 GMT
>>>DB2 8.2 LUW FP14
>>>
[quoted text clipped - 16 lines]
>I wouldn't draw such a conclusion. The optimizer could rewrite one form
>into the other and, thus, result in the same access plan.
You know, the optimizer really gets in the way here. :P
B.