码迷,mamicode.com
首页 > 其他好文 > 详细

Resource governor2:Configuration query

时间:2016-06-12 14:01:27      阅读:289      评论:0      收藏:0      [点我收藏+]

标签:

SQL Server Engine 当前使用的configuration,称作 In-memory configuration,使用DMV:sys.dm_resource_governor_XXX查看;如果需要对Resource Governor Configuration进行更新,需要分两步。

Step1,更新Stored configuration。对Resource Governor组件的update,实际上修改的是Stored Configuration,并没有影响到SQL Server Engine 当前使用的In-Memory configuration。使用系统表sys.resource_governor_XXX查看Stored configuration的详细信息。

step2,更新Configuration,使用 ALTER RESOURCE GOVERNOR RECONFIGURE; 将SQL Server Engine的In-Memory configuration更新为 Stored Configuration。

 

一,查看 Resource Governor metadata

1,查看Resource Pool

sys.dm_resource_governor_resource_pools shows the in-memory configuration.To see the stored configuration metadata, use the sys.resource_governor_resource_pools catalog view.

select rgrp.pool_id,
    rgrp.name,
    rgrp.min_cpu_percent,
    rgrp.max_cpu_percent,
    rgrp.cap_cpu_percent,
    
    rgrp.min_memory_percent,
    rgrp.max_memory_percent,
    rgrp.max_memory_kb,
    rgrp.target_memory_kb
from sys.dm_resource_governor_resource_pools rgrp

cap_cpu_percent: Hard cap on the CPU bandwidth that all requests in the resource pool will receive. Limits the maximum CPU bandwidth level to the specified level.

min_memory_percent:The current configuration for the guaranteed amount of memory for all requests in the resource pool when there is memory contention. This is not shared with other resource pools.

2,查看Workload Group

默认设置,request_max_memory_grant_percent=25,意味着,a single request能够使用的内存是有上限的,不能超过max_request_grant_memory_kb的限制

select rgwg.group_id,
    rgwg.name,
    rgwg.pool_id,
    rgwg.importance,
    rgwg.max_request_cpu_time_ms,
    rgwg.request_max_cpu_time_sec,

    rgwg.request_max_memory_grant_percent,
    rgwg.max_request_grant_memory_kb,

    rgwg.group_max_requests,
    rgwg.max_dop
from sys.dm_resource_governor_workload_groups rgwg

max_request_cpu_time_ms: Maximum CPU usage, in milliseconds, for a single request.This is a measured value, unlike request_max_cpu_time_sec, which is a configurable setting.

request_max_cpu_time_sec: Maximum CPU use limit, in seconds, for a single request.

request_max_memory_grant_percent: Maximum memory grant, as a percentage, for a single request.

max_request_grant_memory_kb: Maximum memory grant size, in kilobytes, of a single request since the statistics were reset.

group_max_requests: Maximum number of concurrent requests.

max_dop: Maximum degree of parallelism for the workload group. The default value, 0, uses global settings. Is not nullable.

importance: Current value for the relative importance of a request in this workload group. Available importance is Low,Medium,High, with Medium being the default.


3, 查看classifier function

通过 sys.dm_resource_governor_configuration

-- Get the in-memory configuration. 
select
    object_schema_name(rgc.classifier_function_id) AS NActive classifier UDF schema,   
    rgc.classifier_function_id, 
    o.name as  NActive classifier UDF name ,
    o.type,
    o.type_desc,
    rgc.is_enabled,
    sm.definition
from sys.resource_governor_configuration rgc
inner join sys.objects o
    on rgc.classifier_function_id=o.object_id
inner join sys.sql_modules sm
    on o.object_id=sm.object_id

 

Appendix Script

创建 Resource governor 的示例代码

use master

CREATE RESOURCE POOL rpLowReource_Percent_20
WITH 
(
     MIN_CPU_PERCENT = 0,
     MAX_CPU_PERCENT = 20,
     CAP_CPU_PERCENT = 20,
     AFFINITY SCHEDULER = auto,
     MIN_MEMORY_PERCENT = 0,
     MAX_MEMORY_PERCENT = 20
);
go

CREATE WORKLOAD GROUP wgLowResource_Percent_20
WITH
(
    IMPORTANCE = MEDIUM,
    REQUEST_MAX_MEMORY_GRANT_PERCENT=20,
    REQUEST_MAX_CPU_TIME_SEC=0,
    REQUEST_MEMORY_GRANT_TIMEOUT_SEC=0,
    MAX_DOP=0,
    GROUP_MAX_REQUESTS=0
)
using rpLowReource_Percent_20;
go

use master
go

CREATE FUNCTION dbo.rgClassifierFunction_LowResource_Percent_20() 
RETURNS sysname
WITH SCHEMABINDING
AS
BEGIN
    DECLARE @Workload_Group_Name AS sysname
      IF (SUSER_NAME() = USER_READONLY)
          SET @workload_group_name = wgLowResource_Percent_20
    RETURN @workload_group_name
END;
GO

-- Register the classifier user-defined function and update in-memory configuration.
ALTER RESOURCE GOVERNOR WITH (CLASSIFIER_FUNCTION=dbo.rgClassifierFunction_LowResource_Percent_20);
GO
ALTER RESOURCE GOVERNOR RECONFIGURE;
GO

参考doc:

sys.dm_resource_governor_resource_pools (Transact-SQL)

sys.dm_resource_governor_workload_groups (Transact-SQL)

sys.dm_resource_governor_configuration (Transact-SQL)

Resource Governor Related Dynamic Management Views (Transact-SQL)

 

Resource governor2:Configuration query

标签:

原文地址:http://www.cnblogs.com/ljhdo/p/5061449.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!