Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2011
    Posts
    9

    Unanswered: IN and performance

    First the two "selects":

    .... IN (SELECT SomeID FROM SomeTable)

    ... IN (1,2,3,4,5)

    Let's assume SomeTable only has 5 rows with the values 1 through 5.

    The first statment is still MUCH MUCH slower than hardcoding in the numbers.

    So what's the correct way of doing a dynamic IN-List?

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by Marty78 View Post
    So what's the correct way of doing a dynamic IN-List?
    with a join
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Specifically with an INNER JOIN when you're using the join operation to filter results.

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

Posting Permissions

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