为 adhoc 查询创建池
首先创建一个除默认资源池之外的资源池
CREATE RESOURCE POOL [PoolAdhoc] WITH(min_cpu_percent=0,
max_cpu_percent=50,
min_memory_percent=0,
max_memory_percent=50)
GO
为池创建 worload 组
CREATE WORKLOAD GROUP [AdhocMedium] WITH(importance=Medium) USING [PoolAdhoc]
创建包含资源调控器逻辑的函数并附加它
create function [dbo].[ufn_ResourceGovernorClassifier]()
returns sysname with schemabinding
as
begin
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'
END
end
GO
alter resource governor
with (classifier_function = dbo.ufn_ResourceGovernorClassifier)
GO
alter resource governor reconfigure
GO