SQL SErver 2008 : Resource Governor in action
1. Resource Governor in action
Now that you have a solid understanding of the components that make up Resource Governor, let's walk through an example of its implementation. Let's imagine we have a database used for both a production point-of-sales application and as a source for a reporting system. Our goal is to constrain the CPU and memory resources consumed by the reporting system in order to reduce the impact on the point-of-sales system when large reports are executed.
Let's walk through the T-SQL code for creating the necessary components, beginning with the creation of the workload groups, as shown in listing 1.
Example 1. Creating workload groups
Despite the various options available, we create our workload groups with all of the default settings. Next up, we'll create the classifier function used to assign incoming connections to the appropriate group. After the function is created, we'll configure Resource Governor to use it, as shown in listing 16.3.
Example 16.3. Classifier function
In this example, our classifier function uses the login name via the SUSER_NAME() function as the basis for classification. As we explained earlier, this could be based on the application, host, or role membership using the appropriate function.
Our final step is to create the resource pools and assign them to the appropriate workload groups, as per listing 2.
Example 2. Assigning resource pools to workload groups
In the above example, we've created resource pools with minimum and maximum CPU and memory values. At this point, the only step left is to reconfigure the Resource Governor to enable the new settings. We can do this using the following command:
-- Reconfigure the Resource Governor to enable the new settings ALTER RESOURCE GOVERNOR RECONFIGURE GO
Once the above T-SQL has been executed, we can confirm our settings using SQL Server Management Studio by right-clicking Resource Governor and choosing Properties. The resultant screen, as shown in figure 1, allows us to modify the settings should we wish to do so.
Finally, should we wish to disable Resource Governor, we can do so using the following command:
-- Disable the Resource Governor ALTER RESOURCE GOVERNOR DISABLE GO
Figure 1. You
can use the properties window of Resource Governor to select the
classifier function and view or edit the resource pools and workload
groups settings.
To complete our coverage of Resource Governor, let's review some of the monitoring options available.