HiveBrain v1.2.0
Get Started
← Back to all entries
snippetsqlModerate

how to simulate a low-memory state when running a query

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
lowqueryrunningstatememoryhowwhensimulate

Problem

I am trying to better understand how SQL Server's execution engine behaves in a low-memory state. Speaking in terms of memory grants, I am wondering if there is some way to force GrantedMemory to be equal to RequiredMemory. (My guess is that there's an undocumented trace flag which will do that. Does anyone know what it is?)

Solution

If you're on SQL Server 2012 SP3 or better, you can use the MAX_GRANT_PERCENT hint to cap a single query's memory grant. However, you'd have to mess with the number to figure out which percent gives you the correct value (to force GrantedMemory to be equal to RequiredMemory).

See here for more details.

Prior to that, you'd have to use Resource Governor (Enterprise only though).

Context

StackExchange Database Administrators Q#177601, answer score: 14

Revisions (0)

No revisions yet.