Today at work we had a brief discussion about whether using an IN or an EXISTS is more performant. There were a couple different opinions, although most thought that EXISTS was faster. It turns out that like most things in our wonderful software world there is not clear cut answer. In general the below holds true:
- If the majority of the filtering criteria are in the subquery then the
IN variation may be more performant. - If the majority of the filtering criteria are in the top query then the
EXISTS variation may be more performant.
Source:
http://www.oracle-base.com/articles/misc/EfficientSQLStatements.php#Exists and
this.
I assume the same holds true for SQL Server, although we're less interested in that at the moment.