>>Sergey,
>>
>>>You can also rewrite it as follow (it may be faster)
>>>
SELECT taitem.ident;
>>> FROM taitem;
>>> WHERE code IN (SELECT arcode.code FROM arcode ;
>>> WHERE arcode.activity = "EA")
>>>
>>
>>I'm almost positive that an EXISTS select is going to be faster than an IN select. AFAIK exists allows the inner select to be run only once. IN forces it to be run for every row in the outer select.
>
>Hi David,
>
>It's actualy opposite. IN subquery runs once and than result is used by the main query. The EXISTS uses correlated subquery so it has to run for every record in the main query.
Even more interesting to me is:
How can I know which will run once and which will really be a correlated subquery?
Also, wouldn't both cases be run every time **IF** there was a field from the record itself included in the subquery's WHERE clause? (say like WHERE ARCODE.Activity = TAITEM.ActionCode)