count(1) and count(*) and count(字段)对比
count(1) and count(*) and count(字段)对比
执行效果:
count(1) and count(*)
当表的数据量大些时,对表作分析之后,使用count(1)还要比使用count()用时多了!
从执行计划来看,count(1)和count()的效果是一样的。 但是在表做过分析之后,count(1)会比count(*)的用时少些(1w以内数据量),不过差不了多少。
如果count(1)是聚索引,id,那肯定是count(1)快。但是差的很小的。
因为count(),自动会优化
原创
2021-02-20 14:44:49 ·
365 阅读 ·
0 评论