I am still working on this..
But I execute this query as well, which gives the query plan
SELECT mg.granted_memory_kb, mg.session_id, t.text, qp.query_plan
FROM sys.dm_exec_query_memory_grants AS mg
CROSS APPLY sys.dm_exec_sql_text(mg.sql_handle) AS t
CROSS APPLY sys.dm_exec_query_plan(mg.plan_handle) AS qp
ORDER BY 1 DESC OPTION (MAXDOP 1)
and
This query
SELECT s.host_name, s.login_name,mg.*
FROM sys.dm_exec_query_memory_grants AS mg
inner join sys.dm_exec_sessions s
on mg.session_id = s.session_id
ORDER BY query_cost DESC
In my case, this is a dw server, I see more queries waiting for memory grant as day progresses.
Will be using your script as well to get some information such as duration, tempdb_allocations, read, writes etc.
Users claim that the server was running fine untill a few days back and now it is taking too much of a time to get the reports.
Trying to see what I can find and how I can help. Thanks for you tool.