Share via


Memory grant related diagnostics

Cross post with https://aka.ms/sqlserverteam

Back in March I blogged about Addressing large memory grant requests from optimized Nested Loops. To further enhance discoverability of memory grant related issues, in SQL Server 2016 and 2014 SP2 we released a new xEvent (query_memory_grant_usage). This fires at the end of query processing for all queries with a memory grant over 5MB, and provides insight into potential memory grant inaccuracies.

image

Also in SQL Server 2014 SP2, we now included a new memory grant warning in showplan. This will also release on SQL Server 2016 in an upcoming update.

Purpose of this warning is to help identify potentially detrimental performance scenarios related to memory grants. As such, this is a warning that is only available at execution time, so an actual execution plan.

Three conditions can trigger this warning to show up in showplan:

  1. Excessive Grant: when max used memory is too small compared to the granted memory. This scenario can cause blocking and less efficient usage when large grants exist and a fraction of that memory was used.
  2. Used More Than Granted: when the max used memory exceeds the granted memory. This scenario can cause OOM conditions on the server.
  3. Grant Increase: when the dynamic grant starts to increase too much, based on the ratio between the max used memory and initial request memory. This scenario can cause server instability and unpredictable workload performance.

Below is a simple example of an excessive grant warning:

image

Pedro Lopes (@sqlpto) – Senior Program Manager