January 30, 2020 at 10:33 pm
Hi All,
I have a few questions regarding RCSI that I'm hoping someone can answer (or at least confirm that my understanding is correct).
"just at the beginning of your query put:
set transaction isolation level snapshot
go
select .... bla bla bla...
SQL will pull the latest value form tempdb if the rows is exclusively locked in the queries table."
Now I'm not sure of the answer to #1, but let's say that RCSI is not enabled in the database, would I need to use "set transaction isolation level snapshot" before both SELECT statements and action queries (UPDATE, INSERT, DELETE). In his example, it's before a SELECT statement and it seems that command instructs SQL Server to specifically look in tempdb for the row, whereas I thought RCSI was less about instructing SQL where to look for a record and more about whether or not to make a copy of the record--in which case I would expect to only need to use "set transaction isolation level snapshot" before any action queries...but maybe it's kind of required in both scenarios to always ensure neither query blocks the other?
Does it say to the updates, "hey, make a copy of this record in tempdb" and to the selects say, "hey, I don't know if there are any copies of the record(s) you want in tempdb, but check there first"?
Does my explanation make sense? I'm just trying to get a definitive answer on how this works on a per query basis across the different types of queries (and whether it's useless to put it before some of those queries), specifically when RCSI is not enabled at the database level.
Thanks in advance for helping to clear this up for me.
Mike
Mike Scalise, PMP
https://www.michaelscalise.com
January 31, 2020 at 10:24 am
It's not per query, it's per connection. You can define the connection to be RCSI. Then, all queries run by the connection follow the rules as you outlined accurately. However, I wouldn't recommend it. It means extra coding. I'd just go for the RCSI as the default setting and run from there.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
January 31, 2020 at 3:01 pm
Thank you, Grant! That actually clears everything up. I wasn't planning on using RCSI at a connection level, but rather just trying to understand the different ways in which it could be used.
Thanks again,
Mike
Mike Scalise, PMP
https://www.michaelscalise.com
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply