One of the smartest ways to identify memory consumption issues in SQL Server is checking details of the queries waiting for memory grant. Below script will show all the queries that have acquired a memory grant or that still require a memory grant to execute. Queries that do not have to wait on a memory grant will not appear in the result. Also below script result will help you to identify queries that are requesting relatively large memory grants, perhaps because they are poorly written or they’re missing indexes that make the query more expensive.
1 2 3 4 |
SELECT * FROM sys.dm_exec_query_memory_grants q INNER JOIN sys.dm_exec_sessions s ON s.session_id=q.session_id WHERE CAST(q.session_id AS INT)<>@@SPID |
Leave a Comment