Sql-server – SP_WhoIsActive – RESOURCE_SEMAPHORE_QUERY_COMPILE

performanceperformance-tuningsql-server-2008-r2

Had an issue with one of our production servers earlier today. Many transactions were suspended with RESOURCE_SEMAPHORE_QUERY_COMPILE wait.
Have sp_whoisactive data logged to table every minute. Below is a snippet from it. It is ordered by USED_MEMORY.

enter image description here

Can someone help me understand the unit of measure for Used_Memory please or should i be looking at other measure to find the query that caused the memory pressure.

Updated Pic of the same session :

enter image description here

Best Answer

The sp_WhoIsActive documentation says:

The [used_memory] column is also reported based on a number of 8 KB pages. The number a combination of both procedure cache memory and workspace memory grant.

However, I need to point out a few things in your question:

  • Queries that are waiting on compilation memory aren't shown in your screenshot
  • Those queries waiting for compilation memory are looking for a different kind of memory (gateways) - I'm not saying you don't have memory pressure, I'm just saying I probably wouldn't sort by memory_used to track the problem down
  • Your screenshot shows a serious blocking issue - queries have been waiting minutes (not seconds) because they're blocked by others

In your case, I'd start by troubleshooting the lead blocker. Don't worry about the queries waiting to compile - they haven't even started yet. In your scenario, the last thing you should be doing is starting even more queries, which are likely to just get blocked anyway and consume more workspace memory while they wait. Get the lead blocker out of the way instead.