Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between "repeatable read" and "snapshot isolation"

Repeatable read is defined as

a higher isolation level, that in addition to the guarantees of the read committed level, it also guarantees that any data read cannot change, if the transaction reads the same data again, it will find the previously read data in place, unchanged, and available to read.

Which seems very similar to snapshot isolation.

How is repeatable read different from the Snapshot isolation level?

like image 468
Anurag Sharma Avatar asked Mar 18 '19 05:03

Anurag Sharma


People also ask

What does snapshot isolation do?

SNAPSHOT isolation specifies that data read within a transaction will never reflect changes made by other simultaneous transactions. The transaction uses the data row versions that exist when the transaction begins.

What is the difference between serializable and snapshot isolation levels?

In Snapshot, the SQL server avoids locks by making use of row versioning. In Serializable, the SQL server makes use of locks and holds them until the transaction is committed or aborted.

What is the difference between read committed snapshot and read committed?

The Read Committed Snapshot Isolation Level in SQL Server provides the statement-level read consistency whereas the Snapshot Isolation Level provides the transaction-level read consistency.

What is the difference between read committed and repeatable read isolation levels?

The REPEATABLE READ transaction will still see the same data, while the READ COMMITTED transaction will see the changed row count. REPEATABLE READ is really important for reporting because it is the only way to get a consistent view of the data set even while it is being modified.


1 Answers

"Snapshot" guarantees that all queries within the transaction will see the data as it was at the start of the transaction.

"Repeatable read" guarantees only that if multiple queries within the transaction read the same rows, then they will see the same data each time. (So, different rows might get snapshotted at different times, depending on when the transaction first retrieves them. And if new rows are inserted, a later query might detect them.)

like image 117
ruakh Avatar answered Nov 06 '22 02:11

ruakh