I recently found out about the activity monitor in SQL Server 2008 (I know, duh, right?). The tab "recent expensive queries" helped me quite a lot.
Now I'm trying to debug an overuse of the database in one client, but the server there is SQL Server 2005. There is an Activity Monitor there, but not "recent expensive queries" !
There are just three tabs: Process info, Locks by process and locks by object. The first one changes a lot and I am not being able to track the performance issue.
Thanks!
You can use this query as Performance Tips to find out your most expensive or costly queries in SQL Server. Below is the way to identify the most costly SQL Server queries using DMV. If you are running this query from SSMS, you can click on the query_plan to view the graphical representation of the execution plan.
The Recent Expensive Queries section shows the following: Number of executions per minute: How many times the query was executed during a minute. Amount of milliseconds spent by the query on CPUs per second: Ratio of time spent on CPU in every minute ...
The activity monitor in sql2k8 allows us to see the most expensive queries.
You can view recent expensive queries with this... I use it all the time, it has far more detail than Activity Monitor.
NB: This is for cached plans only.
SELECT TOP 10 SUBSTRING(qt.TEXT, (qs.statement_start_offset/2)+1,
((CASE qs.statement_end_offset
WHEN -1 THEN DATALENGTH(qt.TEXT)
ELSE qs.statement_end_offset
END - qs.statement_start_offset)/2)+1),
qs.execution_count,
qs.total_logical_reads, qs.last_logical_reads,
qs.total_logical_writes, qs.last_logical_writes,
qs.total_worker_time,
qs.last_worker_time,
qs.total_elapsed_time/1000000 total_elapsed_time_in_S,
qs.last_elapsed_time/1000000 last_elapsed_time_in_S,
qs.last_execution_time,
qp.query_plan
FROM sys.dm_exec_query_stats qs
CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) qt
CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) qp
--ORDER BY qs.total_logical_reads DESC -- logical reads
--ORDER BY qs.total_logical_writes DESC -- logical writes
ORDER BY qs.total_worker_time DESC -- CPU time
Source
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With