Last active
July 13, 2021 10:36
-
-
Save mysqlboy/b7e9a5845c3af47d19eeaee558ec59d9 to your computer and use it in GitHub Desktop.
MySQL table sizes
This file contains 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
-- top 10 | |
SELECT | |
CONCAT(table_schema,'.',table_name) AS `tbl`, | |
round(((data_length + index_length) / POW(1024,2)), 2) `Size_MB` | |
FROM | |
information_schema.TABLES | |
ORDER BY | |
(data_length + index_length) | |
DESC limit 10; | |
-- specific schema | |
SET @tableschema = 'apps'; | |
SELECT | |
CONCAT(table_schema,'.',table_name) AS `tbl`, | |
round(((data_length + index_length) / POW(1024,2)), 2) `Size_MB` | |
FROM | |
information_schema.TABLES | |
WHERE | |
table_schema = @tableschema | |
ORDER BY | |
(data_length + index_length) | |
DESC limit 10; | |
======= | |
SELECT | |
CONCAT(table_schema,'.',table_name) AS `tbl`, | |
round(((data_length + index_length) / POW(1024,2)), 2) `Size_MB`, | |
table_rows/1000000 as rows_mil | |
FROM | |
information_schema.TABLES | |
WHERE | |
table_name in ( | |
'_billing_events_old', | |
) | |
ORDER BY | |
(data_length + index_length) | |
DESC limit 10; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment