For environments running on Cloud Platform technologies, database layer utilization metrics are temporarily unavailable and will be added back as soon as possible, as pointed out in Stack Metrics - Database Layer Metrics.
For environments running on Cloud Classic technologies, database layer utilization metrics are available.
This document guides you through the steps to find out the disk usage of your database by using a MySQL query. This query can be run by using either the MySQL client, or a drush command.
To find the database disk usage we use the MySQL SELECT query against the special table_schema table.
There are two methods presented here to retrieve the disk usage:
drush sqlq commandNote that there needs to be a conversion of the data from bytes to megabytes (MB).
The following methods depend on the MySQL information_schema data that is cached by the MySQL server for up to 24 hours. Therefore, the results might be out of date. In Cloud Platform, this behavior cannot be changed.
If needed, running the ANALYZE TABLE [table_name] query can force MySQL to refresh this information for single tables but it can cause performance problems on busy databases. Use with caution.
This assumes that you have connected through the MySQL client. Once you have connected, run this command:
SELECT table_schema "DB Name", ROUND(SUM(data_length + index_length) / 1024 / 1024, 1) "DB Size in MB" FROM information_schema.tables GROUP BY table_schema;Example output:
mysql> SELECT table_schema "DB Name", ROUND(SUM(data_length + index_length) / 1024 / 1024, 1) "DB Size in MB" FROM information_schema.tables GROUP BY table_schema;
+----------------------------------+---------------+
| DB Name | DB Size in MB |
+----------------------------------+---------------+
| b7aa71b3624148daa16f87b56a274a8f | 411.1 |
| information_schema | 0.2 |
+----------------------------------+---------------+
2 rows in set (0.09 sec)