MySQL Mysql中“IS NULL”和“ISNULL()”的区别
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3530124/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Differences between "IS NULL" and "ISNULL()" in Mysql
提问by Wiliam
Is there any difference in performance between the operator IS NULL
and the function ISNULL()
?
运算符IS NULL
和函数之间的性能有什么区别ISNULL()
吗?
采纳答案by Pekka
Looking into the MySQL manual, they seem to be synonyms really.
查看 MySQL 手册,它们似乎真的是同义词。
and even if they aren't, I would tend to trust the query optimizer to pick the best solution.
即使不是,我也倾向于相信查询优化器会选择最佳解决方案。
回答by Geo
This threadis similar, though not exactly on MySQL. According to the test shown there:
这个线程是类似的,虽然不完全是在 MySQL 上。根据那里显示的测试:
IS NULL
is more efficient as it doesn't require a scan.
IS NULL
效率更高,因为它不需要扫描。
Seek is generally faster than a scan as it only includes qualifying records, while scan includes every row. It is explained in more detail here.
Seek 通常比 scan 快,因为它只包括符合条件的记录,而 scan 包括每一行。这里有更详细的解释。
Another difference (though it's not performance) is their negation syntax:
另一个区别(虽然不是性能)是它们的否定语法:
IS NOT NULL /* using NOT operator */
! ISNULL() /* using exclamation mark */