Quick revision
The short answer
Two million rows a day at about 900 bytes each, indexes included, is about 1.8 GB a day, or roughly 660 GB a year before bloat and traffic growth. On top of that we plan 20 to 50 percent for bloat and vacuum lag, space for WAL, temporary files and backups, and we track index growth separately because indexes here are twice the size of the table data. Monthly partitioning makes retention and maintenance cheap, and we revisit the estimate monthly with real growth, because traffic growth compounds.
What to remember
In this answer, we estimated that 2 million rows a day at 900 bytes, indexes included, is about 1.8 GB a day and 660 GB a year, two thirds of it indexes. We then added the things besides raw size: 20 to 50 percent for bloat and vacuum lag, WAL and temporary files, backups on separate storage, replicas and compounding traffic growth, which together take the first year to over a terabyte. Monthly partitioning with an archiving policy caps the online size and turns retention into dropping partitions, and the estimate is refreshed monthly with real measurements.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
Two million rows a day at about 900 bytes each, indexes included, is about 1.8 GB a day, or roughly 660 GB a year before bloat and traffic growth. On top of that we plan 20 to 50 percent for bloat and vacuum lag, space for WAL, temporary files and backups, and we track index growth separately because indexes here are twice the size of the table data. Monthly partitioning makes retention and maintenance cheap, and we revisit the estimate monthly with real growth, because traffic growth compounds.
Why this question is asked
Running out of disk is one of the most avoidable database outages, and also one of the most damaging: when PostgreSQL cannot write WAL, it stops accepting writes, and freeing space under pressure is slow and risky. Interviewers ask for a capacity estimate because it shows whether we can reason with numbers and know what besides the raw rows consumes space. In this answer, we will recap where the bytes go, do the raw calculation, add the overheads step by step, look at indexes and growth, and see how partitioning and archiving change both the size and the maintenance work.
1A Quick Recap of Where the Bytes Go
In PostgreSQL a table is stored as a heap, files of 8 KB pages holding row versions, and each index is a separate structure with its own pages. A row costs more than its column values: each row version has a header of about 23 bytes plus a pointer in the page, and pages are rarely completely full. Because of MVCC, the way PostgreSQL lets readers and writers work without blocking each other, an UPDATE writes a new row version and the old one stays until VACUUM cleans it up. The space taken by these dead versions, and the free space they leave behind, is called bloat.
The question's figures say a row is about 300 bytes in the table and about 900 bytes once its index entries are included, so the indexes cost about 600 bytes per row. That is our starting point.
2The Raw Calculation
First the arithmetic, with the steps written out so anyone can check them.
So the honest raw answer is about 660 GB of new data a year. Notice that two thirds of it is indexes. That changes what we should optimise: dropping an unused index might save more space than any change to the table itself. The query at the end shows how to replace the estimate with real measurements as soon as the table exists.
3Adding the Overheads Besides Raw Size
Raw size is never the space we need. In PostgreSQL, bloat from updates and deletes, and from vacuum falling behind during busy periods, commonly adds 20 to 50 percent, more if rows are updated often, as order rows are when their status changes. The write-ahead log, WAL, where every change is written before it reaches the table, needs space for at least max_wal_size, and much more if a replication slot holds WAL back because a replica or CDC consumer is lagging; a stuck slot is a classic cause of a full disk. Temporary files from large sorts and hash joins need room during peak queries. And backups, base backups plus archived WAL for point-in-time recovery, usually live on separate storage but must be sized too, often at several times the database size depending on retention.
| Item | Estimate | Note |
|---|---|---|
| Raw new data | 660 GB | 2 M rows x 900 B x 365 |
| Bloat and vacuum lag | +130 to 330 GB | 20 to 50 percent |
| Traffic growth (5 percent a month) | +200 GB | about 955 M rows instead of 730 M |
| WAL and temp files | +50 to 100 GB | more if a replication slot lags |
| Total on the primary | about 1.1 to 1.3 TB | plus the same on each replica |
| Backups | separate storage | base backups plus WAL archive |
4Index Growth and Traffic Growth
Indexes deserve their own line because they grow differently. B-tree indexes on random keys, such as UUIDs, split pages and stay around 70 percent full, and indexes on frequently updated columns bloat faster than the table. Every new index a developer adds for a new query adds to every future row. So we track index size per index, and look at pg_stat_user_indexes for indexes that are never scanned.
Traffic growth compounds. If orders grow 5 percent a month, the daily rate at the end of the year is 1.05 to the power 12, about 1.8 times today's. Summed over the year, that is about 955 million rows instead of 730 million, around 860 GB raw instead of 660 GB. That is why the estimate must be revisited monthly against real growth, and why planning only for today's rate leads to surprises in month nine.
5Partitioning and Archiving
With 2 million rows a day, the table holds 730 million rows after a year. Partitioning by month splits it into twelve smaller tables behind one parent, each with its own indexes. Combined with an archiving policy, such as keeping 13 months online and moving older orders to cheaper storage or a warehouse, the online size stops growing once the retention window is full.
The difference from deleting old rows is large. A DELETE of 60 million rows writes WAL for every row, leaves 60 million dead versions for vacuum, and the space is reused but not returned. Dropping a partition is a metadata change that frees the files at once.
6Follow-up questions
How would partitioning change maintenance work?
Most maintenance becomes per partition and therefore smaller. Vacuum and analyze work on one month's table at a time, and old partitions that no longer change need almost no vacuuming once frozen. Index rebuilds can be done partition by partition. Retention becomes detach and drop instead of huge deletes. The new work is creating future partitions ahead of time, usually with a scheduled job or an extension such as pg_partman, and making sure queries include the partition key so the planner can skip irrelevant partitions.
What alert would you set for disk space?
Alert on the forecast, not only on usage: for example when the current growth rate predicts a full disk within 30 days, plus a hard alert at 80 percent used. Also alert on replication slot lag in bytes, because a stuck slot can fill a disk in hours.
Why does the 300-byte row take more than 300 bytes on disk?
Each row version carries a header of about 23 bytes and a 4-byte pointer, values are aligned, pages keep some free space, and updates create new versions. So we measure average bytes per row from pg_relation_size divided by the row count rather than summing column sizes.
7Conclusion
In this answer, we estimated that 2 million rows a day at 900 bytes, indexes included, is about 1.8 GB a day and 660 GB a year, two thirds of it indexes. We then added the things besides raw size: 20 to 50 percent for bloat and vacuum lag, WAL and temporary files, backups on separate storage, replicas and compounding traffic growth, which together take the first year to over a terabyte. Monthly partitioning with an archiving policy caps the online size and turns retention into dropping partitions, and the estimate is refreshed monthly with real measurements.
Open with
Two million rows a day at about 900 bytes including indexes is 1.8 GB a day, so about 660 GB a year, and two thirds of that is indexes, about 440 GB, against about 220 GB of table data.
Then, if they want more
That is the raw number, and I would not provision only that. In PostgreSQL I would add 20 to 50 percent for bloat and vacuum lag, especially since order rows get updated as their status changes.
Then WAL, at least max_wal_size and much more if a replication slot lags, temporary files for big sorts, and backups with the WAL archive on separate storage, plus the same disk on every replica.
I would also model traffic growth: at 5 percent a month the daily rate nearly doubles by year end and the year is closer to 860 GB raw. So the realistic plan is well over a terabyte on the primary. I would track index size separately and look for unused indexes, since they are the bigger part.
And I would partition the table by month with an archiving policy, say 13 months online, because then retention is a quick detach and drop instead of a huge delete that bloats the table, and vacuum works per partition.
Finally, I would compare the estimate with real measurements every month and alert on forecasted disk exhaustion, not only on current usage.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- PostgreSQL documentation, MySQL reference manual
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Your orders table grows by 2 million rows a day, each row about 300 bytes including...": https://scrivio-interview-library.netlify.app/databases/database-operations/6b33c75a51/