Atomic Database Operations

Today we will explore how to leverage atomic operations without opening a multi-statement transaction, increasing the system’s write throughput without sacrificing correctness. To avoid conflicts with other processes changing the same data, we can lock the rows before updating them, for example with SELECT ... FOR UPDATE. This approach has drawbacks: locks consume database resources for the entire duration of the transaction and can lead to lock contention as writers wait for one another, reducing write throughput. It is generally preferable for transactions to be short. ...

September 2, 2026 · 6 min
☝️