IT

Defragmentace tabulek v MySql

15.5.2017

Pořád zapomínám, takže zjištění stavu fragmentace:

select ENGINE, TABLE_NAME,Round( DATA_LENGTH/1024/1024) as data_length , round(INDEX_LENGTH/1024/1024) as index_length, round(DATA_FREE/ 1024/1024) as data_free, (data_free/(index_length+data_length)) as frag_ratio from information_schema.tables where DATA_FREE > 0 order by frag_ratio desc;

A potom:

OPTIMIZE TABLE tabulka;