IN vs Multiple ORs | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

IN vs Multiple ORs

Is performance better if a where clause is formed as WHERE <column_1> IN (1,2,3…) or WHERE <column_1> = 1 OR <column_1> = 2 OR <column_1> = 3… Is there any difference in performance? Thanks – Walter
They are the same since they are treated as array and compare until found.
another thing is using OR is when you know what you comparing to Know the value in advance.
Using in when you want to use another statement usually select for compare values Beside in is easier to read when more than 3 or statements May the best cheaters win
Sorry if you look at it this way then In is more expensive. Select * from T1 where x in ( select y from T2 ) is typically processed as: select *
from t1, ( select distinct y from t2 ) t2
where t1.x = t2.y; The subquery is evaluated, distinct’ed, indexed (or hashed or sorted) and then
joined to the original table May the best cheaters win
http://groups.google.de/groups?hl=de&lr=&ie=UTF-8&threadm=umy7hwRaBHA.1916%40tkmsftngp05&rnum=48&prev=/groups%3Fq%3Dsql%2Bserver%2Bdifference%2Bnot%2Bin%2Bnot%2Bexists%26start%3D40%26hl%3Dde%26lr%3D%26ie%3DUTF-8%26selm%3Dumy7hwRaBHA.1916%2540tkmsftngp05%26rnum%3D48 —
Frank Kalis
SQL Server MVP
http://www.insidesql.de

Read the first posting by SQL Server MVP Itzik Ben-Gan in that thread I’ve referenced. —
Frank Kalis
SQL Server MVP
http://www.insidesql.de

]]>