Technical Article

Monitoring Resource Governor Memory Grants

,

We've been doing some performance testing of dimensional models and during these tests discovered that our resource governor was possibly throttling the CPU unexpectedly. After some research and digging, I found a few DMV's that would allow me to monitor the status of the resource governor, specifically in the area of memory grants. I wrote a custom query that pulls in several key items to help determine just who and what is working in specific pools in the resource governor. I hope you will find this query useful.

I hope you find this helpful,

Tim Parker

SELECT session_id AS SPID, 

 ( SELECT login_name 

 FROM sys.dm_exec_sessions 

 WHERE session_id = a.session_id 

 ) AS Login_Name, 

 ( SELECT [HOST_NAME] 

 FROM sys.dm_exec_sessions 

 WHERE session_id = a.session_id 

 ) AS [Host_Name], 

 ( SELECT cpu_time 

 FROM sys.dm_exec_sessions 

 WHERE session_id = a.session_id 

 ) AS cpu_time, 

 ( SELECT reads 

 FROM sys.dm_exec_sessions 

 WHERE session_id = a.session_id 

 ) AS reads, 

 ( SELECT writes 

 FROM sys.dm_exec_sessions 

 WHERE session_id = a.session_id 

 ) AS writes, 

 ( 

 SELECT TOP 1 [text] 

 FROM sys.dm_exec_cached_plans P 

 CROSS APPLY sys.dm_exec_sql_text(a.plan_handle) 

 ) AS SQL_Query, 

 ( SELECT name 

 FROM sys.dm_resource_governor_workload_groups 

 WHERE group_id = a.group_id 

 ) AS Group_Name, 

 request_time,

 CAST(DATEDIFF(mi, request_time, GETDATE()) AS VARCHAR(3)) + ' Minute(s)' AS Run_Time_Minutes, 

 ( requested_memory_kb / 1024 ) AS requested_memory_mb, 

 required_memory_kb, 

 max_used_memory_kb, 

 ( ideal_memory_kb / 1024 ) AS ideal_memory_mb, 

 ( ( ideal_memory_kb - requested_memory_kb ) / 1024 ) AS memory_required_mb 

FROM sys.dm_exec_query_memory_grants a

Rate

3.5 (2)

You rated this post out of 5. Change rating

Share

Share

Rate

3.5 (2)

You rated this post out of 5. Change rating