Quick revision
The short answer
Default READ COMMITTED on SQL Server uses shared locks, so a reader waits for a writer's exclusive lock and the two can deadlock. READ_COMMITTED_SNAPSHOT (RCSI) is a database option that makes the same READ COMMITTED level read row versions from the version store instead, so each statement sees the last committed data as of its start and never waits for writers. SNAPSHOT isolation is enabled with ALLOW_SNAPSHOT_ISOLATION and chosen per transaction; it gives one consistent view for the whole transaction, and an update to a row someone else changed since it started fails with error 3960.
What to remember
In this answer, we saw that SQL Server's default READ COMMITTED takes shared locks, so readers wait for writers and can deadlock with them. RCSI is a database option that keeps the READ COMMITTED level but reads row versions, giving each statement the last committed data as of its start without waiting. SNAPSHOT isolation, allowed by ALLOW_SNAPSHOT_ISOLATION and requested per transaction, gives the whole transaction one consistent view but fails with error 3960 when it updates a row others changed after it began. Azure SQL Database enables RCSI by default.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
Default READ COMMITTED on SQL Server uses shared locks, so a reader waits for a writer's exclusive lock and the two can deadlock. READ_COMMITTED_SNAPSHOT (RCSI) is a database option that makes the same READ COMMITTED level read row versions from the version store instead, so each statement sees the last committed data as of its start and never waits for writers. SNAPSHOT isolation is enabled with ALLOW_SNAPSHOT_ISOLATION and chosen per transaction; it gives one consistent view for the whole transaction, and an update to a row someone else changed since it started fails with error 3960.
Why this question is asked
SQL Server is unusual among the big databases: out of the box, its default isolation level still uses read locks, while Oracle and PostgreSQL use row versions. That single difference explains a lot of blocking and deadlock reports from Java teams. Interviewers ask this question to check that we know the three options, what each one promises, and what it costs. In this answer, we will recap shared locks, see how locking READ COMMITTED behaves, then look at RCSI and SNAPSHOT side by side, including how to use them from JDBC.
1A Quick Recap of Shared and Exclusive Locks
SQL Server protects data with locks. A writer takes an exclusive lock on each row it changes and keeps it until its transaction ends. A reader under locking READ COMMITTED takes a shared lock on each row or page while it reads it, and releases it as soon as it moves on. Shared and exclusive locks are incompatible: a reader cannot take a shared lock on a row that a writer holds exclusively, so it waits.
2READ COMMITTED With Locking: Readers Wait for Writers
Here is the behaviour with two sessions, using the default settings.
The reader never sees uncommitted data, which is the promise of READ COMMITTED, but it pays by waiting. Worse, a reader and a writer can deadlock: a report holds a shared lock on one page while waiting for a row the writer locked, and the writer needs that page. SQL Server kills one of them with error 1205. Notice also that statement-level consistency is weak here: because shared locks are released as the scan moves on, a long SELECT can see some rows before and some after a concurrent transaction.
3READ_COMMITTED_SNAPSHOT: The Same Level, Read From Versions
RCSI is a database option. Once it is on, every transaction that runs at READ COMMITTED, which is the default, stops taking shared locks. When a writer changes a row, SQL Server copies the previous committed version into the version store, which lives in tempdb, or in the user database itself when Accelerated Database Recovery is enabled on SQL Server 2019 and later. A reader that meets a row changed by an open transaction follows the version chain back to the last version committed before its statement started.
The application code does not change at all, which is why RCSI is so popular: it is a switch at the database level. Each statement sees a consistent picture as of its own start, the same model as Oracle's default. Writers still block writers, so two sessions updating the same row still wait for each other. Azure SQL Database turns RCSI on by default for new databases.
4SNAPSHOT Isolation: One View for the Whole Transaction
SNAPSHOT is a separate isolation level. The database must allow it first, and then each transaction asks for it explicitly. Every statement in a SNAPSHOT transaction sees data as of the moment the transaction started, so a report made of several queries sees one consistent picture.
The catch is writing. If a SNAPSHOT transaction tries to update a row that another transaction changed and committed after the snapshot transaction began, SQL Server cannot apply the change without losing the other update. It aborts with error 3960, a snapshot isolation update conflict, and the application must retry the whole transaction.
| Aspect | READ COMMITTED (locking) | RCSI | SNAPSHOT |
|---|---|---|---|
| How enabled | Default | Database option, applies to READ COMMITTED | ALLOW_SNAPSHOT_ISOLATION plus per transaction |
| Readers wait for writers | Yes | No | No |
| Consistent as of | Nothing fixed, rows read over time | Start of each statement | Start of the transaction |
| Write conflict | Waits | Waits | Error 3960, retry |
| Version store cost | None | Yes | Yes, kept longer |
5Using Them From Java
With RCSI there is nothing to do in Java; the default level simply behaves differently. For SNAPSHOT, the Microsoft JDBC driver defines its own constant, because SNAPSHOT is not one of the standard JDBC levels.
In Spring, @Transactional(isolation = ...) only offers the standard levels, so SNAPSHOT is usually set on the connection in a small helper or through the data source, and the retry is handled like any other concurrency failure.
6Follow-up questions
Does RCSI make the database slower?
Writers do a little more work, copying old versions to the version store, and tempdb or the user database needs room for them. In return readers no longer wait, so for mixed OLTP and reporting workloads overall throughput usually improves. The cost to watch is version store growth during long transactions.
Which should a multi-query report use, RCSI or SNAPSHOT?
SNAPSHOT, because RCSI gives each statement its own moment, so two queries in the same report can disagree. A read-only SNAPSHOT transaction never hits error 3960, since that error only happens on writes.
Is NOLOCK the same as RCSI?
No. NOLOCK reads uncommitted data and can miss or double-read rows. RCSI reads only committed data from a consistent point in time. RCSI is the correct fix for blocking reads; NOLOCK only hides it.
7Conclusion
In this answer, we saw that SQL Server's default READ COMMITTED takes shared locks, so readers wait for writers and can deadlock with them. RCSI is a database option that keeps the READ COMMITTED level but reads row versions, giving each statement the last committed data as of its start without waiting. SNAPSHOT isolation, allowed by ALLOW_SNAPSHOT_ISOLATION and requested per transaction, gives the whole transaction one consistent view but fails with error 3960 when it updates a row others changed after it began. Azure SQL Database enables RCSI by default.
Open with
There are three behaviours. SQL Server's default READ COMMITTED uses locks: a reader takes shared locks as it reads, so if a writer holds an exclusive lock on a row, the reader waits until the writer commits.
Then, if they want more
It never sees dirty data, but readers block on writers, and reports and updates can deadlock, which shows up as error 1205. READ_COMMITTED_SNAPSHOT, RCSI, is a database option.
With it on, the same READ COMMITTED level stops taking shared locks; writers copy the previous committed version into the version store, in tempdb or in the database with accelerated database recovery, and readers get the last version committed before their statement started. No code change is needed, and Azure SQL Database has it on by default.
SNAPSHOT is a separate level: the database allows it with ALLOW_SNAPSHOT_ISOLATION, and each transaction asks for it, in JDBC with SQLServerConnection.TRANSACTION_SNAPSHOT. Then every statement in the transaction sees the database as of the transaction start, which is what a multi-query report wants.
The catch is writes: if it updates a row someone else changed and committed after it began, it fails with error 3960 and must be retried. Writers still block writers in all three.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- PostgreSQL documentation, MySQL reference manual
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "What is the difference between SQL Server's READ COMMITTED with locking...": https://scrivio-interview-library.netlify.app/databases/oracle-and-sql-server/bd92e15e68/