Resource governor2:Configuration query

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 N‘Active classifier UDF schema‘,
    rgc.classifier_function_id,
    o.name as  N‘Active 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)

时间: 2024-11-08 22:47:56

Resource governor2:Configuration query的相关文章

asp.net core源码飘香:Configuration组件

简介: 这是一个基础组件,是一个统一的配置模型,配置可以来源于配置文件(json文件,xml文件,ini文件),内存对象,命令行参数,系统的环境变量又或者是你自己扩展的配置源,该组件将各个配置源的数据按统一的格式(IDictionary<string, string> Data)进行加载,进而对外提供调用接口. 不仅如此,有些配置源(如文件配置源)还可以在配置源的数据发生变化时进行重新加载(IDictionary<string, string> Data),而程序员随时可以判断是否

asp.net core源码飘香:Configuration组件(转)

简介: 这是一个基础组件,是一个统一的配置模型,配置可以来源于配置文件(json文件,xml文件,ini文件),内存对象,命令行参数,系统的环境变量又或者是你自己扩展的配置源,该组件将各个配置源的数据按统一的格式(IDictionary<string, string> Data)进行加载,进而对外提供调用接口. 不仅如此,有些配置源(如文件配置源)还可以在配置源的数据发生变化时进行重新加载(IDictionary<string, string> Data),而程序员随时可以判断是否

8623错误:The query processor ran out of internal resources and could not pro

8623错误:The query processor ran out of internal resources and could not produce a query plan 问题描述: 配置了SQL Server安全性16的告警,发送邮件通知,如下: 收到如下告警信息: 查看错误日志: Error: 8623, Severity: 16, State: 1.    The query processor ran out of internal resources and could n

解读ASP.NET 5 &amp; MVC6系列(5):Configuration配置信息管理

解读ASP.NET 5 & MVC6系列(5):Configuration配置信息管理 2015-05-18 07:44 by 汤姆大叔, 7103 阅读, 18 评论, 收藏, 编辑 在前面的章节中,我们知道新版的MVC程序抛弃了原来的web.config文件机制,取而代替的是config.json,今天我们就来深入研究一下配置文件的相关内容. 基本用法 新版的配置信息机制在Microsoft.Framework.ConfigurationModel命名空间下进行了重写,重写以后不仅支持XML

开发错误11:Configuration with name ‘default’ not found

开发错误11:Configuration with name 'default' not found 今天在导入一个sdkdemoapp3.0项目时,发现project build.gradle 与module build.gradle.内容也在一个build.gradle里面, 结果make project下 就报如下错: Configuration with name 'default' not found 说明,没找到默认的module  build.gradle; 所以要在setting

mybatis报错:A query was run and no Result Maps were found for the Mapped Statement、、Property [login_ip] not found on type [com.thinkgem.jeesite.common.permission.entity.PremissUser]问题解决

今天在做ssm项目的时候出现了: 先是出现 了错误: mybatis报错:A query was run and no Result Maps were found for the Mapped Statement 这是因为Dao.xml中的select标签中必须指定要返回的值的类型(注意:是返回值的单个类型,即如果你是返回一个List<User>的话,需要指定的是User) 具体的这种错误的解决办法见:https://www.cnblogs.com/isme-zjh/p/11757155.h

spring4.0之二:@Configuration的使用

从Spring3.0,@Configuration用于定义配置类,可替换xml配置文件,被注解的类内部包含有一个或多个被@Bean注解的方法,这些方法将会被AnnotationConfigApplicationContext或AnnotationConfigWebApplicationContext类进行扫描,并用于构建bean定义,初始化Spring容器. 注意:@Configuration注解的配置类有如下要求: @Configuration不可以是final类型: @Configurati

动态Entity Framework查询:Dynamic Query 介绍

小分享:我有几张阿里云优惠券,用券购买或者升级阿里云相应产品最多可以优惠五折!领券地址:https://promotion.aliyun.com/ntms/act/ambassador/sharetouser.html?userCode=ohmepe03 Dynamic Query是一个支持动态Entity Framework查询的库.它的设计初衷是为了减少在管理系统中大量出现的对一个数据集进行查找.排序.分页的这类场景的开发工作量,其设计思想是"markup is code ".通过

lr数据库参数化取数:The query result is empty and same is the parameter file问题原因

出现这个问题的原因: 是因为我们的查询结果存在中文 如果查询结果没有中文,显示正常 解决办法: 新建一个数据源: 重新再选择这个数据源,再次查询: 说明不是连接字符串的问题或者是mysql驱动的问题 问题2:Data Retriever failed to execute query解决方法 问题现象: 所有的环境都一样,仅仅只是两条sql语句不一样: select ProductName from SP_Product where ProductName='力士恒久嫩肤娇肤香皂115g'  这