Is It a Problem?
Usually not on its own; steady amounts on an analytics workload are the cost of batch mode. Get Wait Statistics does not filter it out, so if it ranks, you will see it.
Guidance from the SQL Server team: these waits show how much skew there was between the threads more than how expensive the operation is. With perfect balance they are near zero; the higher the degree of parallelism and the skew, the more they accumulate. The main thing you can do is make sure there is not a lot of data sitting in columnstore delta stores, and do not reflexively lower MAXDOP, which will likely slow things down. For each HT wait, tune the query first, then consider the cost threshold for parallelism or a lower degree of parallelism. The two sources pull in different directions on MAXDOP, so test on the query rather than changing the server.
What It Means
Microsoft’s definition: it occurs with parallel batch-mode plans when synchronizing before scanning hash table to output matches / non-matches in hash join/aggregation. SQL Server 2012 built a hash table per thread and SQL Server 2014 moved to one shared table to save memory, at the cost of these synchronisation waits, and they typically appear with columnstore indexes but can occur whenever a hash operator runs in batch mode.
When It Does Matter
When one batch-mode query is slow and these waits dominate it, look at its actual plan: per-thread row counts on the hash operators show the skew. Find the heaviest parallel queries with:
SELECT TOP (20)
qs.total_elapsed_time / 1000 AS total_elapsed_ms,
qs.total_worker_time / 1000 AS total_cpu_ms,
qs.execution_count,
SUBSTRING(t.text, 1, 200) AS query_start
FROM sys.dm_exec_query_stats AS qs
CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) AS t
WHERE qs.total_worker_time > qs.total_elapsed_time
ORDER BY qs.total_worker_time DESC;
The baseline to monitor is the HT family’s share of wait time during your analytics windows. The query needs VIEW SERVER STATE.
The HT Family
These are the batch-mode hash table waits. Since SQL Server 2014, parallel batch-mode hash joins and aggregations share one hash table across threads, and these waits are the threads synchronising around it; they measure skew between threads more than cost. The main parallelism page is CXPACKET and CXCONSUMER.
- CXPACKET / CXCONSUMERParallelism. Producer and consumer threads in a parallel plan waiting on each other.The main page for this family
- HTBUILDBuild. Building the hash table on the input side; HTBUILD_JOIN and HTBUILD_AGG on current versions.Worth a look when it climbs
- HTREPARTITIONRepartition. Repartitioning the hash table on the input side.Worth a look when it climbs
- HTMEMOScan for output. Before scanning the hash table to output matches and non-matches.Worth a look when it climbs. This page.
- HTREINITReset. Before resetting the hash join or aggregation for the next partial join.Worth a look when it climbs
- HTDELETEEnd. At the end of the hash join or aggregation; HTDELETE_JOIN and HTDELETE_AGG on current versions.Worth a look when it climbs
Where To Go Next
HTMEMO follows batch-mode hash operations. If you are chasing a real problem, start with the waits that cost you time.
- CXPACKET and CXCONSUMER, the main parallelism page.
- 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