Last active
July 31, 2019 11:24
-
-
Save hidayat365/de3dfc2817fccff1cdf555229d1a01c4 to your computer and use it in GitHub Desktop.
MySQL Database and Table Size Query
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT table_schema "DB Name", | |
Round(Sum(data_length + index_length) / 1024 / 1024, 1) "DB Size (MB)" | |
FROM information_schema.tables | |
GROUP BY table_schema; | |
SELECT table_name | |
, round(((table_rows) / 1024 / 1024), 2) as "Row Count (mil)" | |
, round(((data_length) / 1024 / 1024), 2) as "Data Size (MB)" | |
, round(((index_length) / 1024 / 1024), 2) as "Index Size (MB)" | |
, round(((data_length + index_length) / 1024 / 1024), 2) as "Table Size (MB)" | |
FROM information_schema.TABLES | |
WHERE table_schema = "DATABASE_NAME" | |
ORDER BY round(((data_length + index_length) / 1024 / 1024), 2) DESC; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment