Ads

23 April 2025

Difference between NOLOCK and READPAST

 NOLOCK

========

When we use NOLOCK in select command it will allow to read rows are available on dirty pages/uncommitted from buffer cache

Ex: i have table called replication with 4 records 

update one record with out commit 


in another session i try to select table, it not showing any result 

Tried with NOLOCK , it resulting with dirty pages 




READPAST
=========
it will not read rows that are locked by other transactions. When READPAST is specified, row-level locks are skipped.

SELECT *  FROM [replication] with(readpast)

it will skip modified records until transaction will commit





  

No comments:

Post a Comment