A latch is a lightweight internal synchronization mechanism used by SQL Server to protect memory structures like buffer pages from concurrent corruption. Unlike locks, latches are not related to transactions and are held only for very short durations. Most commonly in TempDB contention (PAGELATCH_EX), hot page insert contention, buffer latch issues due to memory/I/O pressure.
Why SQL Server Needs Latches
SQL Server has
many shared memory structures:
Ø Buffer
Pool pages
Ø Allocation
maps
Ø Hash
structures
Ø Index
navigation structures
Ø TempDB
metadata
Multiple
threads may try to read/write these at the same time.
Without latches
= Memory corruption + crashes
Types of
Latches
Ø PAGELATCH
Ø BUFFER LATCH
Ø IO LATCH
No comments:
Post a Comment
If you have any doubt, please let me know.