Issue¶
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.
Resolution¶
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:
- Using MySQL client
- Using drush sqlq
Note that there needs to be a conversion of the data from bytes to megabytes (MB).
Using MySQL client¶
This assumes that you have connected using 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)
Using drush sqlq¶
This assumes that you have ssh'ed into your environment. Once connected, run the following command:
drush sqlq '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:
mysite.prod@sshd-79a5cb2396-llj6z:/var/www/html/docroot/sites/default$ drush sqlq '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;'
b7aa71b3624148daa16f87b56a274a8f 387.1
information_schema 0.2