Optimistic Concurrency Control


Last Updated on Mar 08, 2021

Two-phase locking is pessimistic in nature. It is based on the principle that if there is a chance that something might go wrong, it is better to wait until the situation is safe again. Serializable Isolation is itself a pessimistic approach in the extreme - it prefers to lock the entire database for the duration of a transaction.

In contrast, Serializable Snapshot Isolation is an Optimistic Concurrency Control (OCC) technique. Instead of blocking by default, OCC allows transactions to continue in the hope that everything will turn out alright in the end. If and when the transaction wants to commit writes, the database checks whether isolation was violated and aborts the transaction if so.

Though OCC itself is an old idea and Serializable Snapshot Isolation takes the approach of OCC, it is crucial to note that Optimistic Concurrency Control does not perform well under high contention. This type of control behaves better than pessimistic ones only when there is spare capacity and contentions are not too high.


© 2022 Ambitious Systems. All Rights Reserved.