How to Plan Database Storage Growth Before You Hit the Disk Limit
Database storage growth planning means measuring how fast your tables and files actually grow, then setting a threshold that leaves enough headroom to act before a host's disk cap stops writes. You do not need a forecast that is accurate to the byte; you need a repeatable measurement, a trend line, and a rule for when to expand.
Start with the number the host enforces. Disk quotas are usually applied per account or per volume, and the database files, binary logs, temporary files and media uploads often all count against the same pool. Find that number before you measure anything, because a growth rate is meaningless without the ceiling it is approaching.
Measure current usage before you forecast database storage growth
Two measurements matter: the size of the data directory on disk, and the size of the logical data inside the server. The first is what the host bills and caps. The second tells you whether the growth is real rows or just churn from deleted data that has not been reclaimed.
On the host, du gives you the physical picture. Run it against the data directory, which varies by engine, so check the server's configuration for the path.
$ sudo du -sh /var/lib/mysql
4.2G /var/lib/mysql
$ sudo du -sh /var/lib/mysql/* | sort -h | tail -5
1.1G /var/lib/mysql/app_production
820M /var/lib/mysql/analytics
410M /var/lib/mysql/ibtmp1
Inside the server, ask the engine for the logical sizes. In MySQL and MariaDB the information_schema tables expose per-table data and index lengths. The query below returns the largest tables, which is usually where the growth lives.
SELECT table_schema, table_name,
ROUND((data_length + index_length) / 1048576) AS size_mb
FROM information_schema.tables
ORDER BY data_length + index_length DESC
LIMIT 10;
In PostgreSQL the equivalent is a function call per table, or a query against pg_total_relation_size. Either way, the shape of the output is the same: a ranked list of relations. If one table dominates, your forecast is really a forecast for that table.
Turn two snapshots into a growth rate
A single measurement tells you where you are. Two measurements a week or a month apart tell you the slope. Record the date, the data directory size and the top table sizes in a file you keep outside the database, so the measurement survives if the server does not.
The arithmetic is simple. Subtract the earlier size from the later size, divide by the number of days between them, and you have bytes per day. Extrapolate linearly for a first estimate, but treat it as a floor rather than a prediction. Growth is rarely linear for long: an import, a new feature that writes a row per request, or a log table that nobody prunes will bend the line upward.
Watch for the opposite error too. A table that grows and shrinks with a nightly job can look flat on a monthly average while its peak is much higher. Sample at a consistent time of day, ideally just before your heaviest batch job, so the peaks are visible.
Account for what the database does not show you
The logical table sizes miss several things that consume the same disk. Binary logs and write-ahead logs grow with write volume and are only released on rotation or replication acknowledgement. Temporary files appear during large sorts and can briefly exceed the size of the table being sorted. Deleted rows leave free space inside the tablespace that is reused but not returned to the filesystem. And media uploads, if they live on the same volume, are invisible to every query above.
Check the log directory separately with du, and check the upload directory too. If the host caps the whole account, add all of them into one total. That total, not the table size, is the number that hits the ceiling.
Set an alert threshold and a config directive to match
Pick a threshold that gives you enough time to act. If you grow by a certain amount per week and provisioning a larger volume takes a few days, the threshold must sit at least that far below the cap. A reasonable rule is to alert when usage passes a fixed fraction of the quota, and again when it passes a higher one.
Make the check cheap and run it from cron. The script below reads the filesystem usage for the data directory, compares it to a configured limit, and exits with a non-zero status when the threshold is crossed, which is easy to wire into whatever alerting you already have.
#!/bin/sh
LIMIT_MB=20000
WARN_MB=16000
USED_MB=$(du -sm /var/lib/mysql | cut -f1)
if [ "$USED_MB" -ge "$LIMIT_MB" ]; then
echo "CRITICAL: ${USED_MB}MB used of ${LIMIT_MB}MB"; exit 2
elif [ "$USED_MB" -ge "$WARN_MB" ]; then
echo "WARNING: ${USED_MB}MB used of ${LIMIT_MB}MB"; exit 1
fi
echo "OK: ${USED_MB}MB used"; exit 0
On the server side, set the engine's own limits so a runaway query cannot fill the disk in an afternoon. In MySQL and MariaDB, tmp_table_size and max_heap_table_size bound in-memory temporary tables, and innodb_temp_data_file_path bounds the temporary tablespace. Keep those values well below your free space, so a large sort fails the query instead of the disk.
Reduce growth before you buy more disk
Expanding is the last resort, not the first. Before you resize, look for growth that is not data you need. Log tables without a retention policy are the usual culprit. A scheduled delete of rows older than a fixed window, followed by a partition drop where the table is partitioned by date, keeps those tables bounded without touching the rest of the schema.
Check whether deleted rows are being reclaimed. Large deletes leave gaps that the engine reuses but does not shrink, so a table can stay large long after the rows are gone. An optimize or vacuum operation, run during a quiet window, returns that space. It is not free: it rewrites the table and needs temporary room, which is exactly why you do it before the disk is full, not after.
Finally, separate the things that grow at different rates. Media files belong on object storage or a separate volume, not beside the database files, so the database's growth rate is the only one that affects the database quota. That single change often pushes the wall far enough out that the forecast stops being urgent.
Next step: take one measurement today, write it down with the date, and put the alert script in cron. When the second measurement lands, you will have a slope, a threshold and a decision, all before the disk has an opinion.
