SLEEP_TASK 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?

In the cumulative totals, no. It is commonly filtered as benign, and Get Wait Statistics filters it out by default. On our SQL Server 2025 lab it had over a million waits in a day. The one place it earns a second look is a live query sitting in it.


What It Means

Microsoft’s definition: a task sleeps while waiting for a generic event to occur. It covers background task scheduling, hash spills to tempdb, buffer pool free list stalls, and some exchange operators in parallel plans that are not tracked as CXPACKET or EXECSYNC. It is a catch-all by design.


When It Does Matter

If you catch a running query waiting on it in sys.dm_os_waiting_tasks, look for hash spills:

SELECT
    wt.session_id,
    wt.wait_type,
    wt.wait_duration_ms,
    wt.blocking_session_id,
    wt.resource_description,
    t.text AS waiting_sql
FROM sys.dm_os_waiting_tasks AS wt
JOIN sys.dm_exec_requests AS r ON r.session_id = wt.session_id
CROSS APPLY sys.dm_exec_sql_text(r.sql_handle) AS t
WHERE wt.wait_type LIKE N'SLEEP_TASK'
ORDER BY wt.wait_duration_ms DESC;

Check the actual plan for hash spill warnings, and fix spills the usual way: fresh statistics for better estimates, and indexes that shrink the input to the hash. The baseline to monitor is spills on your heaviest queries, not this wait’s total. The query needs VIEW SERVER STATE.


The SLEEP Family

These are the sleep waits: threads pausing on purpose, at startup, between checkpoint writes, or while they wait for memory to free up. Most are filtered as benign, but the buffer pool memory sleeps are a memory pressure signal. If one is near the top of your waits, read it next to the waits that usually matter.

  • SLEEP_BPOOL_STEAL and memory sleepsNo free memory. Free list stalls and helping the lazy writer; a memory pressure signal when they rise.Worth a look when it climbs
  • SLEEP_BPOOL_FLUSHCheckpoint throttle. A checkpoint holding back new I/O so it does not flood the disks.Usually noise
  • SLEEP_DBSTARTUP and startup sleepsStartup. Waiting for databases, master and DCOM to finish starting.Usually noise
  • SLEEP_TASKGeneric sleep. A task sleeping while it waits for a generic event.Usually noise. This page.
  • LAZYWRITER_SLEEPLazy writer idle. The lazy writer suspended between runs.Usually noise

Where To Go Next

SLEEP_TASK is background noise on a healthy instance. 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 *