During performance tuning conversation the very first question people often ask is what are the queries offending the server or in another word let us identify the queries which are the most resource intensive. The resources are often described as either Memory, CPU or IO. When we talk about the queries the same is applicable for them as well. The query which is doing lots of reads or writes are for sure resource intensive as well query which are taking maximum CPU time.
Performance tuning is a very deep subject and we all have our own preference regarding what should be the first step to tuning and what should be looked with the salt of grain. Though there is no denying that a query which uses more resources than what it should be using for sure require tuning. There are many ways to do identify query using intense resources (e.g. Extended events etc) but in this one we will go by simple DMV.
There is a small gotcha we all have to remember about usage of DMV is that it only brings back results from existing cache. So if you have a query which is very resource intensive but is not cached or if you have explicitly removed the query from the cache it will be not part of the result returned by this DMV. It is quite possible that a query is aged and removed from the cache if your cache is not huge. If your cache is large you may want to be careful in running this query during business hours as this query itself can be resource intensive.
Related Tips in SQL in Sixty Seconds:
- SQL SERVER – Find Most Expensive Queries Using DMV
- Simple Example to Configure Resource Governor – Introduction to Resource Governor
- SQL SERVER – DMV – sys.dm_exec_query_optimizer_info – Statistics of Optimizer
- SQL SERVER – Wait Stats – Wait Types – Wait Queues – Day 0 of 28
Reference: Pinal Dave (https://blog.sqlauthority.com)