Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
NASI SPONSORZY I PARTNERZY
SQL Server Concurrency Structures:
Lock, Latches and Spinlocks
Maciej Pilecki
Concurrency structures
• Main concurrency structures in SQL Server:
– Locks
– Latches
– Spinlocks

• All are used to synch...
Locks
•
•
•
•
•
•

Used to protect LOGICAL integrity of data
Often held for the duration of the transaction
Lock granulari...
Latches
• Three main categories:
– Buffer latches (latching pages in cache –
PAGELATCH_*)
– IO latches – used to synchroni...
Spinlocks
•
•
•
•
•
•

Light-weight, short-lived synchronization primitives
Used to protect internal server data structure...
Concurrency structures
• Main concurrency structures in SQL Server:
– Locks
– Latches
– Spinlocks

• All are used to synch...
NASI SPONSORZY I PARTNERZY

Organizacja: Polskie Stowarzyszenie Użytkowników SQL Server - PLSSUG
Produkcja: DATA MASTER Ma...
Upcoming SlideShare
Loading in …5
×

SQLDay2013_MaciejPilecki_Lock&Latches

415 views

Published on

Published in: Education, Technology, Business
  • Be the first to comment

  • Be the first to like this

SQLDay2013_MaciejPilecki_Lock&Latches

  1. 1. NASI SPONSORZY I PARTNERZY
  2. 2. SQL Server Concurrency Structures: Lock, Latches and Spinlocks Maciej Pilecki
  3. 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. 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. 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. 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. 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. 8. NASI SPONSORZY I PARTNERZY Organizacja: Polskie Stowarzyszenie Użytkowników SQL Server - PLSSUG Produkcja: DATA MASTER Maciej Pilecki

×