SLEEP_TASK is a general-purpose wait recorded when a task sleeps waiting for some event that has no more specific wait type. It covers background task scheduling gaps, some parallel plan exchange operators, buffer free-list stalls, and, most usefully for a DBA, phases of hash spills to tempdb.
It is a grab-bag by design, which is why it lives on every benign-wait filter list.
Is It a Problem?
In sys.dm_os_wait_stats totals, no; the accumulated number is dominated by background noise and safely filtered out. The one place it earns a second look is live analysis: if you catch an actively running query sitting in SLEEP_TASK in sys.dm_os_waiting_tasks, the likely story is a hash operation spilling to tempdb, and that specific query is worth a look.
So the rule is: ignore the cumulative statistic, but respect it on a live waiting task.
Common Causes
- Background task scheduling, the bulk of the accumulated total.
- Hash warnings: hash joins or aggregations spilling to tempdb mid-query.
- Certain exchange operator waits in parallel plans not tracked by
CXPACKET.
What To Do
- Filter it from cumulative wait analysis; our
Get-WaitStatisticsscript already does. - When a live query waits on it, check the actual plan for hash spill warnings and
sys.dm_exec_query_statsspill columns. - Fix spills the normal way: better estimates via fresh statistics, memory grant corrections, and indexes that shrink the hashed input.
How To See It
Rank waits with Get-WaitStatistics, where the cumulative figure is filtered. Its diagnostic value lives in sys.dm_os_waiting_tasks during live troubleshooting.
SLEEP_TASK is background noise on a healthy instance. If you are chasing a real problem, start with the waits that actually cost you time.
- The waits that usually matter, ranked, with what each one is telling you.
- Performance & Troubleshooting, the scripts and guides for this part of the stack.
Leave a Reply