Skip to content

Instantly share code, notes, and snippets.

@cesarmiquel
Created January 15, 2020 13:31
Show Gist options
  • Save cesarmiquel/2b4ed49ceb7268ae0ed91a9d469ccfc5 to your computer and use it in GitHub Desktop.
Save cesarmiquel/2b4ed49ceb7268ae0ed91a9d469ccfc5 to your computer and use it in GitHub Desktop.
List MySQL tables that may need defragmentation
--
-- Source: https://www.thegeekstuff.com/2016/04/mysql-optimize-table/
--
SELECT
table_name
, round(data_length/1024/1024) as data_length_mb\
, round(data_free/1024/1024) as data_free_mb
FROM
information_schema.tables
WHERE
round(data_free/1024/1024) > 500
ORDER BY
data_free_mb;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment