What is SQL Server latch vs spinlock vs lock, and how are they different internally?
Updated May 17, 2026
Short answer
Locks control transaction concurrency, latches protect in-memory structures, and spinlocks protect ultra-short critical sections.
Deep explanation
SQL Server uses three synchronization primitives at different layers. Locks are transaction-level and respect isolation levels (row/page/table). Latches are lightweight protections for internal structures like pages and allocation maps. Spinlocks are extremely low-level CPU constructs used when contention is expected to be very short; threads spin instead of sleeping. Understanding all three is essential for diagnosing performance issues that are not purely query-related.
Unlock with a Pro subscription to view this section.
View pricingReal-world example
No real-world example available yet.
Unlock with a Pro subscription to view this section.
Upgrade to ProCommon mistakes
No common mistakes listed yet.
Unlock with a Pro subscription to view this section.
Upgrade to ProFollow-up questions
No follow-up questions available yet.
Unlock with a Pro subscription to view this section.
Upgrade to Pro