This article is half-done without your Comment! *** Please share your thoughts via Comment ***
The SNAPSHOT Isolation Level constructed based on MVCC – Multiversion Concurrency Control Architecture.
This is also one of my favourite Isolation levels because I like the concept of row versioning.
Before further discussion on SNAPSHOT,
You guys should know about, What is MVCC?
Other RDBMS like: MySQL InnoDB Engine and PostgreSQL is based on MVCC Architecture.
The SNAPSHOT Isolation level does not block your any transaction for inserting, updating or selecting the data because it is managing and storing different versions of the data into TempDB.
When you are reading the data in one transaction and the meanwhile another transaction is updating the same data, and it keeps the old version of data into TempDB so that you can still read the old committed data.
When you read the same data next time, you always get a new version of data from primary storage, and it removes the old version of data from the TempDB.
Your reader does not block any other writer, and your writer does not block any other reader.
You cannot enable SNAPSHOT Isolation level at the statement level.
You have to enable at the database level and after enabling all your database transactions will execute in the MVCC fashion.
Script to Enable SNAPSHOT Isolation Level:
1 2 |
ALTER DATABASE Database_Name SET ALLOW_SNAPSHOT_ISOLATION ON |
Script to Disable SNAPSHOT Isolation Level:
1 2 |
ALTER DATABASE Database_Name SET ALLOW_SNAPSHOT_ISOLATION OFF |