Advertisement
Intermediate SQL Server, In-Memory OLTP (Memory-Optimized Tables)

How does the concurrency model of In-Memory OLTP differ from traditional disk based tables, and why does this improve performance?

Short answer

In-Memory OLTP uses an optimistic concurrency model based on comparing row versions, entirely avoiding traditional locks and latches that disk based tables rely on to manage concurrent access, which removes a major source of contention and waiting when many transactions are…

Save SQL Server mock interview
Advertisement
AModel answer
In-Memory OLTP uses an optimistic concurrency model based on comparing row versions, entirely avoiding traditional locks and latches that disk based tables rely on to manage concurrent access, which removes a major source of contention and waiting when many transactions are trying to read and write data at the exact same time.
Example

-- Memory optimized tables use row versioning instead of locks -- Multiple transactions can proceed without blocking each other -- as long as they are not modifying the exact same row version

Real-world example
A high volume order processing system built on memory optimized tables handles thousands of simultaneous transactions with far less blocking and waiting compared to its previous disk based implementation, since there are no traditional locks to contend for.
Likely follow-ups
  • What happens if two transactions try to update the exact same row at the same time?
  • Does this optimistic model ever require a transaction to be retried?
Related topics