Created
December 3, 2014 04:49
-
-
Save yevrah/e23d6775b0c008312f9f to your computer and use it in GitHub Desktop.
MySQL: Table Size States
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
-- Get Table Sizes | |
SELECT NOW(), | |
TABLE_SCHEMA, | |
TABLE_NAME, | |
ENGINE, | |
TABLE_ROWS, | |
DATA_LENGTH / 1024 / 1024, | |
INDEX_LENGTH / 1024 / 1024, | |
DATA_FREE, | |
AUTO_INCREMENT | |
FROM INFORMATION_SCHEMA.TABLES; | |
-- Sizes grouped by schema | |
SELECT NOW(), | |
TABLE_SCHEMA, | |
ENGINE, | |
SUM(TABLE_ROWS), | |
SUM(DATA_LENGTH / 1024 / 1024), | |
SUM(INDEX_LENGTH / 1024 / 1024), | |
SUM(DATA_FREE) | |
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