I have a remote MS SQL Server and I have several types of queries.
I run some queries that are part of a low-latency production application, and need to ensure they get domne in a timely manner.
But I also have "research" queries that tend to be CPU heavy.
How can I set the classifier such that different queries (from the same user) run with different resource pools so that my research queries don't hog all the CPU?
I am stuck on how to do this because I can't differentiate by user.
Best Answer
The bad news
The only way to throttle the sessions you want is to uniquely identify them. If you cannot do this, then you cannot selectively throttle resources using the Resource Governor.
The good news
There are loads of ways to stratify connections into different resource pools. You may need the cooperation of the person(s) managing the application to segregate the incoming connections, but the options for classifying incoming connections for the purposes of resource pool assignment are functionally infinite. I recommend sticking to connection properties that you set on the application connection string. My favorites are...
host_name()
original_login()
program_name()
...but you can use any arbitrary logic that will uniquely (hopefully) apply to the incoming sessions you want to throttle. If you're feeling dangerous, you can use a lookup table and change the output of your classifier function on the fly (although the docs recommend against this).
For the copy-pasta hungry...
Demo Script
Demo Cleanup