zoukankan      html  css  js  c++  java
  • SQL Server Governer 控制资源的使用


    --- Create a resource pool for production processing 
    --- and set limits. 
    USE master; 
    GO 
    CREATE RESOURCE POOL pProductionProcessing 
    WITH 

         MAX_CPU_PERCENT = 100, 
         MIN_CPU_PERCENT = 50 
    ); 
    GO 
    --- Create a workload group for production processing 
    --- and configure the relative importance. 
    CREATE WORKLOAD GROUP gProductionProcessing 
    WITH 

         IMPORTANCE = MEDIUM 
    )USING pProductionProcessing
    --- Assign the workload group to the production processing 
    --- resource pool. 
    USING pProductionProcessing 
    GO 
    --- Create a resource pool for off-hours processing 
    --- and set limits. 

    CREATE RESOURCE POOL pOffHoursProcessing 
    WITH 

         MAX_CPU_PERCENT = 50, 
         MIN_CPU_PERCENT = 0 
    ); 
    GO 
    --- Create a workload group for off-hours processing 
    --- and configure the relative importance. 
    CREATE WORKLOAD GROUP gOffHoursProcessing 
    WITH 

         IMPORTANCE = LOW 

    --- Assign the workload group to the off-hours processing 
    --- resource pool. 
    USING pOffHoursProcessing; 
    GO 

    ALTER RESOURCE GOVERNOR RECONFIGURE; 
    GO 

    USE master; 
    GO 
    CREATE TABLE tblClassificationTimeTable 

         strGroupName     sysname          not null, 
         tStartTime       time              not null, 
         tEndTime         time              not null 
    ); 
    GO 
    --- Add time values that the classifier will use to 
    --- determine the workload group for a session. 
    INSERT into tblClassificationTimeTable VALUES('gProductionProcessing', '6:35 AM', '6:15 PM'); 
    go

    CREATE FUNCTION fnTimeClassifier() 
    RETURNS sysname 
    WITH SCHEMABINDING 
    AS 
    BEGIN 
    /* We recommend running the classifier function code under
    snapshot isolation level OR using NOLOCK hint to avoid blocking on
    lookup table. In this example, we are using NOLOCK hint. */
         DECLARE @strGroup sysname 
         DECLARE @loginTime time 
         SET @loginTime = CONVERT(time,GETDATE()) 
         SELECT TOP 1 @strGroup = strGroupName 
              FROM dbo.tblClassificationTimeTable WITH(NOLOCK)
              WHERE tStartTime <= @loginTime and tEndTime >= @loginTime 
         IF(@strGroup is not null) 
         BEGIN 
              RETURN @strGroup 
         END 
    --- Use the default workload group if there is no match 
    --- on the lookup. 
         RETURN N'gOffHoursProcessing' 
    END; 
    GO 


    ALTER RESOURCE GOVERNOR with (CLASSIFIER_FUNCTION = dbo.fnTimeClassifier); 
    ALTER RESOURCE GOVERNOR RECONFIGURE; 
    GO

  • 相关阅读:
    Java Web(5) Spring 下使用Junit4 单元测试
    聊聊单元测试(三)——Spring Test+JUnit完美组合
    浅谈ELK日志分析平台
    ELK 实现 Java 分布式系统日志分析架构
    ELK(ElasticSearch, Logstash, Kibana)搭建实时日志分析平台
    开源分布式搜索平台ELK(Elasticsearch+Logstash+Kibana)入门学习资源索引
    自动补全下拉框(可输入匹配的下拉框)
    这是一篇满载真诚的微信小程序开发干货
    微服务化的多组件项目,跨地域、分布式版本管理和发布方式
    解放双手,发掘更大的价值:智能化运维
  • 原文地址:https://www.cnblogs.com/yuzg/p/10725069.html
Copyright © 2011-2022 走看看