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 —
Frank Kalis
SQL Server MVP

Read the first posting by SQL Server MVP Itzik Ben-Gan in that thread I’ve referenced. —
Frank Kalis
SQL Server MVP