How would you identify and correct performance issues in a SQL database?
Instruction: Describe the steps you would take to diagnose and solve performance problems in a SQL database.
Updated
Official answer
Start with the observed symptom: which operation is slow, when it changed, its latency distribution, error rate, throughput and business impact. Compare to a baseline and recent deployments/data growth. Daily active users alone does not identify database pressure.
Separate query execution from connection-pool waits, network delay and lock waits. Inspect workload-level query totals, CPU, disk latency, memory/spills, active transactions and blockers. A moderately slow query called thousands of times may matter more than one rare expensive query.
For a representative query, inspect its plan and cardinality estimates, parameter sensitivity, statistics, indexes and unnecessary work. Reproduce safely; actual-plan execution can be costly or execute writes. Check transaction duration and application N+1 queries as well as SQL text.
Make a targeted change with a rollback path, then compare equivalent results and workload measurements. Indexes add write/storage costs; replacing a subquery with a join can alter duplicates. Capacity changes can help a measured resource constraint but may conceal an inefficient access pattern. Watch the same latency/error metrics after release and verify that the bottleneck was not merely moved.