1

Consider the following SQL statement:

SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
BEGIN TRANSACTION

insert into Customer(name)
values('CustomerName')

COMMIT

Am I right in saying this Isolation Level is not needed since we are doing a simple insert? Not actually READing anything

dstewart101
  • 1,084
  • 1
  • 16
  • 38
  • Are you using SQL Server? Please label with the actual database you are using. – Tim Biegeleisen Jan 16 '17 at 11:52
  • yes - thanks - MS SQL Server 2014 – dstewart101 Jan 16 '17 at 11:55
  • I'd start from a different place. If you have a specific situation where dirty reads would be acceptable, *consider* whether this or a query hint *may* be appropriate. Not "let's sprinkle this setting everywhere and then see what fires I have to put out". – Damien_The_Unbeliever Jan 16 '17 at 11:56
  • 1
    Did you consider that under `READ UNCOMMITTED` someone could do a dirty read while you are inserting and therefore get unexpected results? – Tim Biegeleisen Jan 16 '17 at 11:56
  • 1
    @TimBiegeleisen - only if that other connection has itself opted for `READ UNCOMMITTED`. In general, these settings affect the results or locks that your own connection will be subject to rather than those experienced by other connections. – Damien_The_Unbeliever Jan 16 '17 at 11:59
  • @Damien_The_Unbeliever - i'm trying to get rid of the sprinkling. it's in some places in our codebase where I don't think we need it. seems to me on a transaction like the one above, while it might not do any harm, it's just not necessary to have it in there. unless perhaps there were an extremely large number of customer records and another read process locked the table? – dstewart101 Jan 16 '17 at 12:00
  • ok so @TimBiegeleisen and damien, i should be more worried about the other process than this particular insert. – dstewart101 Jan 16 '17 at 12:01
  • @dstewart101 did you ever find the answer to your question ? – Sourajit Basak Sep 19 '19 at 09:04

0 Answers0