How to get MySQL Database Size


While carrying out Performance Tests for WSO2 Governance Registry, I had to measure(calculate) MySQL database size. So here I am posting the query which I used to measure the MySQL database size, hoping this could be useful to someone.

SELECT table_schema "Database Name", Round(Sum(data_length + index_length) / 1024 / 1024, 3) "Database Size in MB" FROM   information_schema.tables  GROUP  BY table_schema;


Once this query is executed you can view the database size in formation like this::

mysql> SELECT table_schema "Database Name", Round(Sum(data_length + index_length) / 1024 / 1024, 3) "Database Size in MB" FROM   information_schema.tables  GROUP  BY table_schema;
+--------------------+---------------------+
| Database Name      | Database Size in MB |
+--------------------+---------------------+
| db11                       |               1.834 |
| db12                       |               1.834 |
+--------------------+---------------------+
2 rows in set (1.30 sec)

Comments

Popular posts from this blog

XSLT - Modify Date and DateTime value

Integrate With Mutual Certificate Authentication based Service

Yield Price Sri Lanka - Android Application