how to find out the most frequently run queries in a database

  • SELECT TOP 10

    sql.text as sql

    , qp.query_plan

    , creation_time

    , last_execution_time

    , execution_count

    , (total_worker_time / execution_count) as avg_cpu

    , total_worker_time as total_cpu

    , last_worker_time as last_cpu

    , min_worker_time as min_cpu

    , max_worker_time as max_cpu

    , (total_physical_reads + total_logical_reads) as total_reads

    , (max_physical_reads + max_logical_reads) as max_reads

    , (total_physical_reads + total_logical_reads) / execution_count as avg_reads

    , max_elapsed_time as max_duration

    , total_elapsed_time as total_duration

    , ((total_elapsed_time / execution_count)) / 1000000 as avg_duration_sec

    FROM sys.dm_exec_query_stats qs

    CROSS APPLY sys.dm_exec_sql_text(sql_handle) sql

    CROSS APPLY sys.dm_exec_query_plan (plan_handle) qp

    ORDER BY qs. total_worker_time DESC

  • Thank you for the information on a trace!

    Would you have a trace template that you would be willing to share?

Viewing 2 posts - 16 through 16 (of 16 total)

You must be logged in to reply to this topic. Login to reply