3. Concurrency structures
• Main concurrency structures in SQL Server:
– Locks
– Latches
– Spinlocks
• All are used to synchronize access to various
structures but they differ in internals
4. Locks
•
•
•
•
•
•
Used to protect LOGICAL integrity of data
Often held for the duration of the transaction
Lock granularity (ROW, PAGE, TABLE)
Lock mode (S, U, X, IS, IX, Sch, etc.)
Lock escalation
Each lock type has corresponding wait type
5. Latches
• Three main categories:
– Buffer latches (latching pages in cache –
PAGELATCH_*)
– IO latches – used to synchronize I/O (PAGEIOLATCH_*)
– Non-buffer latches (everything else – LATCH_*)
• Each latch type has many corresponding wait types
6. Spinlocks
•
•
•
•
•
•
Light-weight, short-lived synchronization primitives
Used to protect internal server data structures
sys.dm_os_spinlock_stats
NO corresponding wait type!
The thread DOES NOT sleep – it “spins”
Hardest type of contention to troubleshoot
7. Concurrency structures
• Main concurrency structures in SQL Server:
– Locks
– Latches
– Spinlocks
• All are used to synchronize access to various
structures but they differ in internals
8. NASI SPONSORZY I PARTNERZY
Organizacja: Polskie Stowarzyszenie Użytkowników SQL Server - PLSSUG
Produkcja: DATA MASTER Maciej Pilecki