Created
February 23, 2016 11:13
-
-
Save robsonalves/eb82c0c4ee56d661e441 to your computer and use it in GitHub Desktop.
SQL Server - Querys Pesadas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use [database] | |
go | |
select total_worker_time/execution_count as MediaCPU | |
, total_worker_time AS TotalCPU | |
, total_elapsed_time/execution_count as MediaDuration | |
, total_elapsed_time AS TotalDuration | |
, total_logical_reads/execution_count as MediaLogicalReads | |
, total_logical_reads AS TotalLogicalReads | |
, total_physical_reads/execution_count as MediaPhysicalReads | |
, total_physical_reads AS TotalPhysicalReads | |
, execution_count | |
, substring(st.text, (qs.statement_start_offset/2)+1 | |
, ((case qs.statement_end_offset when -1 then datalength(st.text) | |
else qs.statement_end_offset | |
end - qs.statement_start_offset)/2) + 1) as txt | |
, query_plan | |
from sys.dm_exec_query_stats as qs | |
cross apply sys.dm_exec_sql_text(qs.sql_handle) as st | |
cross apply sys.dm_exec_query_plan (qs.plan_handle) as qp | |
order by 1 desc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment