当前位置:Gxlcms > 数据库问题 > mysql优化count(*)查询语句

mysql优化count(*)查询语句

时间:2021-07-01 10:21:17 帮助过:65人阅读

 

1)count(*)会忽略所有的列,直接统计所有列数,不要使用count(列名),也就是不要使用count(1),count(id)

2)可以使用explain查询近似值,用近似值替代count(*)

3)使用缓存,记录总数

4)允许的话,把innodb改为myisam

5)SELECT (SELECT COUNT(*) from test_student) AS count FROM test_student;

mysql优化count(*)查询语句

标签:语句   inno   替代   mysq   直接   总数   test   查询   查询语句   

人气教程排行