Defragment to optimize MySQL tables
- Read more about Defragment to optimize MySQL tables
- Log in to post comments
In MySQL, when you delete records from a table, space is reallocated automatically. It is as empty space and forming new attachments will advantage.
The problem is that if a table perform many DELETE operations, the physical space of the table will become increasingly fragmented and the performance is reduced.
In the MyISAM and InnoDB, OPTIMIZE TABLE command available to perform an optimization on any table that, among other things, performs an automatic defragmentation of the table.
It is highly recommended to use this command regularly especially on tables that are more statements of disposal of records.
As a precaution, keep in mind that during implementation, of course, the table is blocked. You have to remember when you are going to use with large tables and busy.
Supersimples The syntax is:
OPTIMIZE [NO_WRITE_TO_BINLOG | LOCAL] TABLE mi_tabla1 [, mi_tabla2] ...;
To make a fragmented table optimization can be selected to have free space, probably as a result of DELETE statements: