Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Creating temporary table
Message
From
05/02/2014 01:19:27
 
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2008
Application:
Web
Miscellaneous
Thread ID:
01593184
Message ID:
01593239
Views:
36
Usually NOT EXISTS subquery performs slightly faster than NOT IN.

In older versions of SQL Server (i.e. prior to SQL Server 2005), EXISTS/NOT EXISTS was indeed usually faster than IN/NOT IN.

But Microsoft made some changes under the hood, which has led some people to assume that they now perform the same.

Here's my understanding....it depends on the context of NULL values (this has been talked about in many posts on sqlservercentral.com).

If the column being used permits NULL values but no NULL values exists, NOT EXISTS will perform faster (sometimes several times faster) than NOT IN.

If that's not the case, my understanding is that the two are usually going to perform about the same.

Admittedly, I'll use IN/NOT IN when dealing with one column and EXISTS/NOT EXISTS if I have to evaluate multiple columns.
Previous
Reply
Map
View

Click here to load this message in the networking platform