<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>diskio | DBA von Nebenan</title>
	<atom:link href="https://dbavonnebenan.de/tag/diskio/feed/" rel="self" type="application/rss+xml" />
	<link>https://dbavonnebenan.de</link>
	<description>Sql Server, Performance &#38; PowerShell Automation</description>
	<lastBuildDate>Fri, 18 Jul 2025 05:26:47 +0000</lastBuildDate>
	<language>de</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://dbavonnebenan.de/wp-content/uploads/2025/04/cropped-www_logo-32x32.png</url>
	<title>diskio | DBA von Nebenan</title>
	<link>https://dbavonnebenan.de</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Measuring SQL Server Disk Latency Correctly – snapDiskLatency</title>
		<link>https://dbavonnebenan.de/sql-server-disk-latency-en/</link>
					<comments>https://dbavonnebenan.de/sql-server-disk-latency-en/#respond</comments>
		
		<dc:creator><![CDATA[Gabriel]]></dc:creator>
		<pubDate>Thu, 17 Jul 2025 14:21:36 +0000</pubDate>
				<category><![CDATA[Sql Server]]></category>
		<category><![CDATA[TSql]]></category>
		<category><![CDATA[diskio]]></category>
		<category><![CDATA[DISKSPD]]></category>
		<category><![CDATA[eng]]></category>
		<category><![CDATA[latency]]></category>
		<category><![CDATA[PERFORMANCE]]></category>
		<guid isPermaLink="false">https://dbavonnebenan.de/?p=579</guid>

					<description><![CDATA[<p>How to get correct SQL Server Disk Latency values instead of falsified DMV data. Open Source snapDiskLatency solution for long-term analysis.</p>
<p>The post <a href="https://dbavonnebenan.de/sql-server-disk-latency-en/">Measuring SQL Server Disk Latency Correctly – snapDiskLatency</a> first appeared on <a href="https://dbavonnebenan.de">DBA von Nebenan</a>.</p>]]></description>
										<content:encoded><![CDATA[<div style="border: 1px dotted #eb2b14; border-radius: 0%; background-color: #eeeeee; padding-top: var(--wp--preset--spacing--30); padding-left: var(--wp--preset--spacing--30); padding-right: var(--wp--preset--spacing--30); padding-bottom: var(--wp--preset--spacing--30); " class="ub-styled-box ub-bordered-box wp-block-ub-styled-box" id="ub-styled-box-ed9a98aa-0cd4-41e3-8f7e-56d29b672df9">
<p class="has-open-sauce-sans-font-family" style="margin-top:0;margin-right:0;margin-bottom:0;margin-left:0" id="ub-styled-box-bordered-content-">What&#8217;s available here?</p>



<ul style="margin-top:0;margin-right:0;margin-bottom:0;margin-left:0" class="wp-block-list has-open-sauce-sans-font-family">
<li><a href="#DISKSPD" title="">DISKSPD Templates and Wrapper</a></li>



<li><a href="#sqlfilestats" title="">How can I display the latencies of individual database files?</a></li>



<li><a href="#snapdisk" title="">Long-term analysis of latencies with snapDiskLatency</a></li>
</ul>


</div>


<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>


https://github.com/gabrielkoehl/DBAScriptBox


<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading" style="margin-top:var(--wp--preset--spacing--50);margin-bottom:var(--wp--preset--spacing--50)">Intro</h2>



<p>Currently, I&#8217;m involved in a code review at a client. We&#8217;re examining not only the application but also all interfaces. This naturally includes the SQL Server landscape, which I set up at the beginning of the year.</p>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:85%">
<p class="has-open-sauce-sans-font-family">The result was more findings in my direction than expected, and I immediately felt challenged. I was able to refute most of it, some topics were the client&#8217;s responsibility, and one topic caught my interest purely out of curiosity.</p>



<p class="has-text-align-center" style="margin-top:var(--wp--preset--spacing--50);margin-bottom:var(--wp--preset--spacing--50)"><strong>Read- and Write Latencies of TempDB</strong> ( and every other DB )</p>
</div>



<div class="wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:15%">
<figure class="wp-block-image aligncenter size-full is-resized"><img fetchpriority="high" decoding="async" width="264" height="329" src="https://dbavonnebenan.de/wp-content/uploads/2025/06/emote-4.png" alt="" class="wp-image-516" style="width:131px;height:auto" srcset="https://dbavonnebenan.de/wp-content/uploads/2025/06/emote-4.png 264w, https://dbavonnebenan.de/wp-content/uploads/2025/06/emote-4-241x300.png 241w" sizes="(max-width: 264px) 100vw, 264px" /></figure>
</div>
</div>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading" style="margin-top:var(--wp--preset--spacing--50);margin-bottom:var(--wp--preset--spacing--50)">Background</h2>



<p>The client doesn&#8217;t operate their own data center, so they&#8217;re dependent on the hoster, who unfortunately isn&#8217;t very communicative. Therefore, I had to get a picture of the totally overcommitted hardware through various other means and challenge the hoster. This was also the reason why I was quite precisely informed about what the hoster&#8217;s hosts and storage systems were capable of delivering.</p>



<p>That&#8217;s why I was very surprised that 32ms Write Latency was listed as a finding. No question, that&#8217;s a bad value for AllFlash NVMe, but it just stood there in the report without differentiation or deeper analysis. Just the statement &#8222;bad storage.&#8220; So I unpacked my tools, took another look at it, and also developed a new solution that I want to share with you.</p>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading" id="DISKSPD" style="margin-top:var(--wp--preset--spacing--50);margin-bottom:0">DISKSPD</h2>



<p style="margin-bottom:var(--wp--preset--spacing--50)"><em><strong>Repo</strong>: perf_diskspeed/DISKSPD</em><br><strong><em>Microsoft</em>:</strong> <a href="https://github.com/microsoft/diskspd" target="_blank" rel="noopener" title="">https://github.com/microsoft/diskspd</a></p>



<p>With DISKSPD, you should always start on unknown systems; often a large portion of problems is hidden here. At this client, for example, a DB with high workload was running on spindles, with latencies in the .2 percentile of 15 seconds latency, plus 14MB throughput. I don&#8217;t need to worry about indexes etc. anymore.</p>



<p>To quickly get results, I built a wrapper for DISKSPD that always executes 3 standard tests:</p>



<ul class="wp-block-list">
<li>SQL Server Workload</li>



<li>Random 64KB Workload</li>



<li>Sequential 64KB Workload</li>
</ul>



<p>The files are stored separately in the _Output subfolder and thus provide quite good hints about storage problems. Now these were, as expected, great values that correspond to NVMe storage. So let&#8217;s continue to SQL Server and see what it tells us. welche NVMe Storage entsprechen. Also weiter zu Sql Server und wir schauen mal was uns dieser so sagt.</p>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading" id="sqlfilestats" style="margin-top:var(--wp--preset--spacing--50);margin-bottom:var(--wp--preset--spacing--50)">sys.dm_io_virtual_file_stats</h2>



<p>SQL Server provides a view where all file metrics are cleanly listed.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: sql; title: ; notranslate">
select * from sys.dm_io_virtual_file_stats(null,null)
</pre></div>


<ul class="wp-block-list">
<li><a href="https://learn.microsoft.com/en-us/sql/relational-databases/system-dynamic-management-views/sys-dm-io-virtual-file-stats-transact-sql?view=sql-server-ver17">Microsoft Learn</a></li>
</ul>



<figure class="wp-block-image size-full" style="margin-top:var(--wp--preset--spacing--50);margin-bottom:var(--wp--preset--spacing--50)"><img decoding="async" width="1117" height="458" src="https://dbavonnebenan.de/wp-content/uploads/2025/07/disklat_dmv.png" alt="sys.dm_io_virtual_file_stats" class="wp-image-569" srcset="https://dbavonnebenan.de/wp-content/uploads/2025/07/disklat_dmv.png 1117w, https://dbavonnebenan.de/wp-content/uploads/2025/07/disklat_dmv-300x123.png 300w, https://dbavonnebenan.de/wp-content/uploads/2025/07/disklat_dmv-1024x420.png 1024w, https://dbavonnebenan.de/wp-content/uploads/2025/07/disklat_dmv-768x315.png 768w" sizes="(max-width: 1117px) 100vw, 1117px" /></figure>



<p>Based on this, I built an analysis script that gives me more info and I can also draw further conclusions like ReadWrite Ratio, probable IOPS based on the number of operations, and also quantities. This allows you to build storage systems quite well for specific workloads.</p>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:80%">
<p>And this value also showed me 32ms Write Latency of the TempDB. Then I started wondering, how does this value even arise?</p>
</div>



<div class="wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:20%">
<figure class="wp-block-image aligncenter size-full is-resized"><img decoding="async" width="261" height="323" src="https://dbavonnebenan.de/wp-content/uploads/2025/07/emotes_question.png" alt="Question" class="wp-image-575" style="width:125px;height:auto" srcset="https://dbavonnebenan.de/wp-content/uploads/2025/07/emotes_question.png 261w, https://dbavonnebenan.de/wp-content/uploads/2025/07/emotes_question-242x300.png 242w" sizes="(max-width: 261px) 100vw, 261px" /></figure>
</div>
</div>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading" style="margin-top:var(--wp--preset--spacing--50);margin-bottom:var(--wp--preset--spacing--50)">Basic Calculation</h3>



<p>SQL Server measures I/O latency through simple division of cumulative wait times by the number of operations:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: sql; title: ; notranslate">
-- Read Latency in ms
io_stall_read_ms / num_of_reads = durchschnittliche Read-Latenz

-- Write Latency in ms  
io_stall_write_ms / num_of_writes = durchschnittliche Write-Latenz
</pre></div>


<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<p>That&#8217;s it!!! And now it should be clear that the point-in-time use of this DMV is not really meaningful, on the contrary. The values can, as with the review company that specializes in such processes, lead to false conclusions and action recommendations. Scary.</p>



<p>If the storage system had a hard hiccup since the start of SQL Server, the metrics are contaminated. According to my research, you can&#8217;t flush these, only by taking the DB offline, which I usually avoid in productive environments.</p>



<p>After a few more rounds in my head, the solution came quite quickly. These are all snapshot values, I just need the delta between two values and I have real values. And I can also put the whole thing in a time series and have a long-term analysis. Mindblowing <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f61d.png" alt="😝" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>



<p>Google also quickly showed corresponding solutions that I used as a base idea. Thanks to Paul Randal ( <a href="https://www.sqlskills.com/blogs/paul/capturing-io-latencies-period-time/" target="_blank" rel="noopener" title="">sqlskills.com</a> )</p>



<p>For analyzing a complete week, this is also not suitable. So I extended the whole thing to a long-term analysis with persistent table.</p>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading" id="snapdisk" style="margin-top:var(--wp--preset--spacing--50);margin-bottom:0">The Solution &#8211;&gt; snapDiskLatency</h2>



<p><em><strong>Repo</strong>: </em>perf_diskspeed/snapDiskLatency</p>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading" style="margin-top:var(--wp--preset--spacing--50);margin-bottom:var(--wp--preset--spacing--50)">What does snapDiskLatency do?</h3>



<p>The problem is well-known &#8211; the standard DMV <code>sys.dm_io_virtual_file_stats</code> shows cumulative values since SQL Server startup. One single storage hiccup weeks ago and the latency values are no longer representative.</p>



<p>This solves the problem with two simple stored procedures:</p>



<p>The first collects the raw data from the DMV hourly and writes it to a permanent table. Why hourly? Shorter intervals lead to unreliable delta calculations &#8211; too little I/O between snapshots makes the values inaccurate. However, this can be individually adjusted since the agent triggers the procedure.</p>



<figure class="wp-block-image size-full" style="margin-top:var(--wp--preset--spacing--50);margin-bottom:var(--wp--preset--spacing--50)"><img loading="lazy" decoding="async" width="1360" height="382" src="https://dbavonnebenan.de/wp-content/uploads/2025/07/disklat_raw.png" alt="snapDiskLatency collect" class="wp-image-567" srcset="https://dbavonnebenan.de/wp-content/uploads/2025/07/disklat_raw.png 1360w, https://dbavonnebenan.de/wp-content/uploads/2025/07/disklat_raw-300x84.png 300w, https://dbavonnebenan.de/wp-content/uploads/2025/07/disklat_raw-1024x288.png 1024w, https://dbavonnebenan.de/wp-content/uploads/2025/07/disklat_raw-768x216.png 768w" sizes="auto, (max-width: 1360px) 100vw, 1360px" /></figure>



<p>The second does the delta calculations between snapshots and creates the result. Thus, real latency values are generated for defined time periods, without historical hiccups, which can then be compared with other metrics.</p>



<figure class="wp-block-image size-full" style="margin-top:var(--wp--preset--spacing--50);margin-bottom:var(--wp--preset--spacing--50)"><img loading="lazy" decoding="async" width="1298" height="326" src="https://dbavonnebenan.de/wp-content/uploads/2025/07/disklat_report-2.png" alt="snapDiskLatency report" class="wp-image-571" srcset="https://dbavonnebenan.de/wp-content/uploads/2025/07/disklat_report-2.png 1298w, https://dbavonnebenan.de/wp-content/uploads/2025/07/disklat_report-2-300x75.png 300w, https://dbavonnebenan.de/wp-content/uploads/2025/07/disklat_report-2-1024x257.png 1024w, https://dbavonnebenan.de/wp-content/uploads/2025/07/disklat_report-2-768x193.png 768w" sizes="auto, (max-width: 1298px) 100vw, 1298px" /></figure>



<p>Here we see, for example, in the <a href="https://dbavonnebenan.de/sql-server-truncate-vs-delete-dml-or-ddl-en/" title="TRUNCATE TABLE – DDL vs DML – deep dive in operations and practical tips">TRUNCATE TABLE</a> an outlier (NVMe is also underlying here). On the LAB system there&#8217;s no load, DOXIS is just a table with 2 columns and was artificially worked with workload.<br></p>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading" style="margin-top:var(--wp--preset--spacing--50);margin-bottom:var(--wp--preset--spacing--50)"><strong>The Result</strong></h3>



<p>Instead of possibly contaminated values:</p>



<ul class="wp-block-list">
<li>Average latencies per interval</li>



<li>Read/Write ratios</li>



<li>Breakdown by database and file type</li>
</ul>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading" style="margin-top:var(--wp--preset--spacing--50);margin-bottom:var(--wp--preset--spacing--50)"><strong>Setup</strong></h3>



<p>Create Agent Job, run hourly, done. The complete instructions are in the README, copy &amp; paste &amp; enjoy</p>



<figure class="wp-block-image aligncenter size-full is-resized"><img loading="lazy" decoding="async" width="246" height="470" src="https://dbavonnebenan.de/wp-content/uploads/2025/05/emotes_standing_1.png" alt="happy" class="wp-image-330" style="width:125px;height:auto" srcset="https://dbavonnebenan.de/wp-content/uploads/2025/05/emotes_standing_1.png 246w, https://dbavonnebenan.de/wp-content/uploads/2025/05/emotes_standing_1-157x300.png 157w" sizes="auto, (max-width: 246px) 100vw, 246px" /></figure>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading" style="margin-top:var(--wp--preset--spacing--50);margin-bottom:var(--wp--preset--spacing--50)">Diagrams</h2>



<p>Since every good proprietary database monitoring tool does this and presents it graphically, I want to at least show one possibility in Excel in the result. For this, the result of the DataSource or Copy must be pivoted and you can easily recognize your daily peaks.</p>



<figure class="wp-block-image size-full" style="margin-top:var(--wp--preset--spacing--50);margin-bottom:var(--wp--preset--spacing--50)"><img loading="lazy" decoding="async" width="1617" height="604" src="https://dbavonnebenan.de/wp-content/uploads/2025/07/disklat_graph.png" alt="" class="wp-image-572" srcset="https://dbavonnebenan.de/wp-content/uploads/2025/07/disklat_graph.png 1617w, https://dbavonnebenan.de/wp-content/uploads/2025/07/disklat_graph-300x112.png 300w, https://dbavonnebenan.de/wp-content/uploads/2025/07/disklat_graph-1024x382.png 1024w, https://dbavonnebenan.de/wp-content/uploads/2025/07/disklat_graph-768x287.png 768w, https://dbavonnebenan.de/wp-content/uploads/2025/07/disklat_graph-1536x574.png 1536w" sizes="auto, (max-width: 1617px) 100vw, 1617px" /></figure><p>The post <a href="https://dbavonnebenan.de/sql-server-disk-latency-en/">Measuring SQL Server Disk Latency Correctly – snapDiskLatency</a> first appeared on <a href="https://dbavonnebenan.de">DBA von Nebenan</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://dbavonnebenan.de/sql-server-disk-latency-en/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>SQL Server Disk Latency richtig messen &#8211; snapDiskLatency</title>
		<link>https://dbavonnebenan.de/sql-server-disk-latency-de/</link>
					<comments>https://dbavonnebenan.de/sql-server-disk-latency-de/#respond</comments>
		
		<dc:creator><![CDATA[Gabriel]]></dc:creator>
		<pubDate>Thu, 17 Jul 2025 14:06:35 +0000</pubDate>
				<category><![CDATA[Sql Server]]></category>
		<category><![CDATA[TSql]]></category>
		<category><![CDATA[DE]]></category>
		<category><![CDATA[diskio]]></category>
		<category><![CDATA[DISKSPD]]></category>
		<category><![CDATA[latency]]></category>
		<category><![CDATA[PERFORMANCE]]></category>
		<guid isPermaLink="false">https://dbavonnebenan.de/?p=563</guid>

					<description><![CDATA[<p>Wie du richtige SQL Server Disk Latency Werte erhältst statt verfälschter DMV-Daten. Open Source snapDiskLatency Lösung für Langzeitanalyse.</p>
<p>The post <a href="https://dbavonnebenan.de/sql-server-disk-latency-de/">SQL Server Disk Latency richtig messen – snapDiskLatency</a> first appeared on <a href="https://dbavonnebenan.de">DBA von Nebenan</a>.</p>]]></description>
										<content:encoded><![CDATA[<div style="border: 1px dotted #eb2b14; border-radius: 0%; background-color: #eeeeee; padding-top: var(--wp--preset--spacing--30); padding-left: var(--wp--preset--spacing--30); padding-right: var(--wp--preset--spacing--30); padding-bottom: var(--wp--preset--spacing--30); " class="ub-styled-box ub-bordered-box wp-block-ub-styled-box" id="ub-styled-box-ba0a6049-a2c1-44fc-b531-47f63f78c8b4">
<p style="margin-top:0;margin-right:0;margin-bottom:0;margin-left:0" id="ub-styled-box-bordered-content-">Was erwartet dich hier?</p>



<ul style="margin-top:0;margin-right:0;margin-bottom:0;margin-left:0" class="wp-block-list">
<li><a href="#DISKSPD" title="DISKSPD Templates und Wrapper">DISKSPD Templates und Wrapper</a></li>



<li><a href="#sqlfilestats" title="">Wie kann ich die Latenzen der einzelnen Datenbank Files anzeigen lassen?</a></li>



<li><a href="#snapdisk" title="Langzeit Analyse der Latenzen!!!">Langzeit Analyse der Latenzen!!!</a></li>
</ul>


</div>


<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>


https://github.com/gabrielkoehl/DBAScriptBox


<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading" style="margin-top:var(--wp--preset--spacing--50);margin-bottom:var(--wp--preset--spacing--50)">Intro</h2>



<p>Aktuell bin ich bei einem Kunden an einem Code Review beteiligt. Dabei beleuchten wir neben der Applikation auch alle Schnittstellen.. Dazu gehört natürlich auch die Sql Server Landschaft, welche ich Anfang des Jahres aufgesetzt habe.</p>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:85%">
<p>Das Ergebnis waren doch mehr Findings in meine Richtung als erwartet und ich fühlte mich sofort gechallenged. Das Meiste konnte ich widerlegen, bei einigen Themen war der Kunde in der Pflicht und ein Thema hat mich rein interessenhalber gepackt.</p>



<p class="has-text-align-center" style="margin-top:var(--wp--preset--spacing--50);margin-bottom:var(--wp--preset--spacing--50)"><strong>Read- und Write Latenzen der TempDB</strong> ( und jeder anderen DB )</p>
</div>



<div class="wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:15%">
<figure class="wp-block-image aligncenter size-full is-resized"><img loading="lazy" decoding="async" width="264" height="329" src="https://dbavonnebenan.de/wp-content/uploads/2025/06/emote-4.png" alt="" class="wp-image-516" style="width:131px;height:auto" srcset="https://dbavonnebenan.de/wp-content/uploads/2025/06/emote-4.png 264w, https://dbavonnebenan.de/wp-content/uploads/2025/06/emote-4-241x300.png 241w" sizes="auto, (max-width: 264px) 100vw, 264px" /></figure>
</div>
</div>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading" style="margin-top:var(--wp--preset--spacing--50);margin-bottom:var(--wp--preset--spacing--50)">Vorgeschichte</h2>



<p>Der Kunde betreibt kein eigenes Rechenzentrum, ist somit vom Hoster abhängig, welcher leider nicht sehr kommunikativ ist. Somit musste ich mir auf diverse andere Wege ein Bild von der total overcommitteten Hardware machen und den Hoster Challengen. Dies war auch der Grund, warum ich ziemlich genau im Bilde war, was die Hosts und Storage Systeme des Hosters im Stande waren zu leisten.</p>



<p>Deshalb hat es mich doch sehr gewundert, dass als Finding 32ms Write Latency aufgeführt waren. Keine Frage, das ist ein schlechter Wert für AllFlash NVMe aber der stand da einfach so im Report, ohne Differenzierung oder tiefere Analysen. Nur die Aussage schlechter Storage. Also habe ich meine Werkzeuge ausgepackt, mir das noch mal angeschaut und auch eine neue Lösung entwickelt, die ich mit euch teilen möchte.</p>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading" id="DISKSPD" style="margin-top:var(--wp--preset--spacing--50);margin-bottom:0">DISKSPD</h2>



<p style="margin-bottom:var(--wp--preset--spacing--50)"><em><strong>Repo</strong>: perf_diskspeed/DISKSPD</em><br><strong><em>Microsoft</em>:</strong> <a href="https://github.com/microsoft/diskspd">https://github.com/microsoft/diskspd</a></p>



<p>Mit DISKSPD sollte man auf unbekannten Systemen immer anfangen, oft liegt hier schon ein großer Anteil an Problemen versteckt. Bei diesem Kudnen lief zum Beispiel eine DB mit hohem Workload auf Spindeln, mit Latenzen in der .2 Perzentile mit 15 Sekunden Latenz, dazu 14MB Durchsatz. Da brauche ich mir um Indexe usw. keine Gedanken mehr machen.</p>



<p>Um schnell an Ergebnisse zu kommen, habe ich mir einen Wrapper für DISKSP gebaut, welcher immer 3 Standardtests ausführt</p>



<ul class="wp-block-list">
<li>Sql Server Workload</li>



<li>Random 64KB Workload</li>



<li>Sequenziell 64KB Workload</li>
</ul>



<p>Die Dateien werden separat im Unterordner _Output gespeichert und ermöglichen somit recht gute Hinweise auf Storage-Probleme. Nun waren das wie erwartet super Werte, welche NVMe Storage entsprechen. Also weiter zu Sql Server und wir schauen mal was uns dieser so sagt.</p>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading" id="sqlfilestats" style="margin-top:var(--wp--preset--spacing--50);margin-bottom:var(--wp--preset--spacing--50)">sys.dm_io_virtual_file_stats</h2>



<p>Sql Server bietet eine View, in der alle Metriken der Files sauber aufgelistet werden.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: sql; title: ; notranslate">
select * from sys.dm_io_virtual_file_stats(null,null)
</pre></div>


<ul class="wp-block-list">
<li><a href="https://learn.microsoft.com/en-us/sql/relational-databases/system-dynamic-management-views/sys-dm-io-virtual-file-stats-transact-sql?view=sql-server-ver17" target="_blank" rel="noopener" title="">microsoft.com</a></li>
</ul>



<figure class="wp-block-image size-full" style="margin-top:var(--wp--preset--spacing--50);margin-bottom:var(--wp--preset--spacing--50)"><img loading="lazy" decoding="async" width="1117" height="458" src="https://dbavonnebenan.de/wp-content/uploads/2025/07/disklat_dmv.png" alt="sys.dm_io_virtual_file_stats" class="wp-image-569" srcset="https://dbavonnebenan.de/wp-content/uploads/2025/07/disklat_dmv.png 1117w, https://dbavonnebenan.de/wp-content/uploads/2025/07/disklat_dmv-300x123.png 300w, https://dbavonnebenan.de/wp-content/uploads/2025/07/disklat_dmv-1024x420.png 1024w, https://dbavonnebenan.de/wp-content/uploads/2025/07/disklat_dmv-768x315.png 768w" sizes="auto, (max-width: 1117px) 100vw, 1117px" /></figure>



<p>Darauf basierend habe ich ein Analyse Script gebaut, welches mir mehr Infos gibt und ich auch weitere Rückschlüsse wie ReadWrite Ratio, wahrscheinliche IOPS auf Basis der Anzahl der Vorgänge und auch Mengen. Damit kann man schon ganz gut Storage Systeme zu speziellen Workloads aufbauen.</p>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:80%">
<p>Und auch dieser Wert hat mir 32ms Write Latency der TempDB angezeigt. Dann habe ich angefangen mich zu fragen, wie entstehet dieser Wert überhaupt? </p>
</div>



<div class="wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:20%">
<figure class="wp-block-image aligncenter size-full is-resized"><img loading="lazy" decoding="async" width="261" height="323" src="https://dbavonnebenan.de/wp-content/uploads/2025/07/emotes_question.png" alt="Question" class="wp-image-575" style="width:125px;height:auto" srcset="https://dbavonnebenan.de/wp-content/uploads/2025/07/emotes_question.png 261w, https://dbavonnebenan.de/wp-content/uploads/2025/07/emotes_question-242x300.png 242w" sizes="auto, (max-width: 261px) 100vw, 261px" /></figure>
</div>
</div>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading" style="margin-top:var(--wp--preset--spacing--50);margin-bottom:var(--wp--preset--spacing--50)">Grundlegende Berechnung der Werte</h3>



<p>SQL Server misst I/O-Latenz durch einfache Division der kumulativen Wartezeiten durch die Anzahl der Operationen:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: sql; title: ; notranslate">
-- Read Latency in ms
io_stall_read_ms / num_of_reads = durchschnittliche Read-Latenz

-- Write Latency in ms  
io_stall_write_ms / num_of_writes = durchschnittliche Write-Latenz
</pre></div>


<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<p>Thats it!!! Und nun sollte klar sein, dass die punktuelle Nutzung dieser DMV nicht wirklich aussagekräftig ist, im Gegenteil. Die Werte können wie bei dem Review Unternehmen, was sich auf solche Prozesse spezialisiert hat, zu falschen Rückschlüssen und Handlungsempfehlungen führen. Gruselig.</p>



<p>Wenn das Storagesystem seit dem Start von Sql Server mal hart Schluckauf hatte, sind die Metriken verunreiningt. Laut meinen Recherchen kann man diese nicht flushen, nur durch das Offline nehmen der DB, was ich üblicherweise in produktiven Umgebungen vermeide.</p>



<p>Nach ein paar weiteren Runden in meinem Kopf kam recht schnell die Lösung. Das sind alles SnapShot Values, ich brauche ja nur das Delta zwischen zwei Werten und schon habe ich reale Werte. Und das Ganze kann ich auch noch in eine Zeitreihe packen und habe eine Langzeitanalyse.  Mindblowing <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f61d.png" alt="😝" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>



<p>Google hat auch schnell entsprechende Lösungen aufgezeigt, die ich als Basis Idee genutzt habe. Danke an Paul Randal ( <a href="https://www.sqlskills.com/blogs/paul/capturing-io-latencies-period-time/">sqlskills.com</a> )</p>



<p>Für die Analyse einer kompletten Woche ist dies aber auch nicht geeignet. Somit habe ich das Ganze auf eine Langzeitanalyse mit persistenten Table erweitert.</p>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading" id="snapdisk" style="margin-top:var(--wp--preset--spacing--50);margin-bottom:0">Die Lösung &#8211;&gt; snapDiskLatency</h2>



<p><em><strong>Repo</strong>: </em>perf_diskspeed/snapDiskLatency</p>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading" style="margin-top:var(--wp--preset--spacing--50);margin-bottom:var(--wp--preset--spacing--50)">Was macht snapDiskLatency?</h3>



<p>Das Problem ist bekannt &#8211; die Standard-DMV <code>sys.dm_io_virtual_file_stats</code> zeigt kumulative Werte seit dem SQL Server Start. Ein einziger Storage-Schluckauf vor Wochen und die Latenzwerte sind nicht mehr repräsentativ. </p>



<p><strong>snapDiskLatency</strong> löst das Problem mit zwei simplen Stored Procedures:</p>



<p>Die Erste sammelt stündlich die Rohdaten aus der DMV und schreibt sie in einen permanenten Table. Warum stündlich? Kürzere Intervalle führen zu unzuverlässigen Delta-Berechnungen &#8211; zu wenig I/O zwischen den Snapshots macht die Werte ungenau. Dies kann aber individuell angepasst werden, da der Agent die Prozedur triggert.</p>



<figure class="wp-block-image size-full" style="margin-top:var(--wp--preset--spacing--50);margin-bottom:var(--wp--preset--spacing--50)"><img loading="lazy" decoding="async" width="1360" height="382" src="https://dbavonnebenan.de/wp-content/uploads/2025/07/disklat_raw.png" alt="snapDiskLatency collect" class="wp-image-567" srcset="https://dbavonnebenan.de/wp-content/uploads/2025/07/disklat_raw.png 1360w, https://dbavonnebenan.de/wp-content/uploads/2025/07/disklat_raw-300x84.png 300w, https://dbavonnebenan.de/wp-content/uploads/2025/07/disklat_raw-1024x288.png 1024w, https://dbavonnebenan.de/wp-content/uploads/2025/07/disklat_raw-768x216.png 768w" sizes="auto, (max-width: 1360px) 100vw, 1360px" /></figure>



<p>Die Zweite macht die Delta-Berechnungen zwischen den Snapshots und erstellt das Resultset. Somit werden reale Latenzwerte für definierte Zeiträume erzeugt, ohne historischen Schluckauf, welche dann mit anderen Metriken abgeglichen werden können.</p>



<figure class="wp-block-image size-full" style="margin-top:var(--wp--preset--spacing--50);margin-bottom:var(--wp--preset--spacing--50)"><img loading="lazy" decoding="async" width="1298" height="326" src="https://dbavonnebenan.de/wp-content/uploads/2025/07/disklat_report-2.png" alt="snapDiskLatency report" class="wp-image-571" srcset="https://dbavonnebenan.de/wp-content/uploads/2025/07/disklat_report-2.png 1298w, https://dbavonnebenan.de/wp-content/uploads/2025/07/disklat_report-2-300x75.png 300w, https://dbavonnebenan.de/wp-content/uploads/2025/07/disklat_report-2-1024x257.png 1024w, https://dbavonnebenan.de/wp-content/uploads/2025/07/disklat_report-2-768x193.png 768w" sizes="auto, (max-width: 1298px) 100vw, 1298px" /></figure>



<p>Hier sehen wir zum Beispiel im <a href="https://dbavonnebenan.de/sql-server-truncate-vs-delete-dml-or-ddl-de/" title="TRUNCATE TABLE Operationen im Detail – ROLLBACK ist doch möglich">TRUNCATE Table</a> einen Aureißer ( hier liegt auch NVMe drunter ). Auf dem LAB System ist keine Last, DOXIS ist nur ein Table mit 2 Spalten und wurde künstlich mit Workload bearbeitet.</p>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading" style="margin-top:var(--wp--preset--spacing--50);margin-bottom:var(--wp--preset--spacing--50)"><strong>Das Ergebnis</strong></h3>



<p>Statt möglicherweise verunreinigten Werten</p>



<ul class="wp-block-list">
<li>Durchschnittliche Latenzen pro Intervall</li>



<li>Read/Write-Verhältnisse</li>



<li>Aufschlüsselung nach Datenbank und File-Type</li>
</ul>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading" style="margin-top:var(--wp--preset--spacing--50);margin-bottom:var(--wp--preset--spacing--50)"><strong>Setup</strong></h3>



<p>Agent Job erstellen, stündlich laufen lassen, fertig. Die komplette Anleitung steht in der README, copy &amp; paste &amp; freuen</p>



<figure class="wp-block-image aligncenter size-full is-resized"><img loading="lazy" decoding="async" width="246" height="470" src="https://dbavonnebenan.de/wp-content/uploads/2025/05/emotes_standing_1.png" alt="happy" class="wp-image-330" style="width:125px;height:auto" srcset="https://dbavonnebenan.de/wp-content/uploads/2025/05/emotes_standing_1.png 246w, https://dbavonnebenan.de/wp-content/uploads/2025/05/emotes_standing_1-157x300.png 157w" sizes="auto, (max-width: 246px) 100vw, 246px" /></figure>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading" style="margin-top:var(--wp--preset--spacing--50);margin-bottom:var(--wp--preset--spacing--50)">Diagramme</h2>



<p>Da dies auch jedes gute propritäre DatabaseMonitoringTool macht und hübsch grafisch darstellt, will ich zumindest eine Möglichkeit in Excel im Ergebnis zeigen. Dazu muss das Ergebnis der DataSource oder Copy pivotiert werden und schon kann man gut seine Daily Peaks erkennen.</p>



<figure class="wp-block-image size-full" style="margin-top:var(--wp--preset--spacing--50);margin-bottom:var(--wp--preset--spacing--50)"><img loading="lazy" decoding="async" width="1617" height="604" src="https://dbavonnebenan.de/wp-content/uploads/2025/07/disklat_graph.png" alt="" class="wp-image-572" srcset="https://dbavonnebenan.de/wp-content/uploads/2025/07/disklat_graph.png 1617w, https://dbavonnebenan.de/wp-content/uploads/2025/07/disklat_graph-300x112.png 300w, https://dbavonnebenan.de/wp-content/uploads/2025/07/disklat_graph-1024x382.png 1024w, https://dbavonnebenan.de/wp-content/uploads/2025/07/disklat_graph-768x287.png 768w, https://dbavonnebenan.de/wp-content/uploads/2025/07/disklat_graph-1536x574.png 1536w" sizes="auto, (max-width: 1617px) 100vw, 1617px" /></figure><p>The post <a href="https://dbavonnebenan.de/sql-server-disk-latency-de/">SQL Server Disk Latency richtig messen – snapDiskLatency</a> first appeared on <a href="https://dbavonnebenan.de">DBA von Nebenan</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://dbavonnebenan.de/sql-server-disk-latency-de/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
