查看表行数

系统表统计信息

:会有1~3%的不精准

use information_schema;
select table_name,table_rows from tables where TABLE_SCHEMA = '数据库名' order by 
table_rows desc;

高效推荐

SELECT SQL_CALC_FOUND_ROWS 1 FROM tableName limit 1;
SELECT found_rows() AS rowcount;

如下图: 

我们可以看出

(1)统计信息和实际信息的确有差距

(2)count(1) 得出的需要32秒左右

(3)我们的方法大概只需要6秒左右,效率高了5倍。

这个方法也可以用来 测试 where = ...... 有多少个这种值等等

  mysql查看表行数

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-01-05
  • 2021-11-26
  • 2021-12-21
  • 2021-11-22
  • 2021-11-03
  • 2022-02-27
猜你喜欢
  • 2021-04-04
  • 2021-08-11
  • 2022-01-16
  • 2021-08-26
  • 2021-11-27
  • 2022-12-23
  • 2021-11-29
相关资源
相似解决方案