What is Memory Grants Pending in SQL Server? – Interview Question of the Week #103

Question: What is Memory Grants Pending in SQL Server?

A shared bookbinding press is busy while another stack waits for its turn

Answer: This subject could fill a long article, but an interview gives us only a few moments. Memory Grants Pending counts requests waiting for workspace memory. Sorts and hash operations are common reasons a query asks for a grant before it can proceed.

Here is the quick counter query from my original answer:

SELECT object_name, counter_name, cntr_value
FROM sys.dm_os_performance_counters
WHERE [object_name] LIKE '%Memory Manager%'
  AND [counter_name] = 'Memory Grants Pending';
Original SSMS result showing Memory Grants Pending with a counter value of zero
The original SSMS capture shows zero requests waiting at the instant it was taken.

Zero is the value I hope to see, but it means only that no grant request was waiting at that instant. It does not prove there was no earlier memory pressure or that every query had a sensible grant. A single nonzero sample calls for investigation; a counter that stays above zero during a slow workload deserves closer attention.

I would then inspect the waiting and granted requests in sys.dm_exec_query_memory_grants, the RESOURCE_SEMAPHORE waits, and the expensive plans behind them. Excessive grants, poor estimates, and too many concurrent memory-hungry queries can all contribute. More RAM might help a genuine capacity shortage, but the counter alone is not a purchase order.

That is my short interview answer: Memory Grants Pending tells you how many requests are waiting now, then you investigate why.

Published by Pinal Dave on SQLAuthority. More of my work at pinaldave.com.


Discover more from SQL Authority with Pinal Dave

Subscribe to get the latest posts sent to your email.

SQL Memory, SQL Scripts, SQL Server
Previous Post
How to Use OR Condition in CASE WHEN Statement? – Interview Question of the Week #102
Next Post
How to Find Number of Times Function Called in SQL Server? – Interview Question of the Week #104

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.