Database Reference
In-Depth Information
The results are as follows:
1. Now, the important task is to create a classifier function that will be called for each
new connection. Resource Governor supports user-defined functions, whose return
values are used for classifying sessions that are then routed to the appropriate
workload group.
2. This function's logic is to return the workload group where all connection requests will
be sent.
3. The classifier function can use several different connection-related functions for use
in the logic, including the system default HOST_NAME (), APP_NAME (), SUSER_
NAME (), SUSER_SNAME () .
4.
The following code is used for this function that screens the login name and
connection host name in order to see to which workload group that connection
should be assigned as per the above WORKLOAD group settings:
USE master
GO
CREATE FUNCTION dbo.SalesApp_PROD_classifier()
RETURNS sysname
WITH SCHEMABINDING
AS
BEGIN
DECLARE @resource_group_name sysname
IF SUSER_SNAME()IN('Login1','Login2')
SET @resource_group_name ='application_sales'
IF SUSER_SNAME()IN('Login3','Login4')
SET @resource_group_name ='application_stock'
IF HOST_NAME()IN('SalesAppHost1','SalesAppHost2')
SET @resource_group_name ='ad_hoc_queries'
-- If the resource group is still unassigned, use default
IF @resource_group_name ISNULL
SET @resource_group_name ='default'
RETURN @resource_group_name
END
GO
 
Search WWH ::




Custom Search