MySQL information_schema 不更新

Eag*_*gle 5 mysql innodb mysql-5.5 percona-server

abc在 mysql 服务器中有一个数据库。它只有一张名为test. test使用 innodb 引擎,我已经设置innodb_file_per_table为 true。

运行查询后delete from abc.test,我想计算abc. 这是我使用的查询:

SELECT
    table_schema "name",
    sum( IF(engine = "MyISAM", data_length + index_length -  data_free,
    data_length + index_length)) "size"
FROM information_schema.TABLES
where table_schema like "abc";
Run Code Online (Sandbox Code Playgroud)

奇怪的是,我发现数据库大小根本没有减少,但是“测试”中的数据却不见了。

我做过很多次这种测试,这种奇怪的行为有时会发生。

我正在使用 percona mysql server 5.5.29-rel29.4.

谁能告诉我出了什么问题?

更新:

实际上,我使用另一个线程定期检查数据库大小。

Ike*_*ker 3

您需要重建表才能缩小 ibd 文件。这个命令会做到这一点:

optimize table abc.test;
Run Code Online (Sandbox Code Playgroud)