Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Read Committed_Snapshot


Read Committed_Snapshot

Author
Message
IT researcher
 IT researcher
SSC Veteran
SSC Veteran (294 reputation)SSC Veteran (294 reputation)SSC Veteran (294 reputation)SSC Veteran (294 reputation)SSC Veteran (294 reputation)SSC Veteran (294 reputation)SSC Veteran (294 reputation)SSC Veteran (294 reputation)

Group: General Forum Members
Points: 294 Visits: 1798
"Read Committed_Snapshot" isolation level in sql has any negatives or disadvantages?
Grant Fritchey
Grant Fritchey
SSCoach
SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)

Group: General Forum Members
Points: 17592 Visits: 32265
It does put considerable additional load on the tempdb, so be sure you're ready to handle that. The amount depends on the level of data changes you're dealing with. Other than that, I've seen no negatives and quite a few positives.

----------------------------------------------------
The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood...
Theodore Roosevelt

The Scary DBA
Author of: SQL Server Query Performance Tuning and SQL Server Execution Plans
Product Evangelist for Red Gate Software
IT researcher
 IT researcher
SSC Veteran
SSC Veteran (294 reputation)SSC Veteran (294 reputation)SSC Veteran (294 reputation)SSC Veteran (294 reputation)SSC Veteran (294 reputation)SSC Veteran (294 reputation)SSC Veteran (294 reputation)SSC Veteran (294 reputation)

Group: General Forum Members
Points: 294 Visits: 1798
can we estimate required space for tempdb ? and also whether database update speed is reduced ?
Grant Fritchey
Grant Fritchey
SSCoach
SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)

Group: General Forum Members
Points: 17592 Visits: 32265
Best suggestion I can make is to measure the number and size of your current transactions. Get a sense of the amount of data that is actively being modified and that will give you an indication of what's going to happen with tempdb.

----------------------------------------------------
The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood...
Theodore Roosevelt

The Scary DBA
Author of: SQL Server Query Performance Tuning and SQL Server Execution Plans
Product Evangelist for Red Gate Software
Eugene Elutin
Eugene Elutin
Hall of Fame
Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)

Group: General Forum Members
Points: 3042 Visits: 5478
If you enable READ COMMITTED SNAPSHOT in the database, it becomes the default isolation level.
So, it can break some of your application functionality which would depend on default behavior under READ COMMITTED isolation level. I would see that could be a common problem for many existing "booking" systems...

_____________________________________________
"The only true wisdom is in knowing you know nothing"
"O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
(So many miracle inventions provided by MS to us...)

How to post your question to get the best and quick help
Orlando Colamatteo
Orlando Colamatteo
SSCrazy Eights
SSCrazy Eights (8.2K reputation)SSCrazy Eights (8.2K reputation)SSCrazy Eights (8.2K reputation)SSCrazy Eights (8.2K reputation)SSCrazy Eights (8.2K reputation)SSCrazy Eights (8.2K reputation)SSCrazy Eights (8.2K reputation)SSCrazy Eights (8.2K reputation)

Group: General Forum Members
Points: 8243 Visits: 14368
Eugene Elutin (3/18/2013)
If you enable READ COMMITTED SNAPSHOT in the database, it becomes the default isolation level.

For clarity READ_COMMITTED_SNAPSHOT is just a mode of the READ_COMMITTED isolation level with versioning, i.e. READ_COMMITTED_SNAPSHOT is not an isolation level unto itself.

So, it can break some of your application functionality which would depend on default behavior under READ COMMITTED isolation level. I would see that could be a common problem for many existing "booking" systems...

Example?

__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Grant Fritchey
Grant Fritchey
SSCoach
SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)

Group: General Forum Members
Points: 17592 Visits: 32265
opc.three (3/18/2013)
Eugene Elutin (3/18/2013)
If you enable READ COMMITTED SNAPSHOT in the database, it becomes the default isolation level.

For clarity READ_COMMITTED_SNAPSHOT is just a mode of the READ_COMMITTED isolation level with versioning, i.e. READ_COMMITTED_SNAPSHOT is not an isolation level unto itself.

So, it can break some of your application functionality which would depend on default behavior under READ COMMITTED isolation level. I would see that could be a common problem for many existing "booking" systems...

Example?


Yeah, I'd love to see an example or two as well.

----------------------------------------------------
The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood...
Theodore Roosevelt

The Scary DBA
Author of: SQL Server Query Performance Tuning and SQL Server Execution Plans
Product Evangelist for Red Gate Software
Eugene Elutin
Eugene Elutin
Hall of Fame
Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)

