Calculate and Optimize MySQL Database Size

Computing MySQL database size can provide you useful informations : disk usage, index size, number of rows, lack of index, collations and many more.
Calculating these values use the information database : INFORMATION_SCHEMA, the place that stores information about all the other databases that the MySQL server maintains.

Simple Query to show MySQL Database Usage

This query will show the index and data size in Mb, number of rows per table with database type, partitions and collation.

This MySQL query execution will output something like this :

This is also a good example why I also added database engine and MySQL collation in this query, one table is not in utf8_general_ci but in latin1_swedish_ci.

Another way to show MySQL Database Usage

This query use a MySQL function to compute size in more readable number by changing size numbers units.

This MySQL query will output :

This will make the MySQL table size values more readable as the first query returned 5,711.73 Mb as Table B total size.

Hope this will help you.

1 Response

  1. jonnyboy says:

    Very nice. I added these to my list of useful queries.


Leave a Reply