ResorceGovernor--基础和Demo

资源调控器分为三部分:
1:资源池,将资源CPU/MEMORY划分到不同的载体上
2:负载组,承载负载并将负载映射到不同的资源池
3: 分类函数,将不同回话映射到不同的负载组
08提供两种预定义的系统资源池
1:internal,内部资源池,只用于SQL数据库引擎,系统管理员不能改变和设置;
2:default,默认资源池,所有未分配资源池的的回话都使用默认资源池,默认资源池不能被修改和删除;

所有资源池的下限之和不得超过100%,因为系统会尽量满足资源池下限
资源池的上线可设置为下限到100%之间

ResorceGovernor--基础和Demo
--==========================================================
 
USE [master]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
 
--创建资源池
CREATE RESOURCE POOL AppPool
WITH (
   -- allocate at least <MIN_CPU_PERCENT, int, 10>% of the CPU bandwidth for admin queries
   MIN_CPU_PERCENT = 0
   -- do not let them exceed <MAX_CPU_PERCENT, int, 30>% either
   , MAX_CPU_PERCENT = 70
   -- admin queries should be small and we will allocate about <MIN_MEMORY_PERCENT, int, 5>%
   -- of the server memory for them
   , MIN_MEMORY_PERCENT = 0
   , MAX_MEMORY_PERCENT = 80
)
GO
 
--创建负载组
CREATE WORKLOAD GROUP AppGroup
WITH (
   -- use all defaults
   IMPORTANCE = MEDIUM
   , REQUEST_MAX_MEMORY_GRANT_PERCENT = 10
   , REQUEST_MEMORY_GRANT_TIMEOUT_SEC = 100
   , REQUEST_MAX_CPU_TIME_SEC = 10
   , MAX_DOP = 0
   , GROUP_MAX_REQUESTS = 0
)
USING AppPool
  
GO
 
 
--创建分类函数,将登陆用户TestUser的回话映射到负载组AppGroup
CREATE FUNCTION [dbo].[urgClassifier]()
RETURNS sysname
WITH SCHEMABINDING
AS
BEGIN
     DECLARE @grp_name AS sysname;
     SET @grp_name = default;
 
 
     IF (SUSER_SNAME()=TestUser)
     BEGIN
          SET @grp_name = AppGroup;
     END
 
 
     RETURN @grp_name;
END
GO
 
--为资源调控器设置资源组
ALTER RESOURCE GOVERNOR
WITH (
   CLASSIFIER_FUNCTION = [dbo].[urgClassifier]
)
GO
 
--更资源调控器设置
ALTER RESOURCE GOVERNOR RECONFIGURE
GO
 
--禁用资源调控器
ALTER Resource Governor DISABLE;
 
ResorceGovernor--基础和Demo

ResorceGovernor--基础和Demo

上一篇:小记——LocalFree与指针


下一篇:(转)xml序列化