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 synchronize access to various
structures but they differ in internals
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
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
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
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
NASI SPONSORZY I PARTNERZY

Organizacja: Polskie Stowarzyszenie Użytkowników SQL Server - PLSSUG
Produkcja: DATA MASTER Maciej Pilecki

More Related Content

PPTX
Locking and concurrency
PDF
SQLDay2013_ChrisWebb_DAXMD
PDF
MySQL overview
PPTX
An Introduction To Oracle Database
PPTX
SQL locks-presentation
PDF
Understanding Locking Mechanisms in Database Systems
PPTX
Presentation on NOSQL and mongodb .pptx
PPTX
Oracle Database Architecture
Locking and concurrency
SQLDay2013_ChrisWebb_DAXMD
MySQL overview
An Introduction To Oracle Database
SQL locks-presentation
Understanding Locking Mechanisms in Database Systems
Presentation on NOSQL and mongodb .pptx
Oracle Database Architecture

Similar to SQLDay2013_MaciejPilecki_Lock&Latches (7)

PDF
Concurrency in SQL Server (SQL Night #24)
PPTX
Hekaton introduction for .Net developers
PDF
Pl sql-ch3
PDF
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASS DBA Virtu...
PDF
Ora 4 the_sqldba
PDF
MySQL Day Paris 2016 - MySQL as a Document Store
PPTX
Introduction to Redis
Concurrency in SQL Server (SQL Night #24)
Hekaton introduction for .Net developers
Pl sql-ch3
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASS DBA Virtu...
Ora 4 the_sqldba
MySQL Day Paris 2016 - MySQL as a Document Store
Introduction to Redis
Ad

More from Polish SQL Server User Group (20)

PDF
SQLDay2013_PawełPotasiński_ParallelDataWareHouse
PDF
SQLDay2013_PawełPotasiński_GeografiaSQLServer2012
PDF
SQLDay2013_MarekAdamczuk_Kursory
PDF
SQLDay2013_MarcinSzeliga_SQLServer2012FastTrackDWReferenceArchitectures
PDF
SQLDay2013_MarcinSzeliga_DataInDataMining
PDF
SQLDay2013_GrzegorzStolecki_RealTimeOLAP
PDF
SQLDay2013_GrzegorzStolecki_KonsolidacjaBI
PDF
SQLDay2013_Denny Cherry - Table indexing for the .NET Developer
PDF
SQLDay2013_Denny Cherry - SQLServer2012inaHighlyAvailableWorld
PDF
SQLDay2013_DennyCherry_GettingSQLServiceBrokerUp&Running
PDF
SQLDay2013_ChrisWebb_SSASDesignMistakes
PDF
SQLDay2013_ChrisWebb_CubeDesign&PerformanceTuning
PDF
SQLDay2013_MarcinSzeliga_StoredProcedures
PDF
SQL DAY 2012 | DEV Track | Session 6 - Master Data Management by W.Bielski 6 ...
PDF
SQL DAY 2012 | DEV Track | Session 8 - Getting Dimension with Data by C.Tecta...
PDF
SQL DAY 2012 | DEV Track | Session 9 - Data Mining Analiza Przepływowa by M.S...
DOCX
26th_Meetup_of_PLSSUG_WROCLAW-ColumnStore_Indexes_byBeataZalewa_scripts
PDF
26th_Meetup_of_PLSSUG-ColumnStore_Indexes_byBeataZalewa_session
PDF
SQLDay2011_Sesja03_Fakty,MiaryISwiatRealny_GrzegorzStolecki
PDF
SQLDay2011_Sesja02_Collation_Marek Adamczuk
SQLDay2013_PawełPotasiński_ParallelDataWareHouse
SQLDay2013_PawełPotasiński_GeografiaSQLServer2012
SQLDay2013_MarekAdamczuk_Kursory
SQLDay2013_MarcinSzeliga_SQLServer2012FastTrackDWReferenceArchitectures
SQLDay2013_MarcinSzeliga_DataInDataMining
SQLDay2013_GrzegorzStolecki_RealTimeOLAP
SQLDay2013_GrzegorzStolecki_KonsolidacjaBI
SQLDay2013_Denny Cherry - Table indexing for the .NET Developer
SQLDay2013_Denny Cherry - SQLServer2012inaHighlyAvailableWorld
SQLDay2013_DennyCherry_GettingSQLServiceBrokerUp&Running
SQLDay2013_ChrisWebb_SSASDesignMistakes
SQLDay2013_ChrisWebb_CubeDesign&PerformanceTuning
SQLDay2013_MarcinSzeliga_StoredProcedures
SQL DAY 2012 | DEV Track | Session 6 - Master Data Management by W.Bielski 6 ...
SQL DAY 2012 | DEV Track | Session 8 - Getting Dimension with Data by C.Tecta...
SQL DAY 2012 | DEV Track | Session 9 - Data Mining Analiza Przepływowa by M.S...
26th_Meetup_of_PLSSUG_WROCLAW-ColumnStore_Indexes_byBeataZalewa_scripts
26th_Meetup_of_PLSSUG-ColumnStore_Indexes_byBeataZalewa_session
SQLDay2011_Sesja03_Fakty,MiaryISwiatRealny_GrzegorzStolecki
SQLDay2011_Sesja02_Collation_Marek Adamczuk
Ad

Recently uploaded (20)

PDF
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
DOCX
Cambridge-Practice-Tests-for-IELTS-12.docx
PPTX
Introduction to pro and eukaryotes and differences.pptx
PDF
FOISHS ANNUAL IMPLEMENTATION PLAN 2025.pdf
PDF
Uderstanding digital marketing and marketing stratergie for engaging the digi...
PDF
IGGE1 Understanding the Self1234567891011
PDF
FORM 1 BIOLOGY MIND MAPS and their schemes
PDF
Environmental Education MCQ BD2EE - Share Source.pdf
PPTX
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
PDF
LDMMIA Reiki Yoga Finals Review Spring Summer
PPTX
B.Sc. DS Unit 2 Software Engineering.pptx
PPTX
ELIAS-SEZIURE AND EPilepsy semmioan session.pptx
PPTX
Unit 4 Computer Architecture Multicore Processor.pptx
PDF
HVAC Specification 2024 according to central public works department
PDF
1.3 FINAL REVISED K-10 PE and Health CG 2023 Grades 4-10 (1).pdf
PDF
Hazard Identification & Risk Assessment .pdf
DOC
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
PPTX
Computer Architecture Input Output Memory.pptx
PDF
AI-driven educational solutions for real-life interventions in the Philippine...
PDF
Practical Manual AGRO-233 Principles and Practices of Natural Farming
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
Cambridge-Practice-Tests-for-IELTS-12.docx
Introduction to pro and eukaryotes and differences.pptx
FOISHS ANNUAL IMPLEMENTATION PLAN 2025.pdf
Uderstanding digital marketing and marketing stratergie for engaging the digi...
IGGE1 Understanding the Self1234567891011
FORM 1 BIOLOGY MIND MAPS and their schemes
Environmental Education MCQ BD2EE - Share Source.pdf
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
LDMMIA Reiki Yoga Finals Review Spring Summer
B.Sc. DS Unit 2 Software Engineering.pptx
ELIAS-SEZIURE AND EPilepsy semmioan session.pptx
Unit 4 Computer Architecture Multicore Processor.pptx
HVAC Specification 2024 according to central public works department
1.3 FINAL REVISED K-10 PE and Health CG 2023 Grades 4-10 (1).pdf
Hazard Identification & Risk Assessment .pdf
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
Computer Architecture Input Output Memory.pptx
AI-driven educational solutions for real-life interventions in the Philippine...
Practical Manual AGRO-233 Principles and Practices of Natural Farming

SQLDay2013_MaciejPilecki_Lock&Latches

  • 1. NASI SPONSORZY I PARTNERZY
  • 2. SQL Server Concurrency Structures: Lock, Latches and Spinlocks Maciej Pilecki
  • 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