16. Transactions and Concurrency
PostgreSQL uses MVCC (multi-version concurrency control). Understanding transactions and locks is essential for correctness under concurrent load.
Decision Guide
| Goal | Prefer | Notes |
|---|---|---|
| Default OLTP safety | READ COMMITTED | PostgreSQL default |
| Consistent snapshot reads | REPEATABLE READ | Same snapshot within transaction |
| Strict anomaly prevention | SERIALIZABLE | May require retries |
| Work queues | FOR UPDATE SKIP LOCKED | Avoids workers blocking each other |
Lessons
What's Next
- Continue to 17. User Management and Security