count函数的使用

count(*)不会忽略null值

count(1)不会忽略null值

count(列名)会忽略null值

效率:

MyISAM存储引擎,count(*)最高

InnoDB 存储引擎,count(*)和count(1)的效率>count(字段)

所以在使用时尽量不要使用count(字段),有的公司会因为你在生产环境上使用了count(字段)而扣你奖金

猜你喜欢

转载自blog.csdn.net/qq_39839828/article/details/105961590
今日推荐