Last active
November 28, 2019 13:21
-
-
Save efenacigiray/e9c9e1318373e298071baa96d8564ac5 to your computer and use it in GitHub Desktop.
Database Size Estimation Queries
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
-- Display size of all databases in a MySQL server | |
SELECT table_schema AS 'Database Name', | |
sum(data_length + index_length) AS 'Size in Bytes', | |
round((sum(data_length + index_length) / 1024 / 1024), 4) AS 'Size in MB' | |
FROM information_schema.TABLES | |
WHERE table_schema NOT IN ('information_schema', | |
'performance_schema', | |
'mysql', | |
'sys') | |
GROUP BY table_schema | |
ORDER BY sum(data_length + index_length) DESC; | |
-- Display size of tables in a database | |
SELECT TABLE_NAME, | |
table_rows, | |
data_length, | |
index_length, | |
round(((data_length + index_length) / 1024 / 1024),2) "Size" | |
FROM information_schema.TABLES | |
WHERE table_schema = "discus"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment