Skip to content

Instantly share code, notes, and snippets.

@fnkr
Created February 20, 2018 09:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fnkr/aa7691ed0274792f36f659205ccc58c5 to your computer and use it in GitHub Desktop.
Save fnkr/aa7691ed0274792f36f659205ccc58c5 to your computer and use it in GitHub Desktop.
Human readable overview of MySQL/MariaDB database size
SELECT table_schema "Database",
Round(Sum(data_length) / 1024 / 1024, 0) "Data size (in MB)",
Round(Sum(data_length) / 1024 / 1024 / 1024, 3) "Data size (in GB)",
Round(Sum(index_length) / 1024 / 1024, 0) "Index size (in MB)",
Round(Sum(index_length) / 1024 / 1024 / 1024, 3) "Index size (in GB)",
Round(Sum(data_length + index_length) / 1024 / 1024, 0) "Total size (in MB)",
Round(Sum(data_length + index_length) / 1024 / 1024 / 1024, 3) "Total size (in GB)"
FROM information_schema.tables
GROUP BY table_schema;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment