Skip to content

Instantly share code, notes, and snippets.

@ryannealmes
Last active August 29, 2015 14:17
Show Gist options
  • Save ryannealmes/71508afec9fc54c9c1f2 to your computer and use it in GitHub Desktop.
Save ryannealmes/71508afec9fc54c9c1f2 to your computer and use it in GitHub Desktop.
Database/Table size in MB
You can use this query to show the size of a table:
SELECT table_name AS "Table",
round(((data_length + index_length) / 1024 / 1024), 2) "Size in MB"
FROM information_schema.TABLES
WHERE table_schema = "$DB_NAME"
AND table_name = "$TABLE_NAME";
or this query to list the size of every table in the database, largest first:
SELECT table_name AS "Tables",
round(((data_length + index_length) / 1024 / 1024), 2) "Size in MB"
FROM information_schema.TABLES
WHERE table_schema = "$DB_NAME"
ORDER BY (data_length + index_length) DESC;
Reference: http://stackoverflow.com/questions/9620198/how-to-get-the-sizes-of-the-tables-of-a-mysql-database
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment