MySQL / MariaDB: Show disk usage of tables and columns

Posted About 8 years ago. Visible to the public.

You can find out about disk space usage of all tables within your database by running this:

SELECT table_name AS `Table`, round(((data_length + index_length) / 1024 / 1024), 2) `Size (MB)` FROM information_schema.TABLES WHERE table_schema = "$your_database";

Replace $your_database here.

To find out the disk usage of a single column:

SELECT sum(char_length($your_column))/1024/1024 FROM $your_table

Result is in megabytes again.

Thomas Eisenbarth
Last edit
About 8 years ago
Thomas Eisenbarth
License
Source code in this card is licensed under the MIT License.
Posted by Thomas Eisenbarth to makandra dev (2016-04-06 08:36)