gpt4 book ai didi

backup - 显示表状态会显示表中的确切行吗?

转载 作者:行者123 更新时间:2023-11-29 16:28:38 25 4
gpt4 key购买 nike

我在数据库中有一个表,它的空间约为 90 GB。我试图计算表中的行数 select count(idNewsNotification) from notification结果是

4982397

1 row in set (59 min 48.35 sec)

但是当我使用show table status like <table_name>查询时它表明

 Engine: InnoDB
Version: 10
Row_format: Compact
Rows: 8631267
Avg_row_length: 11237
Data_length: 96996425728
Max_data_length: 0
Index_length: 175374336
Data_free: 0
Auto_increment: NULL
.....

了解表中记录数量的完美程序是什么?

最佳答案

事实上,您的计数花费了一个小时,这意味着您正在运行 InnoDB(它不会缓存此数据)。

因此,表状态是基于其他因素的近似值,并不可信。

计数(*)是准确的,但等待很痛苦。

来自the doc :

Some storage engines, such as MyISAM, store the exact count. For other storage engines, such as InnoDB, this value is an approximation, and may vary from the actual value by as much as 40 to 50%. In such cases, use SELECT COUNT(*) to obtain an accurate count.

关于backup - 显示表状态会显示表中的确切行吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54080308/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com