Considerations for Writing a Classifier Function
Resource Governor supports user-defined functions whose return values are used for classifying sessions that are then routed to the appropriate workload group.
The classifier user-defined function should be tested and optimized before use for classifying incoming requests. A poorly written function can render the system unusable by timing out, which in turn can expose configuration information. You can use a Dedicated Administrator Connection (DAC) to troubleshoot a poorly written classifier function because a DAC is not subject to classification and can be used while Resource Governor is running and classifying incoming sessions. For more information, see Using a Dedicated Administrator Connection.
Note
If a DAC is not available for troubleshooting, you can restart the system in single user mode. Although single user mode is not subject to classification, you cannot diagnose Resource Governor classification while it is running.
You can use existing system functions in your classifier functions and use the values these functions return for classifying sessions.
Functions
The following system functions can be used for classification: HOST_NAME(), APP_NAME(), SUSER_NAME(), SUSER_SNAME(), IS_SRVROLEMEMBER(), and IS_MEMBER().
Warning
When you create a function that returns a property that is used for classification, you must consider whether or not the property is secure. If not, you must assess the risk of using the attribute. The HOST_NAME() and APP_NAME() functions return properties that are not secure. For example, APP_NAME() can return any value that is provided in an application connection string.
The LOGINPROPERTY function has been updated with two properties that you can use for classification: DefaultDatabase and DefaultLanguage. In addition, you can use the ORIGINAL_DB_NAME function to obtain the name of the database that is specified in the user connection string.
Resource Governor also implements the CONNECTIONPROPERTY function to provide additional properties that you can use for classification. This function returns the same values for the properties for the unique connection that a request came on as the corresponding columns in the sys.dm_exec_connections dynamic management view.
See Also