Synchronous Statistics Update Stall: Find the Cause

Synchronous Statistics Update Stall: Find the Cause

The query usually finishes in milliseconds. Then, once in a while, it sits. No blocker shows up, the code hasn't changed, and the next run is fast again, so the ticket gets closed as a blip. One possible cause is a synchronous statistics update stall: SQL Server decided a statistic was out of date and rebuilt it while your user waited.

How do I find a synchronous statistics update stall in SQL Server? To find a synchronous statistics update stall, capture the auto_stats Extended Events event while the slowness happens. Each synchronous update shows its duration, which is time the triggering query spent waiting, plus the table, statistic, sample percent and statement. Then check which statistics update repeatedly and which statements recompile because statistics changed.

Database Health Monitor has an Auto Statistics Activity report that records these updates as they happen and shows what each one cost. Picture a 400 million row table whose automatic update holds a user's query for 94 seconds. You want that on record, with a name attached.

Why staleness checks miss it

Most of us start by asking how stale the statistics are. You rank them by how far each modification counter has run past the update threshold. That is useful. It is also a forecast, telling you what will update next and nothing about what already ran, how long it took, or who paid.

It can mislead in a second way. An automatic update may sample 0.4 percent of a large table and overwrite the full scan histogram your nightly job built. Afterward the statistic looks fresh. The plan can still be worse.

The threshold itself also moves. Below compatibility level 130, without trace flag 2371, a table updates after 500 rows plus 20 percent have changed. At 130 and above, or with the flag, tables over 25,000 rows use the smaller of that figure and the square root of 1,000 times the row count. On 400 million rows, that is roughly 632,000 changes instead of about 80 million. Updates arrive far more often. If you raised the level recently, read Compatibility Level Per Database: The Silent Plan Change.

Measuring a synchronous statistics update stall

The honest number is the duration of the update event itself. When the update is synchronous, that duration is time added to the triggering query. No inference needed.

Pick 2, 5, 10 or 30 minutes, optionally one database, and click Capture. The page creates a short Extended Events session using auto_stats and sql_statement_recompile, reads it, resolves the names and drops the session. Stop ends early and keeps what was recorded. You need SQL Server 2012 or later and ALTER ANY EVENT SESSION.

Auto Statistics Activity 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.

Four views split up the evidence:

  • Events: every automatic update or load in time order, with async, sample percent, duration, rows sampled and retries. Synchronous updates also show the program and statement.
  • Hot Statistics: updates grouped by statistic, with a Recommendation, stall time, and the automatic sample against your maintenance sample.
  • Recompiles: recompile causes per statement. If more than half are Statistics changed and a hot statistic sits on one of its tables, the row names it.
  • Lifetime: SELECT StatMan statements from the plan cache, with executions and elapsed time.

A statistic counts as hot when it updated at least twice, at a rate of three or more per hour. Think of a queue table. Its statistic might update 38 times between morning and lunch.

Lifetime needs no capture and works on SQL Server 2008. It can come up empty, though, because some builds, including SQL Server 2025, don't cache those statements.

Match the fix to the pattern

There is no single switch. The right change depends on table size, churn and how much the wait hurts.

What you seeWhat to consider
Hot statistic, small table with high churnNORECOMPUTE plus a scheduled update
Hot statistic, large tableUpdate it in a maintenance window
Automatic sample under a tenth of maintenance sample, over 10 million rowsPERSIST_SAMPLE_PERCENT (2016 SP1 CU4 and later) or a FULLSCAN job
Stalls over 1 second, typical cached statement under 100 msAUTO_UPDATE_STATISTICS_ASYNC

Async has a trade. The triggering query stops waiting, but one query then runs on the old statistics. Decide that on purpose.

Right-click a hot statistic to get the scripts. The page never runs them, so you can review each one, test it and schedule it yourself. Column and view details are in the Auto Statistics Activity documentation.

What to check on your own server

  • Check the compatibility level of each busy database, because it decides which automatic update threshold applies
  • Capture auto_stats and sql_statement_recompile events for 10 minutes during a period when users report slowness
  • List any statistic that updated at least twice and at three or more times an hour
  • Compare the automatic sample percent with your maintenance sample on tables over 10 million rows
  • Compare synchronous stalls over one second with how long your typical cached statement takes

Try Database Health Monitor Today

A query hangs while SQL Server quietly updates statistics inside it, and nothing tells you which statistic did it or how long the wait was. 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 Auto Statistics Activity 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.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

To prove you are not a robot: *