8
Reply

Which will be faster out of these two queries - one with OR or one with IN?

Swati Agarwal

Swati Agarwal

Nov 21, 2012
3.6k
0

    In. If the column is indexed then no difference but if the column is not indexed then the In would be faster than OR because it first sort the record then apply the binary search.

    RAHUL SHUKLA
    July 28, 2015
    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.

    Ajay suwalka
    May 06, 2013
    1

    IN. 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

    Mahesh Patel
    November 27, 2012
    1

    the query with OR is more faster than IN.

    Vishal Jadav
    August 08, 2016
    0

    SQL Server query engine expands all values in IN into a separate OR condition and then executes the query. As Jamie King says it, IN is just a syntactic sugar for less typing for the end user.

    Nitin Sontakke
    July 30, 2016
    0

    In query is faster than OR

    Sandeep Kumar
    June 18, 2016
    0

    IN query is fast rather then OR condition.

    Joginder Banger
    November 10, 2014
    0

    They have difference in Argument types. IN:- test_expressionIs any valid expression. subqueryIs 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 :-boolean_expressionIs any valid expression that returns TRUE, FALSE, or UNKNOWN.

    Manju lata Yadav
    July 11, 2014
    0