Limit reporting load with Resource Governor (pool, workload group, classifier)
SQL ServerConfigurationCommand
USE master;
-- 1) Pool and workload group:
CREATE RESOURCE POOL [pool_report]
WITH (MIN_CPU_PERCENT = 0, MAX_CPU_PERCENT = 30, CAP_CPU_PERCENT = 40,
MIN_MEMORY_PERCENT = 0, MAX_MEMORY_PERCENT = 25);
CREATE WORKLOAD GROUP [wg_report]
WITH (IMPORTANCE = LOW, REQUEST_MAX_MEMORY_GRANT_PERCENT = 15,
MAX_DOP = 2, REQUEST_MAX_CPU_TIME_SEC = 600)
USING [pool_report];
GO
-- 2) Classifier function (in master, SCHEMABINDING required):
CREATE FUNCTION dbo.fn_rg_classifier()
RETURNS sysname
WITH SCHEMABINDING
AS
BEGIN
DECLARE @grp sysname = N'default';
IF SUSER_SNAME() = N'rapor_user' OR APP_NAME() LIKE N'Power BI%'
SET @grp = N'wg_report';
RETURN @grp;
END;
GO
-- 3) Enable:
ALTER RESOURCE GOVERNOR WITH (CLASSIFIER_FUNCTION = dbo.fn_rg_classifier);
ALTER RESOURCE GOVERNOR RECONFIGURE;
-- 4) Which session landed in which group:
SELECT s.session_id, s.login_name, s.program_name, wg.name AS workload_group, rp.name AS pool
FROM sys.dm_exec_sessions s
JOIN sys.dm_resource_governor_workload_groups wg ON wg.group_id = s.group_id
JOIN sys.dm_resource_governor_resource_pools rp ON rp.pool_id = wg.pool_id
WHERE s.is_user_process = 1;
-- Rollback:
-- ALTER RESOURCE GOVERNOR WITH (CLASSIFIER_FUNCTION = NULL); ALTER RESOURCE GOVERNOR DISABLE;What it does
Routes sessions from specific logins or applications to a separate workload group at connect time; protects the OLTP workload by capping that group's CPU, memory grants, DOP and CPU time per request.
When to use it
When reporting/BI queries starve OLTP, when ETL overlaps business-hours load, or for resource sharing on a multi-tenant server.
Caution
The classifier function runs on every new connection; a slow or failing function slows down or breaks every login (no queries or table access in it). If it misbehaves, connect via the DAC and set CLASSIFIER_FUNCTION = NULL. Classification happens only at connect time; existing sessions are not affected. CAP_CPU_PERCENT is a hard cap applied even when CPU is idle. MAX_CPU_PERCENT only applies under CPU contention. Resource Governor is an Enterprise/Developer feature.