开发者

is "NOT EXISTS" bad SQL practice?

开发者 https://www.devze.com 2023-03-22 04:00 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消