252 GB of empty space, and how much history fits in 1 TB
A MySQL database reported 25.6 GiB but used 265 GB on disk. After reclaiming it, I built a sizing model and a 1 TB dataset that matched the forecast within 0.6%.
- reclaimed from bloated partitions
- 252 GB
- of history in 1 TB at ~7,000 values/s
- 23 days
- forecast accuracy on 816 GiB of history
- 99.7%
The question
A SaaS platform stored its time-series data in MySQL 8.4, in tables partitioned by day: raw values for recent weeks, hourly aggregates for a year. The team needed two answers: how many days of raw data fit into a 1 TB database at the expected load of 6,500–7,000 values per second, and a realistic 1 TB dataset to test backup and restore on.
Finding 1: 252 GB that nobody could see
The database looked healthy: no InnoDB corruption, no deadlocks, nothing waiting in the cleanup queue. Butinformation_schema reported 25.6 GiB of data, while the database directory on disk took 265 GB.
| Partition | Rows | File on disk |
|---|---|---|
| Text values, one day | 0 | 196.55 GB |
| Integer values, same day | 3,576 | 6.98 GB |
| Float values, same day | 33,181 | 3.77 GB |
| All tables, next day (healthy) | 250,789,954 | 43.60 GB |
Repeated test runs had created and removed large amounts of data. The rows were deleted withDELETE, and InnoDB does not give that space back to the filesystem. One partition held zero rows in a 196 GB file.
Fix: the affected partitions were dropped with ALTER TABLE … DROP PARTITION, which removes the file instead of the rows. The directory shrank from 265 GB to 13 GiB without a long table rebuild such as OPTIMIZE TABLE.
Finding 2: write rate sizes raw data, series count sizes aggregates
For the forecast I took a partition that had been filled cleanly, without deletes, so its size was not distorted by fragmentation. It gave 4.86 GiB per day for every 1,000 values per second.
The first answer was 28 days. It was wrong, because the test data wrote values for only about 5,500 series at a very high frequency. The hourly aggregate tables grow with the number of series, not with the write rate. Rebuilt for a realistic profile (about 516,000 series, 79 s average interval), a year of aggregates grew from 110 to 217 GiB, and the answer moved to 23 days of raw data at 7,142 values/s (25.6 days at 6,507).
Finding 3: bulk loads are 15% denser than live writes
The first full day of generated data came out 13% smaller than the model: 28.0 GiB instead of 32.2. The cause is InnoDB page fill. A bulk load arrives sorted by primary key (series, timestamp) and packs pages almost full. Live writes arrive interleaved across series, split pages and leave them partly empty.
| Table | Live (model) | Bulk load | Difference |
|---|---|---|---|
| Integer values | 54.2 | 46.3 | −14.6% |
| Float values | 54.6 | 46.4 | −15.0% |
| Text values | 448.0 | 370.6 | −17.3% |
| Hourly aggregates | 70.0 | 64.4 | −8.0% |
So there are two correct numbers for two different questions: a live server holds 23 days in 1 TB, while a bulk-loaded test database needs 28 days of data to reach the same size. The test dataset was built with 28 days, and the one day written live by the application came out at 32.1 GiB, as the model predicted.
The load
- ~16.5 billion rows generated on the fly and streamed with
LOAD DATA LOCAL INFILE. - Parallel by day, sequential by series within a day: separate partitions are separate files and separate B-trees, so loaders never compete for the same pages.
- 70 GiB/hour sustained, peaking at 600,000 rows/s; a single
LOAD DATAis single-threaded and gave 210,000. The limit was CPU, not the NVMe disk. - Result: 1,043.5 GiB against a forecast of about 1,037. Raw data came in at 99.7% of the model, aggregates at 99.1%. Zero MySQL errors.
Side finding: row-by-row cleanup fighting partitioning
The application log reported the database as down about 57 times an hour. The connection limit was not the issue (102 of 300 used, zero aborted connects). The real error was underneath: Lock wait timeout exceededon a DELETE of old aggregates.
The application's own cleanup job was still deleting expired rows one by one, although partition drops already enforced retention. Those deletes were redundant on a partitioned database and collided with long transactions.Recommendation: turn off the row-by-row cleanup for partitioned tables and let partition drops do the job.
"How big is my database" is a different question from "how big are my files". When the numbers disagree, the gap is usually space that DELETE never returned, and on partitioned tables it is reclaimed by dropping partitions, not by deleting rows.