RESOURCE_SEMAPHORE_QUERY_COMPILE

HIGH Triage
#memory#compile#plan-cache
Related diagnostic scripts:

Overview

Occurs when waiting for memory to compile queries. High values indicate the compile memory lock is contended, often from a high rate of ad-hoc query compilations or plan cache churn.

Key Metrics

MetricDescription
Wait TypeRESOURCE_SEMAPHORE_QUERY_COMPILE
CategoryTriage
SeverityHIGH

Troubleshooting

1. Identify the source

Use the following query to identify the top queries contributing to RESOURCE_SEMAPHORE_QUERY_COMPILE waits:

SELECT TOP 10
 [Wait Type] = wait_type,
 [Wait Seconds] = wait_time_ms / 1000,
 [Wait Count] = waiting_tasks_count,
 [Avg Wait Ms] = wait_time_ms / NULLIF(waiting_tasks_count, 0)
FROM sys.dm_os_wait_stats
WHERE wait_type = 'RESOURCE_SEMAPHORE_QUERY_COMPILE'
ORDER BY wait_time_ms DESC;

See Also