<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>SQL Server Performance on SQL Server Scripts</title><link>https://www.sqlserver70.com/series/sql-server-performance/</link><description>Recent content in SQL Server Performance on SQL Server Scripts</description><generator>Hugo -- gohugo.io</generator><language>en</language><copyright>SQLServer70.com</copyright><lastBuildDate>Fri, 15 May 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://www.sqlserver70.com/series/sql-server-performance/index.xml" rel="self" type="application/rss+xml"/><item><title>SQL Server Identify Heap Tables Without Clustered Indexes</title><link>https://www.sqlserver70.com/post/sql-server-identify-heap-tables-without-clustered-indexes/</link><pubDate>Fri, 15 May 2026 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/sql-server-identify-heap-tables-without-clustered-indexes/</guid><description>
&lt;p&gt;A heap table — a table with no clustered index — stores rows in no particular order, forces full table scans for most non-indexed queries, and accumulates forwarded records every time an UPDATE causes a row to outgrow its page. This script queries &lt;code&gt;sys.tables&lt;/code&gt;, &lt;code&gt;sys.indexes&lt;/code&gt;, &lt;code&gt;sys.partitions&lt;/code&gt;, &lt;code&gt;sys.allocation_units&lt;/code&gt;, and &lt;code&gt;sys.dm_db_index_physical_stats&lt;/code&gt; to identify every heap in the current database, report its size and row count, and surface forwarded record counts so DBAs can prioritize which heaps need a clustered index.&lt;/p&gt;</description></item><item><title>SQL Server CPU Utilization History Report</title><link>https://www.sqlserver70.com/post/sql-server-cpu-utilization-history-report/</link><pubDate>Fri, 17 Apr 2026 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/sql-server-cpu-utilization-history-report/</guid><description>
&lt;p&gt;SQL Server records CPU utilization data internally every minute and stores the last 256 readings in a ring buffer. This T-SQL script reads that buffer to produce a CPU history report showing SQL Server CPU usage, other process CPU usage, and total server CPU load — without requiring any external monitoring tool.&lt;/p&gt;
&lt;h2 id="purpose-and-overview"&gt;Purpose and Overview&lt;/h2&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;p&gt;When a CPU spike occurs on a SQL Server host, the first question is whether SQL Server caused it or whether another process did. The &lt;code&gt;sys.dm_os_ring_buffers&lt;/code&gt; DMV stores CPU statistics that SQL Server collects from the Windows performance counters every 60 seconds, retaining the last 256 minutes of data.&lt;/p&gt;</description></item><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><item><title>SQL Server Unused Indexes: sys.dm_db_index_usage_stats</title><link>https://www.sqlserver70.com/post/sql-server-unused-indexes-sys-dm-db-index-usage-stats/</link><pubDate>Wed, 01 Apr 2026 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/sql-server-unused-indexes-sys-dm-db-index-usage-stats/</guid><description>
&lt;h2 id="find-unused-nonclustered-indexes-in-sql-server"&gt;Find Unused Nonclustered Indexes in SQL Server&lt;/h2&gt;
&lt;p&gt;This script queries &lt;code&gt;sys.dm_db_index_usage_stats&lt;/code&gt; to identify nonclustered indexes that have never been used by any read operation since the last SQL Server restart, yet still carry write overhead with every INSERT, UPDATE, and DELETE on the table.&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;Every nonclustered index in SQL Server has a cost: each time a row is inserted, updated, or deleted in the base table, SQL Server must also update every nonclustered index on that table. If an index is never used by the query optimizer — no seeks, scans, or lookups — it is pure overhead with no benefit. Over time, databases accumulate these unused indexes through abandoned development, changed application query patterns, or indexes added by automated tools without follow-up review. This script, from the DBA-Scripts collection by Bulent Gucuk, reads &lt;code&gt;sys.dm_db_index_usage_stats&lt;/code&gt; to expose every nonclustered index with zero read activity since the last server restart, and generates the DROP INDEX statement for each one.&lt;/p&gt;</description></item><item><title>SQL Server Missing Indexes Report: dm_db_missing_index</title><link>https://www.sqlserver70.com/post/sql-server-missing-indexes-report-sys-dm-db-missing-index-details/</link><pubDate>Sat, 28 Feb 2026 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/sql-server-missing-indexes-report-sys-dm-db-missing-index-details/</guid><description>
&lt;p&gt;SQL Server tracks index recommendations automatically as queries execute, storing them in the missing index DMVs. This T-SQL script queries those views to produce a ranked report of missing indexes, ordered by the estimated improvement they would provide, along with a ready-to-run &lt;code&gt;CREATE INDEX&lt;/code&gt; statement for each recommendation.&lt;/p&gt;
&lt;h2 id="purpose-and-overview"&gt;Purpose and Overview&lt;/h2&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;p&gt;Every time SQL Server executes a query that would benefit from an index that does not exist, it records the recommendation in &lt;code&gt;sys.dm_db_missing_index_details&lt;/code&gt;. Over time these recommendations accumulate and can reveal the highest-impact indexing changes you can make to improve query performance.&lt;/p&gt;</description></item><item><title>SQL Server Wait Statistics Report: dm_os_wait_stats</title><link>https://www.sqlserver70.com/post/sql-server-wait-statistics-report-sys-dm-os-wait-stats/</link><pubDate>Fri, 27 Feb 2026 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/sql-server-wait-statistics-report-sys-dm-os-wait-stats/</guid><description>
&lt;p&gt;Wait statistics are one of the most reliable ways to identify performance bottlenecks in SQL Server. This T-SQL script queries &lt;code&gt;sys.dm_os_wait_stats&lt;/code&gt;, filters out background and idle wait types that do not indicate real problems, and ranks the remaining waits by their percentage of total wait time.&lt;/p&gt;
&lt;h2 id="purpose-and-overview"&gt;Purpose and Overview&lt;/h2&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;p&gt;Every time SQL Server cannot immediately process a request — because it is waiting for CPU, disk, memory, locks, or network — it records that wait in &lt;code&gt;sys.dm_os_wait_stats&lt;/code&gt;. Over time this DMV accumulates a comprehensive picture of where SQL Server spends time waiting.&lt;/p&gt;</description></item><item><title>SQL Server UPDATE STATISTICS and SELECT Dynamic Scripts</title><link>https://www.sqlserver70.com/post/sql-server-dynamic-update-statistics-and-select-scripts/</link><pubDate>Wed, 06 Aug 2025 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/sql-server-dynamic-update-statistics-and-select-scripts/</guid><description>
&lt;h2 id="sql-server-dynamic-update-statistics-and-select-scripts-for-database-maintenance"&gt;SQL Server Dynamic Update Statistics and Select Scripts for Database Maintenance&lt;/h2&gt;
&lt;h2 id="purpose"&gt;Purpose&lt;/h2&gt;
&lt;p&gt;These SQL Server scripts are designed to automatically generate database maintenance commands by dynamically creating UPDATE STATISTICS statements and SELECT queries for all user tables in a database. This approach is particularly useful for database administrators who need to perform bulk operations across multiple tables without manually writing individual commands for each table.
&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;/p&gt;</description></item></channel></rss>