Skip to content

Instantly share code, notes, and snippets.

@mrchrisadams
Last active July 14, 2023 10:26
Show Gist options
  • Save mrchrisadams/b5cbc56d5465746a9df5449ac260e729 to your computer and use it in GitHub Desktop.
Save mrchrisadams/b5cbc56d5465746a9df5449ac260e729 to your computer and use it in GitHub Desktop.
This command, when run in a MySQL compatible database like MariaDB will return a list of all the tables, in descending order of tables size in megabyes.
select table_schema as database_name,
table_name,
round(
sum((data_length + index_length + data_free)) / power(1024, 2),
2
) as table_size
from information_schema.tables
where table_schema = 'table_name' -- put your database name here
and table_type = 'BASE TABLE'
group by table_schema,
table_name
order by table_size desc;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment