use master go create resource pool poolAdhoc with ( min_cpu_percent=10,max_cpu_percent=30, min_memory_percent=15,max_memory_percent=25 --min_iops_per_volume=0,max_iops_per_volume=2111111111 ); create resource pool poolReports with ( min_cpu_percent=20,max_cpu_percent=35, min_memory_percent=15,max_memory_percent=45 --min_iops_per_volume=0,max_iops_per_volume=2111111111 ); create resource pool poolAdmin with ( min_cpu_percent=15,max_cpu_percent=25, min_memory_percent=15,max_memory_percent=25 );
2:建立工做負載組而且關聯以上三個資源池數據庫
create workload group groupAdhoc using poolAdhoc; create workload group groupReports using poolReports; create workload group groupAdmin using poolAdmin;
3:建立用戶定義的分類函數:服務器
create function rgtest() returns sysname with schemabinding as begin declare @pg_name as sysname if(user_name()='sa') set @pg_name='poolAdhoc' --if (app_name()) return @pg_name end; go
4:將用戶自定義的分類函數註冊到資源調控器app
alter resource governor with(classifier_function=dbo.rgtest);
5,:啓用資源管理器函數
alter resource governor reconfigure
Resource Governor 可以自動判斷資源分配比例,若是沒有競爭資源池的話,那麼會分配100%資源應用,若是競爭激烈,會按照比例分配。從而使得各個資源池中的對象都可以使用必定的服務器資源完成本身的工做,從而能夠使得咱們預測系統的最差狀況,加強對數據庫的管理性。spa