initial population of repo

This commit is contained in:
Thierry Schork
2022-12-30 10:37:11 +01:00
parent 969dc57be1
commit 5d7658d85f
72 changed files with 488 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
{
"id": "a4d55aef-b09a-41fc-8dfb-4cb38902d29a",
"prefix": "dmvTopQueries",
"description": "Top Cached SPs By Avg Elapsed Time ",
"body": "SELECT x.[SP Name]\r\n\t ,avg_elapsed_time = SUM(x.total_elapsed_time) / SUM(x.execution_count)\r\n\t ,total_elapsed_time = SUM(x.total_elapsed_time)\r\n\t ,execution_count = SUM(x.execution_count)\r\nFROM(\t\r\n\t\t-- Top Cached SPs By Avg Elapsed Time (SQL 2008 R2) (Query 45) (SP Avg Elapsed Time) \r\n\t\tSELECT TOP(50) p.name AS [SP Name], qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time], \r\n\t\tqs.total_elapsed_time, qs.execution_count, ISNULL(qs.execution_count/DATEDIFF(Minute, qs.cached_time, \r\n\t\tGETDATE()), 0) AS [Calls/Minute], qs.total_worker_time/qs.execution_count AS [AvgWorkerTime], \r\n\t\tqs.total_worker_time AS [TotalWorkerTime], qs.cached_time\r\n\t\tFROM sys.procedures AS p WITH (NOLOCK)\r\n\t\tINNER JOIN sys.dm_exec_procedure_stats AS qs WITH (NOLOCK)\r\n\t\tON p.[object_id] = qs.[object_id]\r\n\t\tWHERE qs.database_id = DB_ID()\r\n\t\tORDER BY avg_elapsed_time DESC \r\n\t) x \r\nGROUP BY x.[SP Name]\r\nORDER BY SUM(x.total_elapsed_time) DESC OPTION (RECOMPILE)\r\n\r\n-- This helps you find long-running cached stored procedures that\r\n-- may be easy to optimize with standard query tuning techniques\r\n"
}