如何优化information_Schema数据库中的表

时间:2016-07-09 01:56:39

标签: mysql database optimization information-schema fragmentation

我在 information_Schema 数据库中获得了可用空间(碎片问题)。

警告显示某些表格中有1500%的可用空间,例如 COLUMNS,ROUTINES。

我担心这是怎么可能的,因为我的数据库中没有任何例程,以及如何优化information_schema,因为它基于内存的数据库并在mysql服务启动时创建。

当我在任何information_schema表上查询“SHOW CREATE TABLE”时,它会将innodb作为这些表的引擎,但我认为它应该是内存。

有没有想过优化这些表而不重启?

由于

1 个答案:

答案 0 :(得分:0)

When you have innodb_file_per_table = OFF, InnoDB tables are created in the system 'tablespace', ibdata1. It could be that you have created and manipulated a lot of tables there.

Data_free is a confusing term in SHOW CREATE TABLE and certain tables in information_schema...

  • For MyISAM tables, it is an accurate amount of the space that could be recovered from the .MYD file (but not the .MYI file).
  • For InnoDB it means one of 2 things...
    • If the table you are looking at was created with innodb_file_per_table = ON, then Data_free is some of the unused space. Often, not all of it can be recovered by any means.
    • If the table you are looking at was created with innodb_file_per_table = OFF, then Data_free is the free space in ibdata1. That free space will be used for new inserts and new tables, thereby decreasing Data_free. However, the size of ibdata1 cannot be shrunk, at least not without a lot of effort (dump everything, remove, reload).