Group: General Forum Members
Points: 3042 Visits: 5478
Grant Fritchey (3/18/2013)
opc.three (3/18/2013)
Eugene Elutin (3/18/2013)
If you enable READ COMMITTED SNAPSHOT in the database, it becomes the default isolation level.

For clarity READ_COMMITTED_SNAPSHOT is just a mode of the READ_COMMITTED isolation level with versioning, i.e. READ_COMMITTED_SNAPSHOT is not an isolation level unto itself.

So, it can break some of your application functionality which would depend on default behavior under READ COMMITTED isolation level. I would see that could be a common problem for many existing "booking" systems...

Example?


Yeah, I'd love to see an example or two as well.


Ok, I'll try to come up with one hypothetical one.
But at first I need to put few sentences:
1. "booking" system could be actually any transactional system. I just held an example in my head which would be relevant for booking or stock management.
2. I guess many will agree that READ_COMMITTED_SNAPSHOT is not a magic bullet against all locking problems in your database! When you design and code you should be aware of locking issues and design/code appropriately.

Now an example. "booking" system...

Let say Customer "A" does want to book one Seat and his highest priority is to book a seat #1. At the same (or almost the same) time Customer "B" wants top do exactly the same!
So small setup:


CREATE TABLE Booking (ID INT IDENTITY(1,1), SeatID INT, CustomerID CHAR(1))
INSERT Booking SELECT 1, NULL
INSERT Booking SELECT 2, NULL



Now let see how booking system will process reservations without READ_COMMITTED_SNAPSHOT:


ALTER DATABASE MyDev
SET ALLOW_SNAPSHOT_ISOLATION OFF;

ALTER DATABASE MyDev
SET READ_COMMITTED_SNAPSHOT OFF;



For a Customer A, started first - hence his transaction begins first (SSMS query window 1):

BEGIN TRANSACTION

-- Book seat 1 if it's not already taken
IF NOT EXISTS (SELECT 1 FROM Booking WHERE SeatID = 1 AND CustomerID IS NOT NULL)
BEGIN
UPDATE Booking SET CustomerID = 'A' WHERE SeatID = 1
END

-- Now let say we need to do something else as part of the booking transaction which
-- takes some considerate amount of time for this Customer
-- do not commit for now!



So, while transaction for Customer "A" is still running Customer "B" presses the "Book" button, so his transaction kick's in (SSMS query window 2):


BEGIN TRANSACTION

-- Book seat 1 if it's not already taken (and it's not as transaction for Customer A is not committed as yet).
IF NOT EXISTS (SELECT 1 FROM Booking WHERE SeatID = 1 AND CustomerID IS NOT NULL)
BEGIN
UPDATE Booking SET CustomerID = 'B' WHERE SeatID = 1
END
-- Now let say that "something else - part" for Customer "B" takes no time and transaction is completed, so:
COMMIT TRANSACTION



Yeah, our second transaction is running as it cannot commit waiting for the first one to release the lock. Lets do it. Add COMMIT TRANSACTION into first query (SSMS window 1) and execute it.
So. All transactions are now committed (you can check window 2). Let see what we have in result?

SELECT * FROM Booking



As expected we have:


ID SeatID CustomerID
1 1 A
2 2 NULL


Now turn is for READ_COMMITTED_SNAPSHOT (make sure that you have only one connection to your database open, otherwise SET READ_COMMITTED_SNAPSHOT OFF will run for ever ;-)):

ALTER DATABASE MyDev
SET ALLOW_SNAPSHOT_ISOLATION ON
ALTER DATABASE MyDev
SET READ_COMMITTED_SNAPSHOT ON



Repeat all steps in exactly the same order as previously.
Check results.
Surprise!!!!
You will have Customer "B" much more lucky this time!
Oops....

Yes, you will tell me that my code is not good enough, and you will be right - it's a crap code.
But that is not a point I wanted to make. What I've tried to say is:
If you have a crap code which did work without READ_COMMITTED_SNAPSHOT, you will still get it working fine with READ_COMMITTED_SNAPSHOT ON, except one caveat: it may produce a bit different results...

So, refer to the point #2 at the beginning of my post.

_____________________________________________
"The only true wisdom is in knowing you know nothing"
"O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
(So many miracle inventions provided by MS to us...)

How to post your question to get the best and quick help
Eugene Elutin
Eugene Elutin
Hall of Fame
Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)

Group: General Forum Members
Points: 3042 Visits: 5478
Grant Fritchey (3/18/2013)
... or two as well.


