just for knowledge pupose

  • which one is faster?

    in select query in where condition

    which clause runs faster?

    'in' clause

    OR

    'or' clause

    plzz rply with examples if possibles.

    Sanket Ahir
    Don't run behind the success, Try to be eligible & success will run behind u......

  • They'll be the same. As part of the parsing/algebratisation that SQL does, IN with a list of values is converted to OR. Easy to test for yourself, write a query with an IN list and look at the execution plan.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • If you mean for difference between

    Select WhatEver from MyTable where ID in (1,2,3)

    And

    Select WhatEver from MyTable where ID = 1 OR ID=2 OR ID=3

    Then both will produce the same query plan which means that you won’t see any difference. By the way, you don’t have to take my word for it. You can write the 2 versions of the SQL statement in the management studio and check the query plan and cost relative for the batch.

    Adi

    --------------------------------------------------------------
    To know how to ask questions and increase the chances of getting asnwers:
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply