首页 > MySQL
补充 MySQl 查询 count(*) count(1) count(主键) 怎样选择索引的
发布时间:2017-06-14 15:04:47
访问量:5

 经过使用

    explain extended select count(*) from user;
    show warnings;
    explain extended select count(1) from user;
    show warnings;
    explain extended select count(14) from user;
    show warnings;
    explain extended select count(id) from user;
    show warnings;

发现他们使用的索引是一样的,测试对比总结:

    count(*) count(non-null)  使用索引规则:字段最短的那个表索引,若是主键字段不是最短的也不会使用主键索引

 当然,若是表只有一个主键索引  那肯定就使用主键索引了 


相关文章 更多文章
MySQl 查询 count(*) count(1) count(主键) 选哪个
mysql基础再回顾
MySQL错误之‘Got a packet bigger than 'max_allowed_packet' bytes’
Navicat 操作数据库传输
Windows7 x86系统下安装MySQL5.5
发表评论 0
网友评论
© 2010-2015 PekingPiao.com
版权所有 DBR
Mem
Top