programming4us
programming4us
DATABASE

SQL Server 2008: Managing Resources with the Resource Governor (part 3) - Classifier Function

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019

16.8.3. Classifier Function

The classifier function is a T-SQL function that is executed for each login, which allows you to write logic to route incoming requests to the appropriate workload group. You must create the classifier function in the master database, and the Resource Governor can only use one classifier function at any given time. You can, however, create multiple classifier functions and dynamically change which function the Resource Governor uses. You can use the following functions to help you create your classifier function:

  • HOST_NAME()

  • APP_NAME()

  • SUSER_NAME()

  • SUSER_SNAME()

  • IS_SRVROLEMEMBER()

  • IS_MEMBER()

  • LOGINPROPERTY(suser_name(),'DefaultDatabase')

  • LOGINPROPERTY(suser_name(),'DefaultLanguage')

  • ORIGINAL_DB_NAME()

  • CONNECTIONPROPERTY(<PropertyName>)

You can also create a lookup table to help you with your classifier function. For example, you may want to send certain processes to a different workload group, depending on a schedule you have defined in your lookup table. However, you need to keep in mind that SQL Server will execute the classifier function for each login, so it should be as efficient as possible in order to prevent performance issues. A good thing to keep in mind is that the dedicated administrator connection will never be classified, so you can always log in using this connection to fix any issues you may encounter.

The workload groups used in the classifier function are case sensitive. If you do not use the correct case when referencing the workload groups, the requests will be routed to the default workload group.


Let's create a classifier function that will route the incoming requests to the workload groups shown in Figure 16-15 by running the script in Listing 3.

Example 3. Code to Create and Enable a Classifier Function
USE master
GO

CREATE FUNCTION RG_Classifier_V1 ()
RETURNS sysname
WITH SCHEMABINDING
AS
BEGIN

DECLARE @GroupName sysname

IF (IS_MEMBER('KEN-PC\TestingGroup') = 1)
SET @GroupName = 'TestingGroup'

ELSE IF (APP_NAME() LIKE '%REPORT SERVER%')
SET @GroupName = 'ReportingGroup'

ELSE IF (SUSER_NAME() = 'BackupUser')
SET @GroupName = 'BackupGroup'

ELSE
SET @GroupName = 'default'

RETURN @GroupName

END
GO

--Assign the function to the Resource Governor and reconfigure
ALTER RESOURCE GOVERNOR WITH (CLASSIFIER_FUNCTION = dbo.RG_Classifier_V1)
GO
ALTER RESOURCE GOVERNOR RECONFIGURE
GO

You can see the completed configuration (shown in Figure 3) by right-clicking on Resource Governor in SQL Server Management Studio and selecting Properties from the context menu.

Figure 3. Resource Governor properties

In order to remove a classifier function from the Resource Governor, you can run the ALTER RESOURCE GOVERNOR statement and specify the new classifier name, or NULL if you want to remove all classifier functions and send all requests to the default workload group. The statement in Listing 4 will remove all classifier functions from the Resource Governor.

Example 4. Code to Remove All Classifier Functions from the Resource Governor
ALTER RESOURCE GOVERNOR WITH (CLASSIFIER_FUNCTION = NULL);
GO
ALTER RESOURCE GOVERNOR RECONFIGURE;

Other  
 
Top 10
Free Mobile And Desktop Apps For Accessing Restricted Websites
MASERATI QUATTROPORTE; DIESEL : Lure of Italian limos
TOYOTA CAMRY 2; 2.5 : Camry now more comely
KIA SORENTO 2.2CRDi : Fuel-sipping slugger
How To Setup, Password Protect & Encrypt Wireless Internet Connection
Emulate And Run iPad Apps On Windows, Mac OS X & Linux With iPadian
Backup & Restore Game Progress From Any Game With SaveGameProgress
Generate A Facebook Timeline Cover Using A Free App
New App for Women ‘Remix’ Offers Fashion Advice & Style Tips
SG50 Ferrari F12berlinetta : Prancing Horse for Lion City's 50th
- Messages forwarded by Outlook rule go nowhere
- Create and Deploy Windows 7 Image
- How do I check to see if my exchange 2003 is an open relay? (not using a open relay tester tool online, but on the console)
- Creating and using an unencrypted cookie in ASP.NET
- Directories
- Poor Performance on Sharepoint 2010 Server
- SBS 2008 ~ The e-mail alias already exists...
- Public to Private IP - DNS Changes
- Send Email from Winform application
- How to create a .mdb file from ms sql server database.......
programming4us programming4us
programming4us
 
 
programming4us