Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2008
»
SQL Server Newbies
»
SQL Deadlocks
23 posts, Page 1 of 3
1
2
3
»
»»
SQL Deadlocks
Rate Topic
Display Mode
Topic Options
Author
Message
bugg
bugg
Posted Tuesday, January 22, 2013 8:40 AM
SSC-Enthusiastic
Group: General Forum Members
Last Login: Today @ 8:43 AM
Points: 123,
Visits: 402
In my production database I'm getting a few deadlocks between updates and selects. Where the selects are being killed off.
I'm trying to work out the best way to eliminate these.
After a bit of research I don't really want to use SNAPSHOT ISOLATION or READ_COMMITTED_SNAPSHOT as this approach would require downtime to alter the database and possibly loads of testing and might be overkill for my needs and unnecessary overload on my temp db.
I also don't really want to go down the (nolock) route.
What would be the best way to approach this? Exclusive locks on the updates?
Any insight into dealing with deadlocks would be greatly appreciated.
Post #1410074
anthony.green
anthony.green
Posted Tuesday, January 22, 2013 8:44 AM
SSCertifiable
Group: General Forum Members
Last Login: Friday, April 12, 2013 3:51 AM
Points: 5,075,
Visits: 4,831
Do you have traceflag 1222 enabled?
If so can you post the deadlock graph from the error log
If not run
DBCC TRACEON (1222, -1)
and then post the graphs once a deadlock has occured.
Want an answer fast? Try here
How to post data/code for the best help - Jeff Moden
Need a string splitter, try this - Jeff Moden
How to post performance problems - Gail Shaw
CrossTabs-Part1
&
Part2 - Jeff Moden
SQL Server Backup, Integrity Check, and Index and Statistics Maintenance - Ola Hallengren
Managing Transaction Logs - Gail Shaw
Troubleshooting SQL Server: A Guide for the Accidental DBA - Jonathan Kehayias and Ted Krueger
Post #1410078
GilaMonster
GilaMonster
Posted Tuesday, January 22, 2013 8:58 AM
SSC-Dedicated
Group: General Forum Members
Last Login: Today @ 3:28 PM
Points: 37,730,
Visits: 29,996
bugg (1/22/2013)
Any insight into dealing with deadlocks would be greatly appreciated.
In general:
Optimise the queries. If that doesn't fix the problem use one of the row versioning-based isolation levels
Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild
: Discussions on DB performance with occasional diversions into recoverability
We walk in the dark places no others will enter
We stand on the bridge and no one may pass
Post #1410087
bugg
bugg
Posted Tuesday, January 22, 2013 9:02 AM
SSC-Enthusiastic
Group: General Forum Members
Last Login: Today @ 8:43 AM
Points: 123,
Visits: 402
anthony.green (1/22/2013)
Do you have traceflag 1222 enabled?
If so can you post the deadlock graph from the error log
If not run
DBCC TRACEON (1222, -1)
and then post the graphs once a deadlock has occured.
Started profiler now. Will update once ive captured a deadlock
Post #1410092
bugg
bugg
Posted Tuesday, January 22, 2013 9:04 AM
SSC-Enthusiastic
Group: General Forum Members
Last Login: Today @ 8:43 AM
Points: 123,
Visits: 402
GilaMonster (1/22/2013)
bugg (1/22/2013)
Any insight into dealing with deadlocks would be greatly appreciated.
In general:
Optimise the queries. If that doesn't fix the problem use one of the row versioning-based isolation levels
Thanks Gila, I'm going to try using Rowlock with the update commands and see if that clears the locks.
Post #1410093
GilaMonster
GilaMonster
Posted Tuesday, January 22, 2013 9:04 AM
SSC-Dedicated
Group: General Forum Members
Last Login: Today @ 3:28 PM
Points: 37,730,
Visits: 29,996
bugg (1/22/2013)
anthony.green (1/22/2013)
Do you have traceflag 1222 enabled?
If so can you post the deadlock graph from the error log
If not run
DBCC TRACEON (1222, -1)
and then post the graphs once a deadlock has occured.
Started profiler now. Will update once ive captured a deadlock
Profiler? That traceflag writes the deadlock graph into the SQL error log, not a trace event.
Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild
: Discussions on DB performance with occasional diversions into recoverability
We walk in the dark places no others will enter
We stand on the bridge and no one may pass
Post #1410095
GilaMonster
GilaMonster
Posted Tuesday, January 22, 2013 9:06 AM
SSC-Dedicated
Group: General Forum Members
Last Login: Today @ 3:28 PM
Points: 37,730,
Visits: 29,996
bugg (1/22/2013)
GilaMonster (1/22/2013)
bugg (1/22/2013)
Any insight into dealing with deadlocks would be greatly appreciated.
In general:
Optimise the queries. If that doesn't fix the problem use one of the row versioning-based isolation levels
Thanks Gila, I'm going to try using Rowlock with the update commands and see if that clears the locks.
Optimise your queries, don't mess with locking hints unless you really understand what you're doing and why and have optimised as much as possible.
You do realise that a row lock hint means more chance of lock escalation (to table), not less?
Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild
: Discussions on DB performance with occasional diversions into recoverability
We walk in the dark places no others will enter
We stand on the bridge and no one may pass
Post #1410096
Michael Valentine Jones
Michael Valentine Jones
Posted Tuesday, January 22, 2013 9:07 AM
SSCrazy
Group: General Forum Members
Last Login: Today @ 6:26 PM
Points: 2,945,
Visits: 10,514
bugg (1/22/2013)
...
After a bit of research I don't really want to use SNAPSHOT ISOLATION or READ_COMMITTED_SNAPSHOT as this approach would require downtime to alter the database and possibly loads of testing and might be overkill for my needs and unnecessary overload on my temp db.
...
You do not need to take the database offline to enable SNAPSHOT ISOLATION, but you do need to for READ_COMMITTED_SNAPSHOT.
Post #1410097
bugg
bugg
Posted Tuesday, January 22, 2013 9:21 AM
SSC-Enthusiastic
Group: General Forum Members
Last Login: Today @ 8:43 AM
Points: 123,
Visits: 402
GilaMonster (1/22/2013)
bugg (1/22/2013)
anthony.green (1/22/2013)
Do you have traceflag 1222 enabled?
If so can you post the deadlock graph from the error log
If not run
DBCC TRACEON (1222, -1)
and then post the graphs once a deadlock has occured.
Started profiler now. Will update once ive captured a deadlock
Profiler? That traceflag writes the deadlock graph into the SQL error log, not a trace event.
Ahh right, I'm running SQL profiler and have set it up to watch for deadlocks and produce deadlock graphs.
Post #1410103
bugg
bugg
Posted Tuesday, January 22, 2013 9:24 AM
SSC-Enthusiastic
Group: General Forum Members
Last Login: Today @ 8:43 AM
Points: 123,
Visits: 402
GilaMonster (1/22/2013)
bugg (1/22/2013)
GilaMonster (1/22/2013)
bugg (1/22/2013)
Any insight into dealing with deadlocks would be greatly appreciated.
In general:
Optimise the queries. If that doesn't fix the problem use one of the row versioning-based isolation levels
Thanks Gila, I'm going to try using Rowlock with the update commands and see if that clears the locks.
Optimise your queries, don't mess with locking hints unless you really understand what you're doing and why and have optimised as much as possible.
You do realise that a row lock hint means more chance of lock escalation (to table), not less?
Nope I did not realize that! I thought it was specific to the row being updated
Post #1410105
« Prev Topic
|
Next Topic »
23 posts, Page 1 of 3
1
2
3
»
»»
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.