November 25, 2010 at 7:19 am
Hi,
I would like to know if it's possible for NOLOCK hint to work on a cross database query?
Thanks
November 25, 2010 at 7:58 am
Before answering that, I have one for you. Do you know what nolock does?
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
November 25, 2010 at 8:09 am
yep and I don't mind if I am getting dirty data.
November 25, 2010 at 8:19 am
And you're also fine with possibly missing rows or reading rows twice?
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
November 26, 2010 at 3:49 am
Gail,
That's also fine.
November 26, 2010 at 12:18 pm
Gail, why would you get duplicate rows?
November 26, 2010 at 12:49 pm
rs80 (11/26/2010)
Gail, why would you get duplicate rows?
Non-techincal answer: When dirty reads are allowed, it is possible to read a row and then have someone update that row which can cause that same row to be read again. Bottom line, you end up with the same row twice with different values.
--Jeff Moden
Change is inevitable... Change for the better is not.
November 26, 2010 at 2:32 pm
Jeff Moden (11/26/2010)
rs80 (11/26/2010)
Gail, why would you get duplicate rows?Non-techincal answer: When dirty reads are allowed, it is possible to read a row and then have someone update that row which can cause that same row to be read again. Bottom line, you end up with the same row twice with different values.
and another possibility is a page split which can allow the same data to be read twice...
November 26, 2010 at 3:34 pm
reading the same row twice can also happen with read committed.
November 26, 2010 at 4:02 pm
Ninja's_RGR'us (11/26/2010)
Jeff Moden (11/26/2010)
rs80 (11/26/2010)
Gail, why would you get duplicate rows?Non-techincal answer: When dirty reads are allowed, it is possible to read a row and then have someone update that row which can cause that same row to be read again. Bottom line, you end up with the same row twice with different values.
and another possibility is a page split which can allow the same data to be read twice...
You'll have to show me that one. With read committed, I believe that's impossible,
--Jeff Moden
Change is inevitable... Change for the better is not.
November 26, 2010 at 4:04 pm
Nils Gustav Stråbø (11/26/2010)
reading the same row twice can also happen with read committed.
Same thing here. Can you show me at least a white paper on the subject because the whole idea of read committed is to keep such things from happening.
--Jeff Moden
Change is inevitable... Change for the better is not.
November 27, 2010 at 1:48 am
Nils Gustav Stråbø (11/26/2010)
reading the same row twice can also happen with read committed.
True, but you need more specific circumstances than with read uncommitted. There are allowed anomalies in every isolation level up to serialisable. It's always a trade off. The reason I'm so pushy on nolock is that most people I've seen using it don't realise that it's a trade off. They don't realise what they're giving up in order to read through locks. They think it's a free lunch.
(High level) Technical time.
In read uncommitted, a scan is done in allocation order (order of pages in the file). Any data modification that splits a page (insert or update that grows the row) can result in the scan missing or duplicate reading rows as half of the page is split and moves from behind the scan to in-front of the scan, or vis versa.
In read committed, allocation order scan isn't allowed (unless there's a table lock or a few other conditions that ensure that the table cannot change during the scan). To get dup read/mis read in read committed I believe you need an update of the table that changes the value of the key for the index you are reading for one or more rows. The key value changes so the index row moves from behind the scan to in front of the scan (or vis versa). Possible in read committed because locks are released as soon as the read is done. Not possible in repeatable-read because in that isolation level the locks are held until the end of the transaction.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
November 27, 2010 at 7:08 am
Jeff Moden (11/26/2010)
Ninja's_RGR'us (11/26/2010)
Jeff Moden (11/26/2010)
rs80 (11/26/2010)
Gail, why would you get duplicate rows?Non-techincal answer: When dirty reads are allowed, it is possible to read a row and then have someone update that row which can cause that same row to be read again. Bottom line, you end up with the same row twice with different values.
and another possibility is a page split which can allow the same data to be read twice...
You'll have to show me that one. With read committed, I believe that's impossible,
I was still in the nolock conversation :w00t:.
Viewing 13 posts - 1 through 12 (of 12 total)
You must be logged in to reply to this topic. Login to reply