SQL Server Interview Question #242
What is optimistic concurrency control?
Advanced Transactions & Concurrency Senior Advanced
Detailed Explanation
Optimistic concurrency assumes conflicts are relatively uncommon. Instead of holding restrictive locks for the entire business operation, the application reads data and verifies at update time that the row has not changed since it was read.
In SQL Server applications, a rowversion column is commonly used as a concurrency token. The UPDATE includes both the key and the original rowversion. If zero rows are affected, another transaction has changed or deleted the row.
Optimistic concurrency reduces long-held locks but requires the application to detect and resolve conflicts correctly.