<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Sys.dm_exec_query_plan on SQL Server Scripts</title><link>https://www.sqlserver70.com/tags/sys.dm_exec_query_plan/</link><description>Recent content in Sys.dm_exec_query_plan on SQL Server Scripts</description><generator>Hugo -- gohugo.io</generator><language>en</language><copyright>SQLServer70.com</copyright><lastBuildDate>Sat, 04 Apr 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://www.sqlserver70.com/tags/sys.dm_exec_query_plan/index.xml" rel="self" type="application/rss+xml"/><item><title>SQL Server Top Queries by CPU and IO: dm_exec_query_stats</title><link>https://www.sqlserver70.com/post/sql-server-top-queries-by-cpu-and-io-sys-dm-exec-query-stats/</link><pubDate>Sat, 04 Apr 2026 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/sql-server-top-queries-by-cpu-and-io-sys-dm-exec-query-stats/</guid><description>
&lt;h2 id="find-the-top-cpu-and-io-consuming-queries-in-sql-server"&gt;Find the Top CPU and IO Consuming Queries in SQL Server&lt;/h2&gt;
&lt;p&gt;This script queries &lt;code&gt;sys.dm_exec_query_stats&lt;/code&gt; to identify the most resource-intensive queries currently cached in the plan cache, showing logical reads, writes, CPU time, and elapsed time — with the full query text and execution plan for each.&lt;/p&gt;
&lt;script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1012089347386563"
crossorigin="anonymous"&gt;&lt;/script&gt;
&lt;ins class="adsbygoogle"
style="display:inline-block;width:728px;height:90px"
data-ad-client="ca-pub-1012089347386563"
data-ad-slot="8593449130"&gt;&lt;/ins&gt;
&lt;script&gt;
(adsbygoogle = window.adsbygoogle || []).push({});
&lt;/script&gt;
&lt;h2 id="purpose-and-overview"&gt;Purpose and Overview&lt;/h2&gt;
&lt;p&gt;When a SQL Server instance is under CPU or I/O pressure, the first diagnostic step is finding which queries are responsible. &lt;code&gt;sys.dm_exec_query_stats&lt;/code&gt; holds cumulative execution statistics for every query plan currently in the plan cache. Sorted by total logical reads or total CPU time, it quickly surfaces the queries doing the most work. This script, adapted from the DBA-Scripts collection by Bulent Gucuk, combines &lt;code&gt;sys.dm_exec_query_stats&lt;/code&gt; with &lt;code&gt;sys.dm_exec_sql_text&lt;/code&gt; and &lt;code&gt;sys.dm_exec_query_plan&lt;/code&gt; to return the query text and execution plan alongside the performance metrics — giving you everything needed to begin tuning in a single result set.&lt;/p&gt;</description></item></channel></rss>