Skip to content

Instantly share code, notes, and snippets.

@pydevd
Last active December 26, 2016 12:37
Show Gist options
  • Save pydevd/d6a54571f88fde26904fb047ea571ef7 to your computer and use it in GitHub Desktop.
Save pydevd/d6a54571f88fde26904fb047ea571ef7 to your computer and use it in GitHub Desktop.
This code displays approx size of all databases and tables
-- selects approx size of all databases
SELECT
table_schema AS "Database",
SUM( data_length + index_length )/1024/1024 AS "Size, MB"
FROM information_schema.TABLES
GROUP BY table_schema;
SELECT
CONCAT(table_schema, '.', table_name) AS "Table",
ROUND(((data_length + index_length) / 1024 / 1024), 2) AS "Total size, MB",
ROUND(((data_length) / 1024 / 1024), 2) AS "Data size, MB",
ROUND(((index_length) / 1024 / 1024), 2) AS "Index size, MB"
FROM information_schema.TABLES
WHERE table_schema NOT IN ("information_schema", "mysql");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment