SQL Server 2014 – Meaning of Active and Recent Expensive Queries

activity-monitorsql serversql server 2014

I am trying to understand the active expensive queries and recent expensive queries in Activity Monitor. What is expensive means here? Does it means expensive in term of cpu, block, memory, reads?

Best Answer

It depends on what column you sort by. To dig deeper, I suggest you read the source code that these are on. I blogged about AM a while ago, here is a part from that blog post:

The “Recent Expensive Queries” pane:

This shows the most expensive queries, based on what column you sort on, executed since the last snapshot. If you have, say, a 10 second snapshot interval, you will only see the queries executed during these 10 seconds. AM uses a procedure named #am_get_querystats to collect the information. There are a few things going on inside this procedure, but at the most basic level, it uses sys.dm_exec_query_stats and sys.dm_exec_requests to get queries from cache and currently executing queries. It then does some processing and store the result in temp tables so we later can sort on different columns depending on what metric we are interested in. I suggest that you spend some time with the source code if you want to dig deeper.

The “Active Expensive Queries” pane:

This is very straight forward. It executes a query which uses sys.dm_exec_requests joined to a few other DMVs.

Here's a link to my blog post: http://sqlblog.karaszi.com/explaining-activity-monitor/