{"id":55,"date":"2010-02-09T22:23:44","date_gmt":"2010-02-09T22:23:44","guid":{"rendered":"http:\/\/jcrawfor74.wordpress.com\/?p=55"},"modified":"2026-03-09T09:09:20","modified_gmt":"2026-03-08T22:09:20","slug":"sql-server-performance-testing","status":"publish","type":"post","link":"https:\/\/ntsblog.homedev.com.au\/index.php\/2010\/02\/09\/sql-server-performance-testing\/","title":{"rendered":"SQL Server Performance Testing"},"content":{"rendered":"<div id=\"ntsbl-1029593095\" class=\"ntsbl-before-content ntsbl-entity-placement\"><script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js?client=ca-pub-6288941070289539\" crossorigin=\"anonymous\"><\/script><ins class=\"adsbygoogle\" style=\"display:inline-block;width:728px;height:90px;\" \ndata-ad-client=\"ca-pub-6288941070289539\" \ndata-ad-slot=\"9356781486\"><\/ins> \n<script> \n(adsbygoogle = window.adsbygoogle || []).push({}); \n<\/script>\n<\/div>\n<p>When attempting to assess the performance of a given script on SQL Server it is quite difficult.<\/p>\n\n\n\n<p>The caching of execution plans etc etc, lead to the script taking 20 seconds on the first pass, 10 on the next and settles in to only taking 2 seconds.<\/p>\n\n\n\n<p>This makes it hard to compare apples with apples.<\/p>\n\n\n\n<p>I have found that running the following improves the consistency of the reporting timings, according to books online<\/p>\n\n\n\n<p>&#8220;Use DBCC DROPCLEANBUFFERS to test queries with a cold buffer cache without shutting down and restarting the server.&#8221;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">CHECKPOINT\nGO\nDBCC DROPCLEANBUFFERS\nGO<\/code><\/pre>\n\n\n\n<p>It runs each script with a &#8220;Cold buffer cache&#8221; and gives you a consistent starting point for comparing queries and gives you a more realistic time frame for your SQL execution.<\/p>\n\n\n\n<p>Also helpful when attempting to time your query execution time:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\"><code>set statistics time ON<\/code><\/code><\/pre>\n\n\n\n<p>And to further analyse poorly running queries<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\"><code>set statistics IO ON<\/code><\/code><\/pre>\n\n\n\n<p>With IO statistics on you can see the results of physical disk activity. For example previously I used this to see that on a particular query when I changed one small part of the query it caused the execution plan to change drastically and the disk IO went from doing a few thousand reads on a very large table to a couple of million reads, which blew out the performance of the query.<\/p>\n\n\n\n<p>Hope this is useful<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When attempting to assess the performance of a given script on SQL Server it is quite difficult. The caching of execution plans etc etc, lead [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[13],"tags":[],"class_list":["post-55","post","type-post","status-publish","format-standard","hentry","category-sql-server"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/ntsblog.homedev.com.au\/index.php\/wp-json\/wp\/v2\/posts\/55","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ntsblog.homedev.com.au\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ntsblog.homedev.com.au\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ntsblog.homedev.com.au\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ntsblog.homedev.com.au\/index.php\/wp-json\/wp\/v2\/comments?post=55"}],"version-history":[{"count":1,"href":"https:\/\/ntsblog.homedev.com.au\/index.php\/wp-json\/wp\/v2\/posts\/55\/revisions"}],"predecessor-version":[{"id":2179,"href":"https:\/\/ntsblog.homedev.com.au\/index.php\/wp-json\/wp\/v2\/posts\/55\/revisions\/2179"}],"wp:attachment":[{"href":"https:\/\/ntsblog.homedev.com.au\/index.php\/wp-json\/wp\/v2\/media?parent=55"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ntsblog.homedev.com.au\/index.php\/wp-json\/wp\/v2\/categories?post=55"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ntsblog.homedev.com.au\/index.php\/wp-json\/wp\/v2\/tags?post=55"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}