Resource Governor
Reading the Statistics
Section titled “Reading the Statistics”select *from sys.dm_resource_governor_workload_groups
select *from sys.dm_resource_governor_resource_poolsCreate a pool for adhoc queries
Section titled “Create a pool for adhoc queries”First create a resource pool besides the default one
CREATE RESOURCE POOL [PoolAdhoc] WITH(min_cpu_percent=0, max_cpu_percent=50, min_memory_percent=0, max_memory_percent=50)GOCreate the worload group for the pool
CREATE WORKLOAD GROUP [AdhocMedium] WITH(importance=Medium) USING [PoolAdhoc]Create the function that contains the logic for the resource governor and attach it
create function [dbo].[ufn_ResourceGovernorClassifier]() returns sysname with schemabindingasbegin return CASE WHEN APP_NAME() LIKE 'Microsoft Office%' THEN 'AdhocMedium' -- Excel WHEN APP_NAME() LIKE 'Microsoft SQL Server Management Studio%' THEN 'AdhocMedium' -- Adhoc SQL WHEN SUSER_NAME() LIKE 'DOMAIN\username' THEN 'AdhocMedium' -- Ssis ELSE 'default' ENDend
GO
alter resource governorwith (classifier_function = dbo.ufn_ResourceGovernorClassifier)
GO
alter resource governor reconfigure
GORemarks
Section titled “Remarks”Resource Governor in SQL Server is a feature that allows you to manage resource usage by different applications and users. It kicks in realtime by setting CPU and memory limits. It will help preventing that one heavy process will eat up all system resources while for example smaller tasks are awaiting them.
Only available in Enterprise Editions