SQL SERVER – What is the Difference Between Latches and Locks

A very common question I often get in the email is

“What is the difference between latches and locks?”

The answer to this question is not an easy one. Here is a quick answer from the MS white paper.

A page in SQL Server is 8KB and can store multiple rows. To increase concurrency and performance, buffer latches are held only for the duration of the physical operation on the page, unlike locks which are held for the duration of the logical transaction. Latches are internal to the SQL engine and are used to provide memory consistency, whereas locks are used by SQL Server to provide logical transactional consistency.

Above answer is taken from the old, but extremely relevant white paper written in the year 2011. It was written for SQL Server 2008 R2, however, almost all the concepts from this Whitepaper are still very accurate.

If you want to learn more about Latches and how to diagnose and resolve problems around latch contention, I strongly suggest following whitepaper.

Diagnosing and Resolving Latch Contention on SQL Server

Let me know your thoughts about this subject.

Reference: Pinal Dave (https://blog.sqlauthority.com)

Previous Post
SQL SERVER – Find Port SQL Server is Listening – Port SQL Server is Running
Next Post
MySQL – Pattern Matching Comparison Using Regular Expressions with REGEXP

Related Posts

No results found.

2 Comments. Leave new

  • Hi Pinal,

    Can you explain what is normalization and denormalization ? How we can say Data warehouse is DE-normalisation ?

    Reply
    • Normalization is the process to guarantee relational databases have inserts and updates done with data consistency. Each Table has a specific purpose and no duplicated data within columns.Normalization uses primary keys and foreign keys to join tables(one to many) where there is no duplicated data. Data warehouses there is within columns duplicated data….However do to joins this slows down select statements. By moving to a data warehouse you can create a cleaner and faster(less joins) way to select. (One step further would be to move to multidimensional data or tabular data model)

      Reply

Leave a Reply