sql count(*) count(1)count(colnum)区别

范围:count(*)和count(1) 一样,都包括对NULL的统计;
    count(column) 是不包括NULL的统计。
 
速度:表沒有主键(Primary key),count(1)比count(*)快;
           否则,主键作为count的参数时,count(主键)比count(1)和count(*)都快;
           表只有一个字段,count(*),count(1)和count(主键)速度一样。
posted @ 2017-05-27 17:07  暗夜心慌方  阅读(166)  评论(0)    收藏  举报