metricsign
Start free
High severityresource

Power BI Refresh Error:
8645

What does this error mean?

A query waited too long for a memory grant to execute a sort or hash operation — the grant was never available.

Common causes

  • 1All available query memory is consumed by other concurrent queries
  • 2A single large query requests more memory than the server can grant
  • 3SQL Server max server memory is set too low relative to query memory needs

How to fix it

  1. 1Step 1: Find queries waiting for memory grants: SELECT * FROM sys.dm_exec_query_memory_grants WHERE granted_memory_kb IS NULL;
  2. 2Step 2: Identify the top memory consumers: SELECT TOP 10 session_id, requested_memory_kb, granted_memory_kb FROM sys.dm_exec_query_memory_grants ORDER BY requested_memory_kb DESC;
  3. 3Step 3: Add indexes to eliminate the sort/hash operations causing the large memory grant, or increase max server memory: EXEC sp_configure 'max server memory (MB)', 16000; RECONFIGURE;

Frequently asked questions

How do I reduce the memory grant required by a query?

The primary way is adding indexes that eliminate sorts and hash operations — these are the main consumers of memory grants. Run the query in SSMS with Actual Execution Plan and look for Sort and Hash Match operators.

What is QUERY_GOVERNOR and can it prevent 8645?

QUERY_GOVERNOR limits query cost, not memory — it does not prevent 8645. Use Resource Governor to limit memory grants per workload group: ALTER RESOURCE POOL with MAX_MEMORY_PERCENT.

Can error 8645 be avoided by using a smaller batch size in ADF?

Yes — reducing the batch size in ADF copy activities reduces the size of sort and hash operations, which reduces the required memory grant. Try batch sizes of 10,000–50,000 rows.

Official documentation: https://learn.microsoft.com/en-us/sql/relational-databases/errors-events/mssqlserver-8645-database-engine-error

Other resource errors