Free Webcast: Avoiding Deadlocks by Query Tuning
I’d get the alert from a monitoring tool, and I’d look around to see if anyone was watching me. If the coast was clear, I’d… delete the notification.
Deadlocks were a mystery to me because I didn’t know how I was supposed to fix them. Sometimes the same queries could cooperate, and sometimes they couldn’t? The database server decided which one could pass, and which one would fail? What was I supposed to do about any of that? Besides, most of the time it wasn’t a problem – apps retried their queries, or users just ignored error messages and tried the process again.
But eventually, when I became a consultant, I had to confront my ignorance head-on and do something about it because some clients were having serious deadlock issues that they couldn’t ignore. I got help from smart people like Kendra Little, Erik Darling, and Jeremiah Peschka. I solved those client issues, claimed victory, and today deadlocks don’t scare me at all.
You can solve deadlocks in (at least) 3 ways:
- Having enough indexes to make your queries go fast, but not so many that they cause problems for inserts, updates, & deletes
- Using the right isolation level for your app’s needs, which typically isn’t the default – it’s RCSI
- Or worst case, tuning your queries
I say worst case because tuning your queries is usually the most labor-intensive option. It requires knowing the queries involved in the deadlocks, being able to understand what about them is causing a problem, and knowing how to rewrite/reorder them in a way that’ll avoid deadlocks.
In this free session on April 29th sponsored by Idera, I’ll show you why your queries need to work through tables in a consistent order while minimizing the number of times you touch a table. I’ll use a real-world deadlock example and rewrite the query to resolve the issue. Whether you’re a DBA or developer, you’ll walk away with practical strategies you can apply immediately to make your queries deadlock-resistant and your applications more resilient.
If you can’t make it live, Idera will email registrants the recording later to watch on their own time. See you there!
Related

Hi! I’m Brent Ozar.
I make Microsoft SQL Server go faster. I love teaching, travel, cars, and laughing. I’m based out of Las Vegas. He/him. I teach SQL Server training classes, or if you haven’t got time for the pain, I’m available for consulting too.
Get Free SQL Stuff
"*" indicates required fields


2 Comments. Leave new
Hey Brent, you’re a gem! Your analogies and the way you explain things through case studies are amazing. I rarely miss any of your videos. Hopefully, I’ll be able to grasp this one too!
Thanks, glad you enjoy my work!