Sample Header Ad - 728x90

Should NOT IN be avoided?

14 votes
1 answer
453 views
Among some SQL Server developers, it's a widely held belief that **NOT IN is terribly slow**, and queries should be rewritten so that they return the same result but do not use the "evil" keywords. ([example](https://web.archive.org/web/20160912175949/http://www.componentworkshop.com/blog/2009/06/26/sql-server-basics-avoiding-in-and-not-in)) . **Is there any truth to that?** Is there, for example, some known bug in SQL Server (which version?) that causes queries using NOT IN to have a worse execution plan than an equivalent query that uses * a LEFT JOIN combined with a NULL check or * (SELECT COUNT(*) ...) = 0 in the WHERE clause ?
Asked by Heinzi (3210 rep)
Nov 6, 2013, 10:50 AM
Last activity: May 5, 2019, 08:33 PM