Professional Documents
Culture Documents
Introducing SQL Server 2008 R2 Resource Governor
Introducing SQL Server 2008 R2 Resource Governor
Call routing
Admin
Ad-hoc
Reports
Marketing
Workload prioritization
Call routing
Admin
Ad-hoc
Reports
Marketing
Pool 1
Pool 2
Demo : Setting up RG
USE master; GO -- Examine the current configuration SELECT * FROM sys.dm_resource_governor_configuration; GO
--Define two resource pools, one with 10% CPU max, and the other with 90% CREATE RESOURCE POOL MarketingPool WITH (MAX_CPU_PERCENT = 10); GO
Demo : Setting up RG
-- Need to reconfigure ALTER RESOURCE GOVERNOR RECONFIGURE; GO SELECT * FROM sys.dm_resource_governor_resource_pools; GO
-- Add two workload groups CREATE WORKLOAD GROUP MarketingGroup USING MarketingPool; GO
CREATE WORKLOAD GROUP DevelopmentGroup USING DevelopmentPool; GO
Demo : Setting up RG
-- Need to reconfigure again ALTER RESOURCE GOVERNOR RECONFIGURE; GO SELECT * FROM sys.dm_resource_governor_workload_groups; GO
---IF GO IF GO
Create some dummy databases. The classifier function will use the database name in the connection string to decide which group to put the connection in. DB_ID ('MarketingDB') IS NULL CREATE DATABASE MarketingDB;
DB_ID ('DevelopmentDB') IS NULL CREATE DATABASE DevelopmentDB;
-- Define a classifier function IF OBJECT_ID ('dbo.MyClassifier') IS NOT NULL DROP FUNCTION dbo.MyClassifier; GO
Demo : Setting up RG
CREATE FUNCTION dbo.MyClassifier () RETURNS SYSNAME WITH SCHEMABINDING AS BEGIN DECLARE @GroupName SYSNAME; IF ORIGINAL_DB_NAME () = 'MarketingDB' SET @GroupName = 'MarketingGroup'; ELSE IF ORIGINAL_DB_NAME () = 'DevelopmentDB' SET @GroupName = 'DevelopmentGroup'; ELSE SET @GroupName = 'Default'; RETURN @GroupName; END; GO -- Register it ALTER RESOURCE GOVERNOR WITH (CLASSIFIER_FUNCTION = dbo.MyClassifier); GO ALTER RESOURCE GOVERNOR RECONFIGURE; GO
Demo : Setting up RG
-- Look at our configuration again SELECT * FROM sys.dm_resource_governor_configuration; GO -- Now open System Monitor, Action | New Window From Here. -- Add the SQLDEV01 Resource Pools counters for Marketing and Development -- Run -- sqlcmd /E /S.\SQLDEV01 /d<dbname> /iRunQueries.sql -- Do marketing first and then development
RunQueries.sql
IF OBJECT_ID ('t1') IS NOT NULL DROP TABLE t1; GO CREATE TABLE t1 (c1 INT, c2 VARCHAR (8000)); CREATE CLUSTERED INDEX t1c1 ON t1 (c1); GO SET NOCOUNT ON; GO DECLARE @count INT; SET @count = 0; WHILE (@count < 1000) BEGIN INSERT INTO t1 VALUES (@count, REPLICATE ('a', 8000)); SET @count = @count + 1; END;
physical IOs (as the index is in the buffer pool any fragmentation) but it will spin the CPU while index. INDEX t1c1 ON t1 REORGANIZE;
Q&A
2007 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS SUMMARY.