Quick revision
The short answer
Oracle updates rows in place and keeps old versions in undo, so its failure mode is a long query hitting ORA-01555. PostgreSQL writes a whole new row version into the table on every update and leaves the old one as a dead tuple, so it needs VACUUM to reclaim space, and long transactions do not fail but block cleanup and cause bloat. Teams must also plan for transaction ID wraparound, tune fillfactor and HOT updates on update-heavy tables, and change monitoring from undo usage to bloat, oldest transaction age and autovacuum activity.
What to remember
In this answer, we saw that Oracle updates in place and keeps old versions in undo, while PostgreSQL writes new tuples into the table and leaves dead ones for VACUUM. That changes operations: autovacuum needs tuning on large tables, long or idle transactions cause bloat across the database instead of ORA-01555 errors, transaction id wraparound must be prevented by freezing, update-heavy tables benefit from HOT updates and a lower fillfactor, and monitoring moves from undo usage to bloat, oldest transaction age, autovacuum activity and xid age.
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.
Oracle updates rows in place and keeps old versions in undo, so its failure mode is a long query hitting ORA-01555. PostgreSQL writes a whole new row version into the table on every update and leaves the old one as a dead tuple, so it needs VACUUM to reclaim space, and long transactions do not fail but block cleanup and cause bloat. Teams must also plan for transaction ID wraparound, tune fillfactor and HOT updates on update-heavy tables, and change monitoring from undo usage to bloat, oldest transaction age and autovacuum activity.
Why this question is asked
On paper Oracle and PostgreSQL look the same: both give readers a snapshot and never make them wait for writers. In operation they behave very differently, because they store old versions in different places. Teams that move without knowing this are surprised by tables that keep growing, by an idle connection that hurts the whole database, and by a wraparound warning they have never heard of. Interviewers ask this to see whether we can prepare a team for those differences before they become incidents. In this answer, we will recap how each engine stores versions, then go through the consequences one by one: vacuum and bloat, long transactions, wraparound, update-heavy tables, and what to monitor.
1A Quick Recap: Where Each Engine Keeps Old Versions
In Oracle, an UPDATE changes the row in its block and writes the old values into the undo tablespace. The table itself stays the same size. Readers who need the old version rebuild it from undo, and once undo is old enough, it is simply overwritten. Cleanup is automatic and free, but a reader that needs very old undo can find it gone and fail with ORA-01555.
In PostgreSQL, an UPDATE does not change the existing row. It marks the old row version, called a tuple, as ended by this transaction (its xmax), and inserts a complete new tuple elsewhere in the table. A DELETE only marks the tuple. The old tuples stay in the table as dead tuples until VACUUM confirms no running transaction can still see them and frees the space for reuse.
| Aspect | Oracle | PostgreSQL |
|---|---|---|
| UPDATE writes | Row changed in place, old values to undo | New tuple in the table, old tuple marked dead |
| Cleanup | Undo overwritten after retention | VACUUM frees dead tuples |
| Long query or transaction | May fail with ORA-01555 | Never fails, but blocks cleanup: bloat |
| Special risk | Undo sizing | Transaction ID wraparound |
| Watch | Undo usage, V$UNDOSTAT | Bloat, oldest xmin, autovacuum runs |
2VACUUM and Autovacuum Become Part of Daily Life
Because dead tuples live in the table, someone must remove them. PostgreSQL's autovacuum daemon does this in the background. By default it vacuums a table when dead tuples exceed 50 rows plus 20 percent of the table (autovacuum_vacuum_scale_factor = 0.2). On a 100 million row table, that means 20 million dead tuples before cleanup starts, which is far too late for a busy table. So teams coming from Oracle need a new habit: tune autovacuum per table for large, hot tables.
VACUUM frees space inside the table for new tuples, but it normally does not give the space back to the operating system. A table that bloated to three times its size stays that size until it is rewritten, for example with VACUUM FULL, which locks the table, or with an online tool such as pg_repack. Prevention is far cheaper than repair.
3Long Transactions: Bloat Instead of Errors
This is the most important behaviour change. In Oracle, a long-running report risks its own failure. In PostgreSQL, a long-running transaction never fails for this reason, but VACUUM cannot remove any dead tuple that the oldest open snapshot might still need, in any table of the database. So one forgotten transaction stops cleanup everywhere, and busy tables grow for as long as it stays open.
The worst offender is a connection left idle in transaction, for example a Java service that began a transaction, then waited on a slow HTTP call while holding it. Replication slots that a consumer has stopped reading and hot_standby_feedback from replicas with long queries hold cleanup back in the same way. The fix is mostly discipline plus guard rails.
4Transaction ID Wraparound
PostgreSQL stamps each tuple with 32-bit transaction ids, which means about 4 billion values, compared in a circle so that roughly 2 billion are in the past and 2 billion in the future. Before old tuples fall off that window, VACUUM must freeze them, marking them as visible to everyone. If freezing falls too far behind, PostgreSQL first warns and eventually refuses new transactions to protect the data.
Autovacuum normally handles this through anti-wraparound vacuums, triggered when a table's age passes autovacuum_freeze_max_age, 200 million by default. The danger is the same as for bloat: a long transaction or a stuck replication slot stops freezing too. So we monitor age(datfrozenxid) per database and alert well before it approaches a billion. Oracle teams have no equivalent concept, which is why this belongs in their training.
5Update-Heavy Tables: Fillfactor and HOT Updates
Because every update writes a new tuple, it would normally also add a new entry to every index on the table, which makes updates expensive. PostgreSQL avoids this with HOT, heap-only tuple, updates: if no indexed column changed and the new tuple fits on the same page, the indexes are not touched at all. Two design rules follow. We avoid indexing columns that change often, such as a last_seen timestamp, and we leave free space on each page with a lower fillfactor so the new version fits next to the old one.
6Changing What We Monitor
Oracle dashboards that track undo tablespace usage and ORA-01555 counts have no meaning in PostgreSQL. The new dashboard tracks table and index bloat for the largest tables, dead tuples and last autovacuum time from pg_stat_user_tables, the age of the oldest transaction and of idle-in-transaction sessions, transaction id age per database, and replication slot lag. Each of these needs an alert with an owner, because the failure is slow and silent until it is serious.
7Follow-up questions
Is PostgreSQL's approach worse than Oracle's?
It is a different trade-off. PostgreSQL makes rollback instant and never fails a long query for lack of old versions, but it pays with vacuum work and the risk of bloat. Oracle keeps tables compact but needs undo sizing and can fail long queries. Neither is free; teams just need to manage the cost they actually have.
How do you find bloated tables?
The pgstattuple extension measures dead and free space exactly but reads the whole table. For a regular dashboard, estimate queries based on statistics are cheaper, and comparing a table's size with its expected size from row count and row width gives a good first signal.
Do Java connection pools make this worse?
They can, if a transaction is left open on a pooled connection. With Spring, keeping @Transactional methods short and never making remote calls inside them is the main defence, and idle_in_transaction_session_timeout catches the cases that slip through.
8Conclusion
In this answer, we saw that Oracle updates in place and keeps old versions in undo, while PostgreSQL writes new tuples into the table and leaves dead ones for VACUUM. That changes operations: autovacuum needs tuning on large tables, long or idle transactions cause bloat across the database instead of ORA-01555 errors, transaction id wraparound must be prevented by freezing, update-heavy tables benefit from HOT updates and a lower fillfactor, and monitoring moves from undo usage to bloat, oldest transaction age, autovacuum activity and xid age.
Open with
The key difference is where old versions live. Oracle updates the row in place and puts the old values in undo, so the table stays compact and the risk is that a long query finds its undo overwritten and fails with ORA-01555.
Then, if they want more
PostgreSQL writes a new tuple for every update and leaves the old one in the table as a dead tuple, so VACUUM has to clean up. I would prepare teams for four things.
First, autovacuum needs per-table tuning, because the default 20 percent threshold is far too late for a hundred million row table, and bloat does not shrink by itself. Second, long transactions behave differently: nothing fails, but the oldest open snapshot stops cleanup across the whole database, so an idle-in-transaction connection from a Java service can bloat every hot table.
I would set idle_in_transaction_session_timeout and keep transactions short. Third, transaction id wraparound: ids are 32-bit, so autovacuum must freeze old tuples, and we alert on age of datfrozenxid long before it gets near a billion. Fourth, update-heavy tables need HOT updates, which means not indexing frequently changed columns and lowering fillfactor so new versions fit on the same page.
And monitoring changes from undo usage to bloat, dead tuples, oldest transaction age, autovacuum activity and replication slot lag.
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 "You are moving a workload from Oracle to PostgreSQL. Both use MVCC, but differently....": https://scrivio-interview-library.netlify.app/databases/oracle-and-sql-server/fff8395093/