Googled out the second one (surprisingly to me - based on "stock management":

http://www.jimmcleod.net/blog/index.php/2009/08/27/the-potential-dangers-of-the-read-committed-snapshot-isolation-level/

_____________________________________________
"The only true wisdom is in knowing you know nothing"
"O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
(So many miracle inventions provided by MS to us...)

How to post your question to get the best and quick help
Lynn Pettis
Lynn Pettis
SSC-Insane
SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)

Group: General Forum Members
Points: 24200 Visits: 37964
Eugene Elutin (3/18/2013)
Grant Fritchey (3/18/2013)
opc.three (3/18/2013)
Eugene Elutin (3/18/2013)
If you enable READ COMMITTED SNAPSHOT in the database, it becomes the default isolation level.

For clarity READ_COMMITTED_SNAPSHOT is just a mode of the READ_COMMITTED isolation level with versioning, i.e. READ_COMMITTED_SNAPSHOT is not an isolation level unto itself.

So, it can break some of your application functionality which would depend on default behavior under READ COMMITTED isolation level. I would see that could be a common problem for many existing "booking" systems...

Example?


Yeah, I'd love to see an example or two as well.


Ok, I'll try to come up with one hypothetical one.
But at first I need to put few sentences:
1. "booking" system could be actually any transactional system. I just held an example in my head which would be relevant for booking or stock management.
2. I guess many will agree that READ_COMMITTED_SNAPSHOT is not a magic bullet against all locking problems in your database! When you design and code you should be aware of locking issues and design/code appropriately.

Now an example. "booking" system...

Let say Customer "A" does want to book one Seat and his highest priority is to book a seat #1. At the same (or almost the same) time Customer "B" wants top do exactly the same!
So small setup:


CREATE TABLE Booking (ID INT IDENTITY(1,1), SeatID INT, CustomerID CHAR(1))
INSERT Booking SELECT 1, NULL
INSERT Booking SELECT 2, NULL



Now let see how booking system will process reservations without READ_COMMITTED_SNAPSHOT:


ALTER DATABASE MyDev
SET ALLOW_SNAPSHOT_ISOLATION OFF;

ALTER DATABASE MyDev
SET READ_COMMITTED_SNAPSHOT OFF;



For a Customer A, started first - hence his transaction begins first (SSMS query window 1):

BEGIN TRANSACTION

-- Book seat 1 if it's not already taken
IF NOT EXISTS (SELECT 1 FROM Booking WHERE SeatID = 1 AND CustomerID IS NOT NULL)
BEGIN
UPDATE Booking SET CustomerID = 'A' WHERE SeatID = 1
END

-- Now let say we need to do something else as part of the booking transaction which
-- takes some considerate amount of time for this Customer
-- do not commit for now!



So, while transaction for Customer "A" is still running Customer "B" presses the "Book" button, so his transaction kick's in (SSMS query window 2):


BEGIN TRANSACTION

-- Book seat 1 if it's not already taken (and it's not as transaction for Customer A is not committed as yet).
UPDATE Booking SET SeatNo = 1
WHERE Customer ='B'
AND NOT EXISTS(SELECT 1 FROM Booking WHERE SeatNo = 1) -- seat is not booked yet.

-- Now let say that "something else - part" for Customer "B" takes no time and transaction is completed, so:
COMMIT TRANSACTION



Yeah, our second transaction is running as it cannot commit waiting for the first one to release the lock. Lets do it. Add COMMIT TRANSACTION into first query (SSMS window 1) and execute it.
So. All transactions are now committed (you can check window 2). Let see what we have in result?

SELECT * FROM Booking



As expected we have:


ID SeatID CustomerID
1 1 A
2 2 NULL


Now turn is for READ_COMMITTED_SNAPSHOT (make sure that you have only one connection to your database open, otherwise SET READ_COMMITTED_SNAPSHOT OFF will run for ever ;-)):

ALTER DATABASE MyDev
SET ALLOW_SNAPSHOT_ISOLATION ON
ALTER DATABASE MyDev
SET READ_COMMITTED_SNAPSHOT ON



Repeat all steps in exactly the same order as previously.
Check results.
Surprise!!!!
You will have Customer "B" much more lucky this time!
Oops....

Yes, you will tell me that my code is not good enough, and you will be right - it's a crap code.
But that is not a point I wanted to make. What I've tried to say is:
If you have a crap code which did work without READ_COMMITTED_SNAPSHOT, you will still get it working fine with READ_COMMITTED_SNAPSHOT ON, except one caveat: it may produce a bit different results...

So, refer to the point #2 at the beginning of my post.


Not sure about your setup. You aren't even using the same code between sessions.

Cool
Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search