What are Memory Grants
A memory grant is the workspace memory SQL Server reserves for a query before it runs, used by sorts, hash joins, and hash aggregates. The optimizer estimates the size from row counts and row widths. If the shared pool is exhausted, the query waits with a RESOURCE_SEMAPHORE wait. The memory stays reserved for the life of the query, whether it’s used or not.
Why large grants matter
- Concurrency: A few oversized grants can queue other queries while CPU and I/O sit idle.
- Buffer pool pressure: Grants compete with cached data pages, increasing physical reads.
- Over-grants: Memory granted but unused (granted memory vs. requested memory) is wasted.
- Under-grants: Underestimates cause sorts and hashes to spill to tempdb, slowing the query.
Common Causes: Stale statistics, parameter sniffing, missing indexes, wide rows or SELECT *, and high DOP.
What to monitor: Granted vs. used memory, queries waiting on a grant, RESOURCE_SEMAPHORE waits, tempdb spills, and repeat offenders with high max_grant_kb.
Solutions: Update statistics, tune indexes and queries, and use MAX_GRANT_PERCENT or Resource Governor to cap grants. On SQL Server 2017+, memory grant feedback adjusts grants automatically.
DPA Alert Results
The query used in this alert returns results similar to the screenshot below:
DPA Alert Configuration
Paste the attached query into the SQL Statement text box and use this screenshot as a template to build your own alert.