加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MySql教程 > 正文

myisam和innodb中count(*)的区别

发布时间:2020-12-12 00:02:04 所属栏目:MySql教程 来源:网络整理
导读:转自: p style="color:rgb(51,51,51);font-family:Arial;font-size:14px;"COUNT( ) for Innodb Tablesa href="http://www.mysqlperformanceblog.com/2006/12/01/count-for-innodb-tables/" rel="nofollow" style="color:rgb(51,102,153);text-decoration:no

转自:

<p style="color:rgb(51,51,51);font-family:Arial;font-size:14px;">COUNT() for Innodb Tables<a href="http://www.mysqlperformanceblog.com/2006/12/01/count-for-innodb-tables/" rel="nofollow" style="color:rgb(51,102,153);text-decoration:none;">http://www.mysqlperformanceblog.com/2006/12/01/count-for-innodb-tables/


<p style="color:rgb(51,51);font-family:Arial;font-size:14px;">?


<p style="color:rgb(51,51);font-family:Arial;font-size:14px;">总结:


<p style="color:rgb(51,51);font-family:Arial;font-size:14px;">1.myisam保存表的总行数,因此count(
)并且无where子句,很快会返回表的总行数
2.myisam保存表的总行数,利用count(column)并且无where子句,并且此column不为null,很快会返回表的总行数
3.myisam保存表的总行数,并且此column可以为null,<a href="http://lib.csdn.net/base/mysql" rel="nofollow" class="replace_word" title="MySQL知识库" style="color:rgb(223,52,52);text-decoration:none;font-weight:bold;">MySQL会对表进行全表或全索引扫描来确定行数
4.innodb查询count(),count(column(not null)),count(column(may be null))并且无where子句,mysql会对表进行全表或全索引扫描来确定行数
5.myisam和innodb查询count(
),count(column(may be null))并且存在where子句,mysql会对表进行索引扫描(如果列上有索引),速度也比较快

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读