Difference between Optimistic and Pessimistic Locking.

Updated Apr 28, 2026

Short answer

Pessimistic locks the data for the duration; Optimistic checks for changes before commit.

Deep explanation

Exploring concurrency control. How MVCC (Multi-Version Concurrency Control) works to allow readers and writers to operate without blocking each other.

Real-world example

Banking systems using SERIALIZABLE isolation to prevent double-spending.

Common mistakes

  • Over-indexing tables which slows down INSERT/UPDATE operations.

Follow-up questions

  • What is Dirty Read?

More Databases interview questions

View all →