All jobs / Database administrator / Performance
Database administrator interview question · 1–3 years
Both code paths update the `accounts` and `ledger` tables; the errors cluster around payroll runs.
The application logs show deadlocks a few times a day. What do you do?
The strongest answer
Capture the deadlock graph, find the two code paths that lock the same rows in opposite orders, and fix the ordering or shorten the transactions; the app should also retry the victim
Why it works
Exactly — deadlocks are a design symptom; the graph names the culprits.
What a good answer covers
- Read the deadlock graph.
- Fix lock ordering.
- Shorten transactions.
- Retry is hygiene, not the cure.
Answers that fall short
- Close, but not the strongest: Add retry logic in the application so the failed transaction runs again
Retry is necessary hygiene, but it treats the symptom and the deadlocks will keep coming. - Weak: Raise the deadlock timeout so the engine waits longer before choosing a victim
A deadlock never resolves by waiting; the timeout only delays the kill. - Red flag: Deadlocks are normal in a busy system; there is nothing a DBA can do
Consistent lock ordering removes most deadlocks entirely.
Who gets asked this
More Performance questions
- Several sessions sit “idle in transaction” for hours. Why does that matter and what do you do?
- A query that ran in milliseconds now takes minutes, right after a large data load. First suspect?
- The database shows thousands of identical tiny queries per page load. What is happening and what do you…
- What is a covering index and when is it worth it?
- Hundreds of application pods each keep a pool of twenty connections. The database is out of connections. Fix?
- The same parameterised query is fast for most customers and terribly slow for one large customer. What is…
- The plan cache is full of thousands of near-identical statements that differ only by literal values. Impact…
- A nightly job updating a few million rows locks the entire table and blocks the application. Why, and what do…