Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the Report Query Execution Memory (Memory Grants) #386

Open
asavioliMSFT opened this issue Feb 14, 2025 · 0 comments
Open

Improve the Report Query Execution Memory (Memory Grants) #386

asavioliMSFT opened this issue Feb 14, 2025 · 0 comments
Assignees
Labels

Comments

@asavioliMSFT
Copy link
Contributor

The report Query Execution Memory (Memory Grants) is based on the table tbl_Query_Execution_Memory, which is not returning the main queries allocating memory for query execution (memory grants). We should use the table tbl_dm_exec_query_memory_grants instead, which is based on the dmv sys.dm_exec_query_memory_grants.

Suggestion we have for the query used by the report

WITH CTE AS (
SELECT TOP 10
mg.sql_handle,
mg.plan_handle,
MAX(granted_memory_kb) AS granted_memory_kb
FROM dbo.tbl_dm_exec_query_memory_grants mg
GROUP BY sql_handle, mg.plan_handle
ORDER BY MAX(granted_memory_kb) DESC
)
SELECT
c.*,
(SELECT TOP 1 n.procname
FROM tbl_NOTABLEACTIVEQUERIES n
WHERE c.plan_handle = n.plan_handle) AS procname,
(SELECT TOP 1 n.stmt_text
FROM tbl_NOTABLEACTIVEQUERIES n
WHERE c.plan_handle = n.plan_handle ) AS stmt_text
FROM CTE c
ORDER BY c.granted_memory_kb DESC;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants