Update bloat in a multitenant PostgreSQL table
A multitenant settings table has 10 million rows and five indexes. Frequent updates have raised the bloat estimate to 50% and peak write rate to 1,800 queries per second.
Jump to resultsInputs
Results
Runs in your browser- Heap and indexes now
- 9GB
- 12-month storage
- 12.24GB
- 36-month storage
- 18.72GB
The modeled hot working set fits in the supplied RAM budget.
| Current heap | 6 GB |
|---|---|
| Current indexes | 3 GB |
| 12-month rows | 13,600,000 |
| 36-month rows | 20,800,000 |
| Hot working set | 1.35 GB |
| Working set / available RAM | 7.858 % |
| Read IOPS | 400 IOPS |
| Write IOPS | 5,400 IOPS |
| Data page I/O | 5,800 IOPS |
| WAL write throughput | 4.32 MB/s |
| Data and WAL throughput | 51.834 MB/s |
| WAL generated per day | 373.248 GB |
What to try
Set a lower bloat scenario and compare its steady-state size with the free disk available during a rewrite. Reclaiming space can itself need temporary storage and WAL bandwidth.
How the estimate works
Heap bytes ≈ rows × (payload + tuple overhead) ÷ fillfactor × (1 + bloat)
The heap estimate includes row overhead, free space from fillfactor, and extra bloat. Index size uses an average entry size, a B-tree overhead factor, and the same bloat factor. Use measured relation sizes to calibrate these estimates when available.
A forecast month is 30 days. When a retention period and a positive arrival rate are set, future rows are capped at arrivals within that retention horizon. The current size uses the supplied row count. Forecast points assume pruning is effective by that point.
Read IOPS comes from uncached page touches. Page I/O assumes 8 KiB pages and a steady write rate. WAL bandwidth uses bytes generated per write. Data page throughput and WAL throughput are added. A WAL segment retention policy, TOAST, maintenance spikes, and replica amplification need separate sizing.
Frequently asked questions
Do tenant-specific index entry sizes matter for this bloat forecast?
Yes. An index using a long tenant key can be larger than the average. Estimate a weighted entry size or model that index separately.
Does ordinary PostgreSQL VACUUM shrink the table to the modeled clean size?
It usually marks space reusable inside the existing relation. Reclaiming space at the filesystem can require a rewrite or a point where trailing pages can be truncated.