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;

相关文章:

  • 2021-08-06
  • 2021-06-11
  • 2022-12-23
  • 2022-02-15
  • 2021-10-17
  • 2021-08-08
  • 2021-12-13
  • 2022-12-23
猜你喜欢
  • 2022-02-05
  • 2021-12-08
  • 2022-12-23
  • 2021-10-24
  • 2022-12-23
相关资源
相似解决方案