The SQL Booklet · Troubleshooting and optimization

Investigate SQL Server signals.

Twenty-three queries for observing activity, relating metrics, and deciding on the next reasonable check.

A guided path

A diagnostic query starts the investigation.

Dynamic management views, cache, Query Store, and events preserve different kinds of evidence. Some views describe current state; others accumulate data since a restart or depend on a plan remaining available.

The path separates observation, hypothesis, and action. A high wait, an index suggestion, or an expensive query needs context before it becomes a recommendation.

How to use it

How to interpret each value.

  1. Distinguish the observed periodSeparate current state, accumulated data, cache, and intervals retained by Query Store.
  2. Relate several signalsAn isolated metric directs the investigation, but rarely proves a cause.
  3. Review permissions and costAdministrative queries may require elevated permissions or scan an entire instance.
  4. Define the next checkEach result leads to a more precise question and a delimited check.

Editorial method

Evidence-based conclusions.

Queries state permissions, time scope, and conditions that can alter the output. Accumulated results describe their observation period. A correlation requires checking the cause.

High-impact actions—terminating sessions, clearing plans, changing configuration, or creating indexes—remain outside a blind recommendation. The hypothesis and possible side effects are reviewed first.

Read the editorial methodology

The path

Activity, resources, and changes.

The path begins with what is happening now and expands the investigation toward trends, structures, and regressions.

Section 1

Active work, blocking, and transactions

Queries for observing requests, reconstructing blocking chains, and distinguishing sessions that retain open work.

  1. 01View active requests and their SQL text
  2. 02Identify blocking and blocked sessions
  3. 03Build the blocking chain
  4. 04Find long-running open transactions
  5. 05Find idle sessions with an open transaction
  6. 06View waits for active requests
Section 2

Waits and accumulated consumption

Signals for reviewing waits, CPU, reads, and duration without confusing accumulation with cause.

  1. 07Review the main accumulated waits
  2. 08Find queries with the highest total CPU use
  3. 09Find queries with the highest logical reads
  4. 10Find queries with the highest average duration
Section 3

Plans, indexes, and statistics

Cached plans, suggestions, usage, fragmentation, and statistics state as evidence that requires context.

  1. 11Retrieve a cached execution plan
  2. 12Review missing-index suggestions
  3. 13Review index usage
  4. 14Review index fragmentation with controlled scope
  5. 15Review statistics age and modifications
Section 4

Space, log, events, and regressions

File usage, log reuse, deadlocks, and performance changes observed through Query Store.

  1. 16Measure data and log space by database
  2. 17Diagnose why the transaction log cannot be reused
  3. 18Retrieve recent deadlocks from system_health
  4. 19Find regressed queries with Query Store
Section 5

Resources and plan stability

tempdb, memory grants, per-file latency, and queries that retained multiple plans.

  1. 20Find sessions and requests consuming tempdb
  2. 21Review pending or excessive memory grants
  3. 22Calculate read and write latency by file
  4. 23Find queries with multiple plans and different performance