Swati Agarwal
Which will be faster out of these two queries - one with OR or one with IN?
Posted by Swati Agarwal in SQL Server on Nov 21, 2012
  • 0
  • 4
  • 1796
Do you know the answer for this question? Post it below.
Posted by Ajay suwalka on May 06, 2013
  • 1

Almost no difference.. Just checked it on 65000 rows with random values.

Values are compared separately at run time whether they are using IN CLAUSE or using OR CLAUSE in query sql server usage same mechanism for both.

Posted by Mahesh Patel on Nov 27, 2012
  • 1


Because While you use "OR" condition that means your sql select two set of record of index while "IN" is select one record set as per index

Posted by Joginder Banger on Nov 10, 2014
  • 0

IN query is fast rather then OR condition.

Posted by Manju lata Yadav on Jul 11, 2014
  • 0

They have difference in Argument types.

Is any valid expression.

Is a subquery that has a result set of one column. This column must have the same data type as test_expression.
expression[ ,... n ]

Is a list of expressions to test for a match. All expressions must be of the same type as test_expression.
OR :-


Is any valid expression that returns TRUE, FALSE, or UNKNOWN.