notebook/IT/SQL/SCRIPTS SQL QSA ORSYS/Demo top 10 des requêtes les plus pourries.sql

33 lines
1.1 KiB
MySQL
Raw Permalink Normal View History

2020-11-26 17:38:25 +00:00
-- top 10 des requ<71>tes les plus pourries
SELECT TOP 10
SUBSTRING(text,
(statement_start_offset/2) + 1,
((CASE statement_end_offset
WHEN -1 THEN DATALENGTH(text)
ELSE statement_end_offset
END - statement_start_offset)/2) + 1)
AS QUERY,
*
FROM sys.dm_exec_query_stats
CROSS APPLY sys.dm_exec_sql_text(sql_handle)
CROSS APPLY sys.dm_exec_query_plan(plan_handle);
GO
-- top 10 des proc<6F>dures les plus pourries
SELECT *
FROM sys.dm_exec_procedure_stats
CROSS APPLY sys.dm_exec_sql_text(sql_handle)
CROSS APPLY sys.dm_exec_query_plan(plan_handle);
-- top 10 des d<>clencheurs les plus pourries
SELECT *
FROM sys.dm_exec_trigger_stats
CROSS APPLY sys.dm_exec_sql_text(sql_handle)
CROSS APPLY sys.dm_exec_query_plan(plan_handle);
-- top 10 des UDF les plus pourries
SELECT *
FROM sys.dm_exec_function_stats
CROSS APPLY sys.dm_exec_sql_text(sql_handle)
CROSS APPLY sys.dm_exec_query_plan(plan_handle);