- Error number
- 8651
- Severity
- 17 (resource or software problem)
- State
- Not documented by Microsoft (not reproduced here)
- Product
- Microsoft SQL Server Database Engine
- Versions
- All supported SQL Server versions (2016 to 2025)
- Category
- Memory
- Last reviewed
- 24 October 2026
On this page
What it means
Error 8651 means a query could not be given the memory grant it needs to run (for sorts, hashes and similar work) in the named resource pool, so it failed instead of starting.
Queries with memory-hungry operators get a memory grant before they start, from the grant memory of their resource pool. Error 8651 is raised when the grant the query requires cannot be provided in that pool. Microsoft's reference explains it as other processes consuming server memory, and its older message text tied it to the min memory per query setting: every grant is at least that size, so a high value makes grants harder to satisfy.
Read the pool name and pool_id: default (2) means ordinary work on an instance short of grant memory; a user-defined pool points to Resource Governor limits, which the message itself suggests checking. Severity 17 means a resource ran out; the server keeps running. If queries are queuing for grants and failing after a wait, you will see 8645 instead or as well.
Common causes
- Memory pressure on the instance: other processes or SQL Server components using memory, leaving too little for query grants.
- Concurrent queries with large grants (big sorts and hash joins) holding most of the pool's grant memory.
- A Resource Governor pool with a low MAX_MEMORY_PERCENT, or a workload group with a low REQUEST_MAX_MEMORY_GRANT_PERCENT, for the work that runs in it.
- An unusually high
min memory per querysetting, which raises the minimum size of every grant. - Overestimated row counts that make queries ask for far more memory than they use.
Diagnose it
Read-only These queries only read metadata and dynamic management views. They do not change data, permissions or configuration, so they are safe to run first.
How much grant memory does each pool have left?
SELECT pool_id, resource_semaphore_id,
total_memory_kb / 1024 AS total_mb, available_memory_kb / 1024 AS available_mb,
granted_memory_kb / 1024 AS granted_mb, used_memory_kb / 1024 AS used_mb,
grantee_count, waiter_count
FROM sys.dm_exec_query_resource_semaphores; For the pool_id in the message: little available memory with many grantees means the grant memory is used up by running queries.
Which running queries hold the largest grants?
SELECT mg.session_id, mg.pool_id, mg.group_id,
mg.required_memory_kb / 1024 AS required_mb, mg.requested_memory_kb / 1024 AS requested_mb,
mg.granted_memory_kb / 1024 AS granted_mb, mg.max_used_memory_kb / 1024 AS max_used_mb,
t.text AS query_text
FROM sys.dm_exec_query_memory_grants AS mg
OUTER APPLY sys.dm_exec_sql_text(mg.sql_handle) AS t
ORDER BY mg.granted_memory_kb DESC; The queries to tune. A grant much larger than max_used_mb is oversized by poor estimates.
How are the Resource Governor pools and groups limited?
SELECT p.pool_id, p.name AS pool_name, p.max_memory_kb / 1024 AS max_mb,
p.used_memory_kb / 1024 AS used_mb, p.out_of_memory_count, p.total_memgrant_count
FROM sys.dm_resource_governor_resource_pools AS p;
SELECT g.group_id, g.name AS group_name, g.pool_id,
g.request_max_memory_grant_percent, g.max_request_grant_memory_kb / 1024 AS max_grant_mb
FROM sys.dm_resource_governor_workload_groups AS g; The pool named in the message and the groups that use it. A small max_mb or max_grant_mb compared with the grants your queries request explains the failure.
Is memory short overall, and how are the settings?
SELECT total_physical_memory_kb / 1024 AS total_mb,
available_physical_memory_kb / 1024 AS available_mb,
system_memory_state_desc
FROM sys.dm_os_sys_memory;
SELECT TOP (10) type, SUM(pages_kb) / 1024 AS pages_mb
FROM sys.dm_os_memory_clerks
GROUP BY type
ORDER BY pages_mb DESC;
SELECT name, value_in_use
FROM sys.configurations
WHERE name IN (N'max server memory (MB)', N'min server memory (MB)', N'min memory per query (KB)'); Low available physical memory, an unusually large clerk, or a min memory per query far above its default of 1024 KB.
How to fix it
Each fix is labelled with what it changes. Try read-only checks and the least invasive fix first, and test changes outside production.
Make the big queries need less memory
Client or network sideIndex the heaviest queries so they read fewer rows or get rows already sorted, return only the needed columns, and avoid large sorts and hashes. Run big reports and batch jobs at quieter times so they do not all hold grants at once.
Correct the estimates and cap oversized grants
Client or network sideUpdate statistics on the tables of queries whose grants far exceed what they use, and for a specific query that keeps asking for too much, cap it with the MAX_GRANT_PERCENT hint. Watch for tempdb spills if the cap is too low.
SELECT ProductId, SUM(Quantity) AS Units
FROM dbo.OrderLines
GROUP BY ProductId
ORDER BY Units DESC
OPTION (MAX_GRANT_PERCENT = 10);
Review the Resource Governor limits for that pool
Changes configurationIf the message names a user-defined pool, compare its MAX_MEMORY_PERCENT and its workload groups' REQUEST_MAX_MEMORY_GRANT_PERCENT with the grants measured above, and adjust only what the measurements justify.
Caution: Resource Governor changes apply to the whole instance at ALTER RESOURCE GOVERNOR RECONFIGURE and move memory between workloads. Change one limit at a time and record the old values.
Review memory settings, but only after measuring
Changes configurationMicrosoft's actions include lowering an unusually high min memory per query and raising max server memory if it was set too low, and removing other applications that use the server's memory. Make these changes only from measurements of what Windows and SQL Server need.
Caution: sp_configure and RECONFIGURE change the whole instance at once. Record the old values so you can revert, and apply changes in a maintenance window.
Examples
A query cannot get its memory grant under memory pressure
Shown from the engine message catalogue; not reproduced here because it needs memory pressure or a Resource Governor change on the whole instance. The level and state a client sees were not observed in the lab, so only the message text is shown; the catalogue severity is 17.
SELECT o.CustomerId, l.ProductId, SUM(l.Quantity) AS Units
FROM dbo.Orders AS o
JOIN dbo.OrderLines AS l ON l.OrderId = o.OrderId
GROUP BY o.CustomerId, l.ProductId
ORDER BY Units DESC;
Could not perform the operation because the requested memory grant was not available in resource pool 'default' (2). Rerun the query, reduce the query load, or check resource governor configuration setting.
How to prevent it
Keep an eye on grant memory: the largest grants in the plan cache or Query Store, waiters in sys.dm_exec_query_resource_semaphores, and Memory Grants Pending. Tune new heavy queries before they reach production.
Leave memory settings such as min memory per query at their defaults unless a measured problem says otherwise, and size Resource Governor pools from the grants their workloads actually request.
Common questions
What is the difference between 8651 and 8645?
8645 means the query waited in the grant queue and timed out. 8651 means the grant it needs could not be provided in the pool. Both come from the same shortage of query memory and share the same diagnostics.
Microsoft says to decrease min memory per query. Should I?
Only if it was raised above the default of 1024 KB. That older advice comes from the previous message text; most cases today come from large grants or pool limits.
Is the message telling me to change Resource Governor?
It suggests checking it. If the pool named is default and you do not use Resource Governor, focus on the queries and on memory pressure instead.
Learn more on CodeWithSQL
Official documentation
- MSSQLSERVER_8651 (Microsoft Learn)
- Troubleshoot memory grant issues
- sys.dm_exec_query_resource_semaphores
- Resource Governor
Last technically reviewed 24 October 2026; examples and diagnostics run on SQL Server 2025 (17.0.1145.4). Message text checked against the engine's sys.messages catalogue.