Search code examples
t-sqloptimizationprofilingperformancesql-optimization

What's faster IN or OR?


In T-SQL what's faster?

DELETE * FROM ... WHERE A IN (x,y,z)

Or

DELETE * FROM ... WHERE A = x OR A = y OR A = z

In my case x, y and z are input parameters for the stored procedure. And I'm trying to get the performance of my DELETE and INSERT statements to the best of my abilities.


Solution

  • "IN" will be translated to a series of "OR"s...if you look at the execution plan for a query with "IN", you'll see it has expanded it out.

    Much cleaner to use "IN" in my opinion, especially in larger queries it makes it much more readable.