sql-servernolocksnapshot-isolation

Do I get any performance gain by using WITH (NOLOCK) on SQL Server database where READ_COMMITTED_SNAPSHOT is switched on?


I have a database on Microsoft SQL Server 2014 where READ_COMMITTED_SNAPSHOT property is switched on. I understand that this means that reads are not blocked by writes because reads do not issue shared locks and that this is clean reading.

My question is: do I get any performance gain by using WITH (NOLOCK) in select statements in this scenario? In my case I don't mind it would be dirty reading.

I tried to find this information but only found the comparison between using WITH (NOLOCK) and switching READ_COMMITTED_SNAPSHOT on. But I already have it on.


Solution

  • In theory there should be an improvement because although the query will not block in either case, in the READ_COMMITTED_SNAPSHOT case the book-keeping associated with the locks is still required, so that the database knows when it needs to create/retain/cleanup snapshotted rows/pages.

    However as with all performance questions, you should try it and see if the difference exists in practice, and if it is, if it matters to your use-case.