July 2, 2007 at 10:47 am
I have a view and it has
select a, b, c from tableA
UNION ALL
select a, b, c from tableB
UNION ALL
select a, b, c from tableC
What really surprised me is there are two queries using this view and they ran into a deadlock. How can it be?
Is it some wrong in our configuration and it is standard.
Lock min 500 max 2147483647
Should I put in SET DEADLOCK_PRIORITY LOW?
This happens when two different sources tried to insert record into the same table.
July 2, 2007 at 4:47 pm
Is the call to the view in an explicit transaction that updated one of the tables in the view?
--Jeff Moden
Change is inevitable... Change for the better is not.
July 2, 2007 at 5:29 pm
No none of the call updates any table. They are all Select statements. That's why I did not understand why a deadlock would happen.
July 3, 2007 at 12:01 am
Check what is the type of lock held by the blocking SPID. You can set your isolation level to read committed so that select statements can avoid locks.
Cheers,
Sugeshkumar Rajendran
SQL Server MVP
http://sugeshkr.blogspot.com
July 3, 2007 at 4:06 am
Interesting...I've been meaning to ask this for some time.
When querying a database for reporting purposes, I'll almost always use the NOLOCK clause (read uncommitted) because it's generally quicker, sometimes very much so.
I understand this is because it prevents dropping in read locks and reads uncommitted data so doesn't hold up transactions and isn't held up by pending transactions. I've not come across a situation yet where uncommitted data has screwed up the print job but appreciate that sooner or later it may happen, when a transaction (the changed data of which has already been read by my reporting query) is rolled back.
Am I right in my understanding of this? What's the general concensus on using the NOLOCK clause for reporting?
Loner, I hope you don't mind me asking this, and perhaps you could try the NOLOCK clause yourself - provided that you are sure your output won't be skewed by uncommitted data.
Many thanks
ChrisM
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
July 3, 2007 at 4:33 am
With read uncommited isolation level there is a possibility to read dirty reads which can be avoided with read commited level. But the more the level you use the higher is the locking possibility. So plan before you use an isolation level. You can have a good and easy reading of ISOLATION Levels @
http://www.expresscomputeronline.com/20040426/techspace01.shtml
Cheers,
Sugeshkumar Rajendran
SQL Server MVP
http://sugeshkr.blogspot.com
July 3, 2007 at 5:51 am
There may be some normal "healthy" blocking going on... you sure these are "deadlocks" (found in the SQL Server log) and not just blocking?
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply