SQL Server has an option for statistics to autoupdate asynchronously (AUTO_UPDATE_STATISTICS_ASYNC).

But, even if this option is ON, from time to time I see locks like this on pic below: say, spid 549 locks spid 42 and spid 42 locks 8 other sessions. As I can see, system spid tries to change old statistics to a newly computed one, so it waits for SCH-M lock to acquire.

enter image description here

Suddenly, it turns out, async stats update is not so async: any long-running SELECT (which, of course, holds SCH-S lock) can freeze system spid, which, in turn, can gather queue of many other sessions. Even worse, whole queue wait time depends on of locker’s SELECT duration. It means, if I have a long OLAP query, all the stalled sessions could be timed out.

So, my question is: am I missing something or it works just by design? Can I somehow avoid these sudden locks, caused by autoupdated statistics?

2 Answers 2




  • Link only answers are not acceptable. Please quote the essential points from the link Sep 24, 2023 at 12:58

It has nothing to do with SCH-S. Select queries which acquire S and IS locks are compatible with SCH-S, which is called Schema Stability and all it does, it prevents table during query execution from being modified which means SCH-S and SCH-M are not compatible. SCH-S is compatible with all other locks.

Your problem however is that you have auto update stats enabled, which are triggered whenever there is certain amount of data changed within a table (20% pre SQL2016 or with 2371 traceflag counts % depending on number of rows) and it does when you execute the query.

So what might have happened is that your table was pretty busy and query optimizer decided it should update statistics, so you had to wait.

You should disable auto update statistics and update it manually

  • Will updating stats manually not cause blocking? Jul 4, 2017 at 9:33
  • "Will updating stats manually not cause blocking? " -- it will
    – 0wl
    Jul 4, 2017 at 9:37
  • It will Erik, but at least he can be prepared for it, and update whenever he believes that these queries are not executed
    – S4V1N
    Jul 4, 2017 at 9:42
  • "Your problem however is that you have auto update stats enabled" -- Autoupdate statistics is exactly what I am trying to implement. And my goal is to make it create as less locks as possible. I thougth, async update would help me, but, you see, there are some complications. I agree, It has nothing with Schema-Stability. Problem occurs when system spid acquires Schema-Modification lock (to change, like I said, old statistics to a new one). And, as I see, this lock can cause a lot of other users stall on Schema-Stability lock, which is incompatible with SCH-M.
    – 0wl
    Jul 4, 2017 at 9:42
  • You should monitor how many rows are inserted/updated/deleted on a daily basis on that table/tables, and how often and when is that query executed and try to come up with a plan when to update statistics
    – S4V1N
    Jul 4, 2017 at 10:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.