Popular Posts

SQLblog.com - The SQL Server blog spot on the web

Wednesday, March 21, 2018

Consider using [NOT] EXISTS instead of [NOT] IN (subquery)

SQLServerCentral.com Articles
Consider using [NOT] EXISTS instead of [NOT] IN (subquery)

The query optimizer now treats EXISTS and IN the same way, whenever it can, so you’re unlikely to see any significant performance differences. Nevertheless, you need to be cautious when using the NOT IN operator if the subquery’s source data contains NULL values. If so, you should consider using a NOT EXISTS operator instead of NOT IN, or recast the statement as a left outer join.

No comments: