I use SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
in the majority of my general SQL queries, mainly because this was drilled in to me when originally learning the language.
From my understanding, this isolation level acts the same way that WITH (NO LOCK)
however I only ever tend to use SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
.
- Is there ever a time that I should be using
WITH (NO LOCK)
overSET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
. - Does
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
stop other users from being locked out of the tables that I am reading? - If
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
is used to stop locks, but I am only reading data, what is the point in using it? Is it only system intensive queries that would generate locks? Is it worth using it when running queries that would return in say, 5-10 seconds? - I have been told not to use
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
when reading data that would be used in updates, presumably to avoid updating dirty data. Would this be the only reason? - With the type of database that I am working on, there is a production and testing environment. We will very rarely be querying the production environment but when I need to, I will generally be using
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
in my query. I understand that dirty reads are possible with this. Aside from receiving data back that may not end up being committed to the database (and therefore throw my results out) what other types of 'dirty reads' could be possible?
Sorry for the mass questions.
READ UNCOMMITTED
everywhere, in the exact same way as I wouldn't useWITH (NOLOCK)
everywhere (they are essentially the same thing) blogs.sqlsentry.com/aaronbertrand/bad-habits-nolock-everywhere