Database Concurrency & Scaling interview question · Most asked
What's the difference between Read Committed and Repeatable Read in practice?
Summary
Read Committed gives each statement a fresh view of committed data; Repeatable Read gives the whole transaction one snapshot. Multi-statement reports can see inconsistent data under Read Committed.
Longer Answer
- Postgres defaults to Read Committed; its Repeatable Read is snapshot isolation and raises serialization errors when a concurrently updated row is written.
- MySQL InnoDB defaults to Repeatable Read; plain reads use a snapshot, but locking reads and UPDATEs see the latest data — so read-modify-write can still lose updates.
- Neither prevents write skew; that needs locks, constraints or SERIALIZABLE.
Use Repeatable Read (read-only) for consistent reports; set isolation explicitly when correctness depends on it.
Key Points
- RC: per-statement snapshot
- RR: per-transaction snapshot
- Different defaults in Postgres and MySQL
- Neither stops write skew
Deep dive: Isolation Levels in Postgres vs MySQL
More most-asked Database Concurrency & Scaling questions
- How do you prevent overselling in a flash sale with 50,000 buyers in the first minute?
- After a deploy, logs show hundreds of 'deadlock detected' errors per hour on checkout. Walk through how you'd investigate.
- Two customers buy the last item at the same moment and both orders are confirmed. What happened, and how do you prevent it?
- Your service throws 'connection pool exhausted' errors but database CPU is only 20%. What's going on?
- Why shouldn't you call a payment API inside a database transaction?
- Database CPU is at 85%. How do you decide what to optimise before buying a bigger server?
- A user saves their profile and the next page shows the old data. Reads go to replicas. How do you fix it?
- How do you choose a shard key for a multi-tenant SaaS?