MySQL TABLE.TABLE_ROWS 在插入期间减少
如果我发出以下命令:
CREATE TABLE foo LIKE bar;
INSERT INTO bar SELECT * FROM foo;
foo 有几百万行,因此此操作需要一些时间。
如果我在执行上面的过程中重复执行以下查询:
use information_schema
select table_name, TABLE_ROWS from tables where table_name IN ('foo','bar');
我看到了以下进展:
+---------------------------------+------------+
| table_name | TABLE_ROWS |
+---------------------------------+------------+
| foo | 21270328 |
| bar | 5292482 |
+---------------------------------+------------+
然后稍后:
+---------------------------------+------------+
| table_name | TABLE_ROWS |
+---------------------------------+------------+
| foo | 21270328 |
| bar | 3422182 |
+---------------------------------+------------+
为什么这个数字会减少?
If I issue the following commands:
CREATE TABLE foo LIKE bar;
INSERT INTO bar SELECT * FROM foo;
There are several million rows in foo, so this action takes some time.
If I do the following query repeatedly during the execution of the above:
use information_schema
select table_name, TABLE_ROWS from tables where table_name IN ('foo','bar');
I've seen the following progression:
+---------------------------------+------------+
| table_name | TABLE_ROWS |
+---------------------------------+------------+
| foo | 21270328 |
| bar | 5292482 |
+---------------------------------+------------+
and then a little later:
+---------------------------------+------------+
| table_name | TABLE_ROWS |
+---------------------------------+------------+
| foo | 21270328 |
| bar | 3422182 |
+---------------------------------+------------+
Why does this number decrease?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如 information_schema.tables 的文档中所述,“对于 InnoDB 表,行数只是 SQL 优化中使用的粗略估计。”
As noted in the documentation for information_schema.tables, "For InnoDB tables, the row count is only a rough estimate used in SQL optimization."