In SQL Server, using "NOT EXISTS" in queries are considered bad practice and I've heard that micr开发者_JAVA百科osoft code reviews test for NOT EXISTS and flag these as warnings. Why is NOT EXISTS considered bad practice and that join operators are preferred over NOT EXISTS?
Given that:
Any reasonably query optimizer will be able to convert between “not exists”, “exists” and "joins", so there is normally no performance difference these days.
“Not exists” can often be easier to read then joins.
Therefore I don’t consider “Not exists” to be bad practice in the general case.
精彩评论