QDS_CLEANUP_STALE_QUERIES_TASK_MAIN_LOOP_SLEEP Wait Type in SQL Server

⏳Part of the SQL Server Wait Types Library, every wait type explained.Related deep dive: IO_COMPLETION Wait TypeRelated pillar: Performance & Troubleshooting

Is It a Problem?

No. It is the Query Store cleanup task’s sleep between runs, it is commonly filtered as benign, and Get Wait Statistics filters it out by default. On our SQL Server 2025 lab, with Query Store active, it was still zero after a day of uptime, so do not expect it on every server either.


What It Means

Microsoft lists it as internal use only, from SQL Server 2014. It is a thread waiting for a timer between runs that remove old query information from Query Store. It is a pause between housekeeping runs, and the long name is the most interesting thing about it.


When It Does Matter

The wait itself never needs action. If cleanup is the worry, check whether each store stays under its size cap. A store that keeps filling up needs its CLEANUP_POLICY (STALE_QUERY_THRESHOLD_DAYS) or MAX_STORAGE_SIZE_MB adjusted for that database, not anything to do with this timer.

Query Store health has its own witness: sys.database_query_store_options, per database, shows actual_state_desc against desired_state_desc and the size used against max_storage_size_mb. The baseline to monitor is the actual state staying READ_WRITE with headroom under the cap; a store that has flipped to READ_ONLY because it filled up is the real problem. Get Query Store Status reads it for every database.


The QDS Family

These are the Query Store waits. Most are background timers and queues that tick over in every database with Query Store on; two of them can matter. If one is near the top of your waits, read it next to the waits that usually matter.

  • QDS_PERSIST_TASK_MAIN_LOOP_SLEEPPersist timer. The pause between runs that write Query Store data to disk.Usually noise
  • QDS_ASYNC_QUEUEPersist queue. Access to the queue of Query Store data waiting to be written to disk.Usually noise
  • QDS_CLEANUP_STALE_QUERIES_TASK_MAIN_LOOP_SLEEPCleanup timer. The pause between runs that remove old queries from the store.Usually noise. This page.
  • QDS_SHUTDOWN_QUEUEShutdown queue. Documented as internal use only; a background Query Store queue.Usually noise
  • QDS_DYN_VECTORInternal structure. Access to a thread-safe Query Store data structure.Usually noise
  • QDS_STMTNew query tracking. Registering a query Query Store has not seen before.Worth a look when it climbs
  • QDS_LOADDBLoading at startup. Query Store loading its data when a database starts up.Worth a look when it climbs

Where To Go Next

This wait is background noise wherever Query Store is on. If you are chasing a real problem, start with the waits that cost you time.

Comments

Leave a Reply

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