Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Note Dennis's comment about the inner query executing for each value. You might think that's automatically going to happen, but if the server thinks it will be faster to retrieve all or some of the Cards rows it'll do that instead. 

There are varying opinions on "where in" vs "where exists", but as this StackOverflow post suggests there's a good chance the query optimizer will create the same execution plan in both cases. 

I'm told that the thing to watch out for is the use of Not Exists in subqueries, as this will always result in the subquery executing for each row in the parent query. In this situation you're probably better off with an outer join

Arnor reminded the group about the Database Engine Tuning Advisor

For more information on subqueries check out the Subquery Fundamentals page on MSDN.