Skip to content

Instantly share code, notes, and snippets.

@ankona
Created May 4, 2021 15:51
Show Gist options
  • Save ankona/d66a2534a3f78a2f44bcad39e31975ea to your computer and use it in GitHub Desktop.
Save ankona/d66a2534a3f78a2f44bcad39e31975ea to your computer and use it in GitHub Desktop.
get some poorly performing queries & their query plans
-- Thanks to: https://blobeater.blog/2019/11/20/execution-plans-in-azure-sql-database/
SELECT top 10 (total_logical_reads/execution_count) as ReadsPerExec,
(total_logical_writes/execution_count) as WritesPerExec,
(total_physical_reads/execution_count) PhyReadsPerExec,
Execution_count, sql_handle, plan_handle, total_worker_time
FROM sys.dm_exec_query_stats
ORDER BY (total_logical_reads + total_logical_writes) Desc
SELECT * FROM sys.dm_exec_query_plan (0x060028007491E823E0C7342EC101000001000000000000000000000000000000000000000000000000000000)
/*
select top 1 * FROM sys.dm_exec_query_stats
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment