“IS NULL”和“IS NULL”之间的差异和“ISNULL()”在Mysql中
运算符IS NULL
和函数ISNULL()
之间的性能有什么区别吗?
Is there any difference in performance between the operator IS NULL
and the function ISNULL()
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
此线程类似,但不完全是在 MySQL 上。根据此处显示的测试:
IS NULL
效率更高,因为它不需要扫描。查找通常比扫描更快,因为它只包含符合条件的记录,而扫描包括每一行。它有更详细的解释 这里。
另一个区别(尽管不是性能)是它们的否定语法:
This thread is similar, though not exactly on MySQL. According to the test shown there:
IS NULL
is more efficient as it doesn't require a scan.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.
Another difference (though it's not performance) is their negation syntax:
查看MySQL手册,它们似乎确实是同义词。
关于
IS NULL 的 MySQL 手册
关于
ISNULL()
的 MySQL 手册
,即使不是,我也倾向于相信查询优化器会选择最好的解决方案。
Looking into the MySQL manual, they seem to be synonyms really.
MySQL manual on
IS NULL
MySQL manual on
ISNULL()
and even if they aren't, I would tend to trust the query optimizer to pick the best solution.