We hear it in all kinds of shops: the order screen is usually instant, then now and then it hangs, and nobody can make it happen on demand. A sometimes slow query SQL Server runs all day is expensive to chase. People lose hours waiting for it to misbehave, and the business quietly learns to distrust the application.
How do I find a sometimes slow query SQL Server keeps running? To find a sometimes slow query SQL Server has cached, compare each statement's minimum, average, maximum and last elapsed time in sys.dm_exec_query_stats. A wide gap between average and maximum marks the inconsistent ones. Then check whether reads, CPU, memory grant or parallelism moved with it, because that points to the cause.
The usual first move is to sort cached statements by average duration. It feels reasonable. It also misleads. A statement averaging 400 ms might take 400 ms every single time. Or it might take 40 ms for most callers and 9 seconds for the one unlucky parameter value. Both show the same number, yet only the second one generates the angry phone call.
The Unstable Queries report in Database Health Monitor is built to tell those two apart. It reads what the plan cache already holds for each statement: the minimum, average, maximum and most recent values. That matters on a database where nobody ever turned on Query Store, because the cache may be the only local evidence you have.
Unstable Queries is one of the reports in Database Health Monitor. It runs against your own servers, and it takes about a minute to have this same screen open on one of them.
Measure the spread, not the average
The honest number is the spread: the maximum divided by the average. It says how far the worst run strayed from the typical one. You can measure it on elapsed time, CPU, reads or rows, and the ranking follows your choice. Elapsed time matches what users feel. Reads show whether SQL Server did more work.
Run counts matter too. With fewer than about ten executions, a minimum and maximum say very little, so the toolbar lets you require 5, 10, 50 or 500 runs. Stable statements are hidden by default. What remains is a much shorter list, and each row on it has earned a second look.
Finding a sometimes slow query SQL Server has cached
A wide spread proves that something varies. It does not say why. So each statement is given a class based on which counter moved, along with a verdict naming the report to open next.
| Class | What it suggests |
|---|---|
| Regressed recently | A run in the last hour took at least 3 times the average |
| Data volume | A parameter decides how many rows get touched |
| Grant | A sniffed sort or hash is sizing memory very differently |
| Parallelism | Degree of parallelism changes between runs |
| Waiting | Time swings while reads stay fairly level |
| CPU variance | CPU swings while reads hold steady |
The difference between Data volume and Waiting can save a day. In the first, SQL Server really is reading far more for some callers, so parameters and histograms deserve attention. In the second it is not working harder at all. It is stuck, and blocking is a sensible suspect. Rewriting that query would be effort spent in the wrong place.
Hovering over a row shows its counters as a small table. A right click opens the Query Card or the Query Tuning Workbench, or jumps to the follow-up reports for that class. Column definitions are in the Unstable Queries documentation. If the real concern is a statement that reads too much on every run, see Logical Reads Per Row: Which Query Reads Too Much?
Know what the numbers cover
The plan cache is not a history. A restart or memory pressure empties it, and a recompile starts the counters over for the new plan. Minimum and maximum only reach back to when the plan was cached, so the line above the grid shows the oldest cache time among the listed rows. Read that line first.
Version matters as well. The report runs on SQL Server 2008 or later, but rows returned need 2012, memory grant and parallelism need 2016, and spills need 2016 SP2 or 2017 CU3. Older servers simply show fewer columns and classes, and the page tells you which are missing.
One more catch. The list is cut to the top 50, 100 or 300 by the spread of the chosen counter. A statement that only varies its memory grant can fall outside a small list ranked on elapsed time, so widen it before declaring the server clean.
What to check on your own server
- Check that your login has VIEW SERVER STATE, or VIEW SERVER PERFORMANCE STATE on SQL Server 2022 and later
- Note when SQL Server last restarted and how old the cached plans are before trusting any minimum or maximum
- Compare average and maximum elapsed time for statements that have run at least ten times
- Check whether reads spread along with elapsed time, to separate extra work from waiting
- Review the compiled parameter values wherever reads and rows returned both swing widely
Try Database Health Monitor Today
Stop letting an average hide the query that is fast for most users and painfully slow for a few. Database Health Monitor shows it on every instance you connect, in the time it takes to open the report.
Download Database Health Monitor and run the Unstable Queries report against your own server. There is nothing to configure first, and you will know inside a few minutes whether it tells you something you did not already know.

