Last active
December 4, 2021 08:20
-
-
Save gh640/26eba264c2e8aaa11c2691ed534327a7 to your computer and use it in GitHub Desktop.
List up large database tables in MySQL / MariaDB
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
| -- All databases. | |
| SELECT | |
| table_schema AS `Database`, | |
| ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) AS `Size in MB` | |
| FROM information_schema.tables | |
| GROUP BY `Database` | |
| ORDER BY `Size in MB` DESC; |
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
| -- See: https://stackoverflow.com/questions/9620198/how-to-get-the-sizes-of-the-tables-of-a-mysql-database | |
| -- Largest 10 tables. | |
| SELECT | |
| table_schema AS `Database`, | |
| table_name AS `Table`, | |
| round(((data_length + index_length) / 1024 / 1024), 2) AS `Size in MB` | |
| FROM information_schema.TABLES | |
| ORDER BY `Size in MB` DESC | |
| LIMIT 10; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment