Thursday, 14 May 2026

BUFFER LATCH in SQL server

A BUFFER LATCH is a protection mechanism used by SQL Server to safeguard buffer pool pages while they are being read or written. Whenever SQL Server reads a page from disk or writes a page to disk or pins page in buffer or checks page validity or modifies internal memory metadata. SQL Server places a Buffer Latch on that page.

we need Buffer Latches because multiple threads may try to simultaneously access same buffer page for readers or modifiers or flushing threads or checkpoint or Lazy writer. So, buffer latch protects in-memory page while it is being accessed. BUT unlike Locks, it has nothing to do with transactions.

Feature

BUFFER LATCH

PAGELATCH

LOCK

Protects

In-memory buffer structures

In-memory page access coordination

Logical data consistency

Location

Buffer Pool

Buffer Pool page access

Transaction engine

Purpose

Safety of memory copy of page

Avoid concurrent corruption of in-memory page

Isolation + concurrency control

Duration

Microseconds–milliseconds

Microseconds–milliseconds

Transaction duration

Appears in sys.dm_tran_locks

No

No

Yes

Root problem when high

I/O stress / memory pressure

TempDB / hot page contention

Blocking

 Short version

Ø  Buffer Latch = Protect buffer page during I/O + internal access

Ø  Pagelatch = protect shared in-memory page access

Ø  Lock = protect logical data modifications

Below are the common buffer latch wait type

Wait Type

Meaning

BUFFERLATCH

General buffer latch wait

BUFFERLATCH_SH

Shared access to buffer

BUFFERLATCH_EX

Exclusive latch on buffer

BUFFERLATCH_UP

Update latch

PAGEIOLATCH_*

(Often seen with buffer latch during disk read)

 

 

No comments:

Post a Comment

If you have any doubt, please let me know.

Popular Posts