Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Nov 2002
    Location
    Loughborough (UK)
    Posts
    209
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool JOIN OR SubQuery?

    Hi, I'm using a Stored Proc to build the XML that I then bind to the MS TreeView Server Control. The whole process is quite long-winded so I want to make it as efficient as possible.

    PROBLEM: I need to select only those records for which the ID appears in another table. What I want to know is which is the most efficient of the following options?

    OPTION 1: Use an inner join on the other table.

    OPTION 2: Use the good old 'WHERE ID IN (SELECT ID FROM...)

    Thanks,
    Chris

  • #2
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i believe the inner join will be faster+ uses less resources.

    On the other hand...
    Suppose table 1 has 100k records and table 2 (the one from the IN(clause) only has 50 records. Then i suppose the subquery could be faster ...

    Why not try it out ? It's just writing out the 2 sql stataments and set a timer on it.


  •  

    Posting Permissions

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