Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2003
    Location
    Pittsburgh, PA
    Posts
    86

    Question Unanswered: Performance of "=" versue "in"

    Is there any performance difference between the following two SQL Statements?

    Select *
    from table_A
    where field_Q = 7 or field_Q = 10

    select *
    from table_A
    where field_Q in (7,10)

  2. #2
    Join Date
    Nov 2003
    Posts
    2,933
    Provided Answers: 12
    What does the execution plan say?

  3. #3
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    I'm sure someone can provide a more scholarly answer, but I'm pretty sure the answer is no. I believe the "in" syntax is converted to the "=" syntax for execution.
    Paul

  4. #4
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    Im not at a computer but i am 1 million percent sure they are the same in anyway we can measure but please check yourself. try..

    SET STATISTICS PROFILE ON

    SET STATISTICS IO ON

    SET STATISTICS TIME ON

    google it.
    Last edited by Thrasymachus; 01-05-09 at 21:49.
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

  5. #5
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    If you look at the execution plan text, you can see that IN(...) is changed to a series of OR predicates. As such, there is no logical nor physical distinction between the two.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  6. #6
    Join Date
    Jan 2003
    Location
    Pittsburgh, PA
    Posts
    86

    Thx

    Thanks. My hunch was they were the same. I'll be sure to look at the execution plan more thoroughly.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •