mysql优化count(*)查询语句

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;

原文地址:https://www.cnblogs.com/-mrl/p/13280684.html