INfo about IN clause in SQL
Ruslan Zasukhin
sunshine at public.kherson.ua
Tue Jul 19 12:50:43 CDT 2005
On 7/19/05 12:38 PM, "sharath.hegde" <sharath.hegde at ness-gsg.com> wrote:
Hi Sharath,
> Hi,
>
> I happened to come across an e-mail posting by you regarding implementation
> of IN clause in SQL. I had a question regarding the use of IN. Which of the
> two queries is faster (more optimized) and why?
>
> Select NAME from STUDENT where ID=100;
>
> OR
>
> Select NAME from STUDENT where ID IN (100);
^^^^^^^ exactly one number?
First query will be faster a little. Because it explicitly says to find ONE
number that equal.
But if you will have MANY values in the IN then IN wins
Select NAME from STUDENT where ID IN (100, 101,102, 103, ....);
The same to
Select NAME from STUDENT where ID=100 OR ID=101 OR ID=102 ...
--
Best regards,
Ruslan Zasukhin
VP Engineering and New Technology
Paradigma Software, Inc
Valentina - Joining Worlds of Information
http://www.paradigmasoft.com
[I feel the need: the need for speed]
More information about the Valentina
mailing list