count(*),count(常量),count(列名)的区别

简单来说count(*)与count(常量)在功能上是一样的,都是统计总行数,那么他们的速度是一样的么?在mysql官方文档中有这么一句话InnoDB handles SELECT COUNT(*) and SELECT COUNT(1) operations in the same way. There is no performance difference.所以说他们的处理方法是一样的,不存在速度偏差。

而count(列名)就不一样了,它不会统计数据为null的行,所以结果可能会比count(*)数量少。

原文地址:https://www.cnblogs.com/duowenjia/p/12617734.html