Isolation-Levels

Tag: isolation-levels

Lost Updates Under Read Committed Snapshot Isolation (RCSI)

Lost Updates Under Read Committed Snapshot Isolation (RCSI)

I shared an image on social media this week that describes how I feel about isolation levels in SQL Server (and its various flavors): the more concurrent sessions you have in a database reading and writing data at the same time, the more attractive it is to use version-based optimistic locking for scalability reasons.

There are two isolation levels in SQL Server that use optimistic locking for disk-based tables:

  1. Read Committed Snapshot Isolation (RCSI), which changes the implementation of the default Read Committed Isolation level and enables statement-based consistency.
  2. Snapshot Isolation, which provides high consistency for transactions (which often contain multiple statements). Snapshot Isolation also provides support for identifying update conflicts.

Many folks get pretty nervous about RCSI when they learn that certain timing effects can happen with data modifications that don’t happen under Read Committed. The irony is that RCSI does solve many OTHER timing risks in Read Committed, and overall is more consistent, so sticking with the pessimistic implementation of Read Committed is not a great solution, either.

Continue reading

New Free Course: The Dirty Secrets of NOLOCK

New Free Course: The Dirty Secrets of NOLOCK

I’m excited to begin moving over courses from SQL Workbooks and making the material available here. The first course up for grabs is The Dirty Secrets of NOLOCK.

Continue reading

Two Free Sessions Next Week: Fighting Bad Data and Deadlocks

Two Free Sessions Next Week: Fighting Bad Data and Deadlocks

I am excited and honored to be giving two free online sessions next week. Both events are sponsored by the fine folks over at Quest Software.

Why is That Data Wrong? How Choosing the Wrong Isolation Level Causes Bad Results

Tuesday, June 12, Noon Pacific 24 Hours of PASS, Sponsored by Quest Software

If you haven’t thought much about isolation levels in SQL Server, chances are your applications can return inconsistent data to your users: data that looks completely wrong. If your user re-runs their report or reloads their screen, the data may look right the second time… but after this happens, your customer feels that they can’t trust your data.

Continue reading

The Case of the Blocking Merge Statement (LCK_M_RS_U locks)

The Case of the Blocking Merge Statement (LCK_M_RS_U locks)

Recently I got a fun question about an “upsert” pattern as a “Dear SQL DBA” question. The question is about TSQL, so it lent itself to being answered in a blog post where I can show repro code and screenshots.

Continue reading

How to Choose Between RCSI and Snapshot Isolation Levels

How to Choose Between RCSI and Snapshot Isolation Levels

on February 18, 2016

SQL Server offers two flavors of optimistic locking for traditional disk-based tables: Read Committed Snapshot Isolation (RCSI), and Snapshot Isolation. They are each great tools to reduce blocking and make applications faster, particularly in databases that have lots of tiny reads and writes that need to be quick, or mixed-use patterns (lots of little reads and writes + larger reporting queries).

Both isolation levels are available in SQL Server Standard Edition and Web Edition as well as Enterprise. That’s right, they’re cheap and easy. Each of them are controlled by database level settings, and default to disabled for new user databases when you install SQL Server and leave the default settings on the model database.

When should you pick one or the other? And when might you enable both?

Continue reading

DBCC USEROPTIONS: See Your Session Settings in SQL Server

DBCC USEROPTIONS: See Your Session Settings in SQL Server

This is a super old command, but it still comes in handy when working with SQL Server.

Continue reading

Free Webcast on SQL Server Isolation Levels: (NOLOCK) or YESFUN?

Free Webcast on SQL Server Isolation Levels: (NOLOCK) or YESFUN?

By Kendra Little on August 8, 2011

Tomorrow evening I will be presenting for the SQL PASS Application Development chapter. Stop by and say hello!

Continue reading