SQL Interview: 54 Deadlock Correction

This is a post in the SQL Interview series. These aren’t trick or gotcha questions, they’re just questions designed to scope out a candidate’s knowledge around SQL Server and Azure SQL Database.
Section: Administrtaion Level: Advanced
Question:
You have deployed a database application into production.
Soon after, you get reports that large numbers of deadlocks are occurring.
What is the most important first step in resolving deadlocks?
Answer:
While it might appear that looking into locking processes, etc. is critical, it is pointless reviewing these until you are certain that queries on the system are running efficiently.
The longer that queries run, the more likely it is that they will be holding locks longer than needed.
You should start by reviewing long-running queries, to correct any issues. Often, once you have done that, the deadlocks will have disappeared. Only after that has been done, you should start to review the locking behavior.
2025-06-09