In the context of the SQL Server resource governor, why would I create a user-defined resource pool? It seems like you could get almost the same result by using the default resource pool for everything, and controlling resources instead using the workload group settings.
I've heard that there can be issues if too many resource pools are created, so I'm wondering what the advantages are over the workload group settings?
Best Answer
Think of the resource pool as physically dividing the CPU, memory, and IO of the server. This can be useful when you need to limit resources used by overlapping workloads. The workload groups further limit resources used at a query level within a pool. This can be useful when you need to limit resources used within a workload, perhaps to improve throughput.
The resource governor overview provides a few use cases that can only be satisfied with resource pools as opposed to resource groups. For example:
Resource pools have the
MIN_IOPS_PER_VOLUME
andMAX_IOPS_PER_VOLUME
options to limit IO. Workload groups do not have any options to limit IO.Workload groups are also limited in how they can control CPU usage. The
REQUEST_MAX_CPU_TIME_SEC
option doesn't actually enforce a hard limit on CPU by query:To properly limit CPU through a workload group you would need to use the
MAXDOP
option for workload groups but that may not be granular enough. Resource pools offer much better options for preventing runaway queries from using all of the CPU available on a server.It may seem that workload groups could be used to balance query memory grants for competing workloads with the
GROUP_MAX_REQUESTS
andREQUEST_MAX_MEMORY_GRANT_PERCENT
options. However, consider a workload that sends thousands of queries of various sizes to run against the server with a concurrency of up to 40 queries at once. A small percentage of the queries are memory hogs and if left unchecked would use all available memory for query grants. You find through performance testing that limitingREQUEST_MAX_MEMORY_GRANT_PERCENT
to 4% gives reasonable overall throughput. If you only configured this through a workload group you'd end up with:That could lead to good performance for that workload but could use all of the memory on the server. If you need another workload to run at the same time then you need to do configuration at the resource pool level. Suppose that you determine that the original workload can get by with 50% of the memory on the server. At the pool level you could set the following:
And at the workload group level you could set the following:
That would give you reasonable throughput for the first workload but also allow the second workload to run at the same time. The resource pool is used to divide resources between workloads and the workload group is used to divide resources between the queries that belong to the pool.