Skip to content

Instantly share code, notes, and snippets.

@madlep
Created August 28, 2012 01:30
Show Gist options
  • Save madlep/3494112 to your computer and use it in GitHub Desktop.
Save madlep/3494112 to your computer and use it in GitHub Desktop.
MySQL query to list table sizes (index + data) for each schema
SELECT
TABLE_NAME,
table_rows,
AVG_ROW_LENGTH,
data_length / 1024 /1024 / 1024 AS data_length_gb,
index_length / 1024 /1024 / 1024 AS index_length_gb,
(data_length / 1024 /1024 / 1024 + index_length / 1024 /1024 / 1024) AS total_length_gb
FROM information_schema.tables
ORDER BY table_schema, total_length_gb DESC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment