Created
February 19, 2020 14:26
-
-
Save fdv/19e98eef5c0b0e3e5dc83bda67e3639d to your computer and use it in GitHub Desktop.
MySQL breakdown of table size between data and index
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
SELECT | |
ROUND(SUM(DAT) /1024/1024/1024, 2), | |
ROUND(SUM(NDX) /1024/1024/1024, 2), | |
TBL | |
FROM | |
( | |
SELECT TBLN, DAT,NDX,TBL,IF(px>4,4,px) pw1,IF(py>4,4,py) pw2,IF(pz>4,4,pz) pw3 | |
FROM | |
( | |
SELECT table_name TBLN, data_length DAT,index_length NDX,data_length+index_length TBL, | |
FLOOR(LOG(IF(data_length=0,1,data_length))/LOG(1024)) px, | |
FLOOR(LOG(IF(index_length=0,1,index_length))/LOG(1024)) py, | |
FLOOR(LOG(data_length+index_length)/LOG(1024)) pz | |
FROM information_schema.tables | |
WHERE table_schema='mydb' | |
GROUP BY table_name | |
) AA | |
) A,(SELECT 'B KBMBGBTB' units) B; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment