Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
IS NULL运算符和函数之间的性能有什么区别ISNULL()吗?
IS NULL
ISNULL()
这个线程是相似的,虽然不完全在 MySQL 上。根据那里显示的测试:
IS NULL效率更高,因为它不需要扫描。
搜索通常比扫描快,因为它只包括合格的记录,而扫描包括每一行。这里有更详细的解释。
另一个区别(尽管它不是性能)是它们的否定语法:
IS NOT NULL /* using NOT operator */ ! ISNULL() /* using exclamation mark */
查看 MySQL 手册,它们似乎真的是同义词。
MySQL手册上IS NULL
MySQL手册上ISNULL()
即使不是,我也倾向于相信查询优化器会选择最佳解决方案。