Skip to content

Latest commit

 

History

History
12 lines (11 loc) · 303 Bytes

check_fragmentation_for_table.md

File metadata and controls

12 lines (11 loc) · 303 Bytes

Check the fragmentation for a table

SELECT
table_name,
round(data_length / 1024 / 1024) AS 'total (MB)',
round(data_free / 1024 / 1024) AS 'unused (MB)',
data_free * 100 / data_length AS 'fragmented (%)'
FROM information_schema.tables
WHERE table_schema = 'my_db'
ORDER BY data_free DESC;