View Full Version : JOIN OR SubQuery?

10-23-2003, 10:21 AM
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...)


10-23-2003, 12:32 PM
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.