Follow

Identify the Top 20 queries running on the Kaseya database

PROBLEM:

How do I find the top 20 queries running on my SQL server?

SOLUTION:

It is not uncommon for other databases to be running on the same SQL server as Kaseya. To troubleshoot the issue and determine if Kaseya is the root cause, run the following SQL query to determine what the top 20 queries running in the SQL instance are.

SELECT TOP 20
(total_logical_reads/execution_count) AS
avg_logical_reads,
(total_logical_writes/execution_count) AS
avg_logical_writes,
(total_physical_reads/execution_count)
AS avg_phys_reads,
execution_count,
statement_start_offset as stmt_start_offset,
(SELECT SUBSTRING(text, statement_start_offset/2 + 1,
(CASE WHEN statement_end_offset = -1
THEN LEN(CONVERT(nvarchar(MAX),text)) * 2
ELSE statement_end_offset
END - statement_start_offset)/2)
FROM sys.dm_exec_sql_text(sql_handle)) AS query_text
-- , plan_handle
FROM sys.dm_exec_query_stats
ORDER BY
(total_logical_reads + total_logical_writes) DESC

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

0 Comments

Article is closed for comments.