為 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