SQL SERVER – Queries Waiting for Memory Grant – Performance Tuning

Queries Waiting for memory grants give me evidence to investigate. A customer CTO requested that evidence before approving more RAM.

Busy loom stations are inspected beside a separate tray of waiting yarn bundles.

SELECT session_id, request_id, requested_memory_kb, granted_memory_kb,
       required_memory_kb, wait_time_ms, resource_semaphore_id
FROM sys.dm_exec_query_memory_grants
WHERE grant_time IS NULL
ORDER BY wait_time_ms DESC;
Historical customer output showing memory-grant pressure.
Historical customer output showing memory-grant pressure.
Additional original memory-grant result from that investigation.
Additional original memory-grant result from that investigation.

The query lists currently pending execution-memory grants when permissions allow. Grants support operators such as sorts and hashes. They don’t represent the entire engine memory footprint. An empty snapshot does not exclude intermittent pressure.

We first tuned queries, views and indexes and reviewed the memory budget. Remaining evidence supported an increase in this case. The measured workload improved afterward. That outcome does not establish a universal frequency or guarantee for hardware upgrades.

Check estimates, grants, concurrency, max server memory, Resource Governor limits and relevant waits. Compare the same workload before and after a targeted correction. The linked diagnostics support that investigation.

Related reading

A pending grant is not automatic proof of inadequate RAM, it is pressure to investigate in workload context.

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 Server
Previous Post
QDS_LOADDB Wait: Slow Startup and Query Store Load
Next Post
LPIM Memory Model: Check It With sys.dm_os_sys_info

Related Posts

1 Comment. Leave new

  • Tom Wickerath
    June 18, 2020 1:49 pm

    I’m curious why the requested and ideal memory values dropped significantly after increasing memory? Were those two screen shots taken on the same server?

    Can you give us an idea of what the before and after memory amounts were?

    Reply

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.