Where is my database storage going to?
Platform.sh DevRel
I’ve followed the following article to check my database storage usage:
https://community.platform.sh/t/how-to-determine-database-usage-of-an-environment/180
But the size it reports seems wrong to me.
I’ve imported a 3GB sized database backup. But when I check platform db:size it is reporting 9GB.
Checking database service db...
+----------------+-----------------+--------+
| Allocated disk | Estimated usage | % used |
+----------------+-----------------+--------+
| 14.6 GiB | 9.4 GiB | ~ 64% |
+----------------+-----------------+--------+
Why the big difference?
0
Comments
platform db:sizemakes a good estimate on how much is used, but it can deviate by a few percentages.db:sizeactually has a trick to help you identify wasted space and clean those up.That should clean up some storage, if your tables are small enough you can even run those queries in a cron once a week to keep it nice and clean (Sunday early morning for example).
Warning: do not run a cleanup during production hours unless you really have to. It will lock up tables.
Recommendations
More information
SELECT table_name, round((data_length+index_length)/1048576,2) as size_MB, round((data_free)/1048576,2) as Allocated_but_unused FROM information_schema.tables ORDER BY data_free DESC LIMIT 10;Or sorted by actual data size:
SELECT table_name, round((data_length+index_length)/1048576,2) as size_MB, round((data_free)/1048576,2) as Allocated_but_unused FROM information_schema.tables ORDER BY data_length DESC LIMIT 10;Percona also has a nice article describing how InnoDB deals with storage.
Please sign in to leave a comment.