{"id":4495,"date":"2015-04-28T11:52:00","date_gmt":"2015-04-28T18:52:00","guid":{"rendered":"http:\/\/3.209.169.194\/blogs\/paul\/?p=4495"},"modified":"2015-04-28T11:55:18","modified_gmt":"2015-04-28T18:55:18","slug":"when-dbcc-dropcleanbuffers-doesnt-work","status":"publish","type":"post","link":"https:\/\/www.sqlskills.com\/blogs\/paul\/when-dbcc-dropcleanbuffers-doesnt-work\/","title":{"rendered":"When DBCC DROPCLEANBUFFERS doesn&#8217;t work&#8230;"},"content":{"rendered":"<p>Here&#8217;s an interesting question\u00a0that came up in our IEPTO1 class in Chicago this week (paraphrasing):<\/p>\n<p style=\"padding-left: 30px;\"><em>I was doing a demo recently where I was demonstrating physical I\/Os occurring. I used DBCC DROPCLEANBUFFERS, then enabled SET STATISTICS IO ON and performed a SELECT operation. I was expecting to see physical reads occurring but I only saw\u00a0logical reads. What&#8217;s going on? Why weren&#8217;t there any physical reads after I&#8217;d flushed the buffer pool with DBCC DROPCLEANBUFFERS?<\/em><\/p>\n<p>It&#8217;s a very interesting question. If you ask most people what <em>DBCC DROPCLEANBUFFERS<\/em> does, you&#8217;ll get the response that it clears out the buffer pool (as my student expected).<\/p>\n<p>But it doesn&#8217;t.<\/p>\n<p>It drops *clean* pages from the buffer pool only.<\/p>\n<p>A clean page is one that has not been changed since it was read into memory or last written to disk. A dirty page is one that has not been written to disk since it was last changed. Dirty pages are not dropped by <em>DBCC DROPCLEANBUFFERS<\/em>, they are only made clean by writing them to disk (either through one of the various kinds of checkpoints or by the lazy writer &#8211; or one of the per-NUMA node lazy writers if you have NUMA configured).<\/p>\n<p>The demo in question had updated the table being selected, and so when <em>DBCC DROPCLEANBUFFERS<\/em> was executed, the pages from that table remained in memory &#8211; hence no physical reads were required for the subsequent <em>SELECT<\/em>.<\/p>\n<p>If you want to ensure that all pages from a database are flushed from memory, you need to first perform a manual <em>CHECKPOINT<\/em> of that database and then run <em>DBCC DROPCLEANBUFFERS<\/em>.<\/p>\n<p>You can then verify that there are no pages in memory for the database in question using the following code:<\/p>\n<pre class=\"brush: sql; title: ; toolbar: true; wrap-lines: true; notranslate\" title=\"\">\r\nSELECT *,\r\n\t&#x5B;DirtyPageCount] * 8 \/ 1024 AS &#x5B;DirtyPageMB],\r\n\t&#x5B;CleanPageCount] * 8 \/ 1024 AS &#x5B;CleanPageMB]\r\nFROM\r\n\t(SELECT \r\n\t\t(CASE WHEN (&#x5B;database_id] = 32767)\r\n\t\t\tTHEN N'Resource Database'\r\n\t\t\tELSE DB_NAME (&#x5B;database_id]) END) AS &#x5B;DatabaseName], \r\n\t\tSUM (CASE WHEN (&#x5B;is_modified] = 1)\r\n\t\t\tTHEN 1 ELSE 0 END) AS &#x5B;DirtyPageCount], \r\n\t\tSUM (CASE WHEN (&#x5B;is_modified] = 1)\r\n\t\t\tTHEN 0 ELSE 1 END) AS &#x5B;CleanPageCount]\r\n\tFROM sys.dm_os_buffer_descriptors\r\n\tGROUP BY &#x5B;database_id]) AS &#x5B;buffers]\r\nORDER BY &#x5B;DatabaseName]\r\nGO \r\n<\/pre>\n<p>Hope this helps some of you out there!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here&#8217;s an interesting question\u00a0that came up in our IEPTO1 class in Chicago this week (paraphrasing): I was doing a demo recently where I was demonstrating physical I\/Os occurring. I used DBCC DROPCLEANBUFFERS, then enabled SET STATISTICS IO ON and performed a SELECT operation. I was expecting to see physical reads occurring but I only saw\u00a0logical [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18,34],"tags":[],"class_list":["post-4495","post","type-post","status-publish","format-standard","hentry","category-buffer-pool","category-dbcc"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>When DBCC DROPCLEANBUFFERS doesn&#039;t work... - Paul S. Randal<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.sqlskills.com\/blogs\/paul\/when-dbcc-dropcleanbuffers-doesnt-work\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"When DBCC DROPCLEANBUFFERS doesn&#039;t work... - Paul S. Randal\" \/>\n<meta property=\"og:description\" content=\"Here&#8217;s an interesting question\u00a0that came up in our IEPTO1 class in Chicago this week (paraphrasing): I was doing a demo recently where I was demonstrating physical I\/Os occurring. I used DBCC DROPCLEANBUFFERS, then enabled SET STATISTICS IO ON and performed a SELECT operation. I was expecting to see physical reads occurring but I only saw\u00a0logical [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqlskills.com\/blogs\/paul\/when-dbcc-dropcleanbuffers-doesnt-work\/\" \/>\n<meta property=\"og:site_name\" content=\"Paul S. Randal\" \/>\n<meta property=\"article:published_time\" content=\"2015-04-28T18:52:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2015-04-28T18:55:18+00:00\" \/>\n<meta name=\"author\" content=\"Paul Randal\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Paul Randal\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/when-dbcc-dropcleanbuffers-doesnt-work\/\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/when-dbcc-dropcleanbuffers-doesnt-work\/\",\"name\":\"When DBCC DROPCLEANBUFFERS doesn't work... - Paul S. Randal\",\"isPartOf\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#website\"},\"datePublished\":\"2015-04-28T18:52:00+00:00\",\"dateModified\":\"2015-04-28T18:55:18+00:00\",\"author\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/when-dbcc-dropcleanbuffers-doesnt-work\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.sqlskills.com\/blogs\/paul\/when-dbcc-dropcleanbuffers-doesnt-work\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/when-dbcc-dropcleanbuffers-doesnt-work\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"When DBCC DROPCLEANBUFFERS doesn&#8217;t work&#8230;\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#website\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/\",\"name\":\"Paul S. Randal\",\"description\":\"In Recovery...\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce\",\"name\":\"Paul Randal\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/0b6a266bba2f088f2551ef529293001bd73bf026bc1908b9866728c062beeeb6?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/0b6a266bba2f088f2551ef529293001bd73bf026bc1908b9866728c062beeeb6?s=96&d=mm&r=g\",\"caption\":\"Paul Randal\"},\"sameAs\":[\"http:\/\/3.209.169.194\/blogs\/paul\"],\"url\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/author\/paul\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"When DBCC DROPCLEANBUFFERS doesn't work... - Paul S. Randal","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.sqlskills.com\/blogs\/paul\/when-dbcc-dropcleanbuffers-doesnt-work\/","og_locale":"en_US","og_type":"article","og_title":"When DBCC DROPCLEANBUFFERS doesn't work... - Paul S. Randal","og_description":"Here&#8217;s an interesting question\u00a0that came up in our IEPTO1 class in Chicago this week (paraphrasing): I was doing a demo recently where I was demonstrating physical I\/Os occurring. I used DBCC DROPCLEANBUFFERS, then enabled SET STATISTICS IO ON and performed a SELECT operation. I was expecting to see physical reads occurring but I only saw\u00a0logical [&hellip;]","og_url":"https:\/\/www.sqlskills.com\/blogs\/paul\/when-dbcc-dropcleanbuffers-doesnt-work\/","og_site_name":"Paul S. Randal","article_published_time":"2015-04-28T18:52:00+00:00","article_modified_time":"2015-04-28T18:55:18+00:00","author":"Paul Randal","twitter_misc":{"Written by":"Paul Randal","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/when-dbcc-dropcleanbuffers-doesnt-work\/","url":"https:\/\/www.sqlskills.com\/blogs\/paul\/when-dbcc-dropcleanbuffers-doesnt-work\/","name":"When DBCC DROPCLEANBUFFERS doesn't work... - Paul S. Randal","isPartOf":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#website"},"datePublished":"2015-04-28T18:52:00+00:00","dateModified":"2015-04-28T18:55:18+00:00","author":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce"},"breadcrumb":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/when-dbcc-dropcleanbuffers-doesnt-work\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqlskills.com\/blogs\/paul\/when-dbcc-dropcleanbuffers-doesnt-work\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/when-dbcc-dropcleanbuffers-doesnt-work\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqlskills.com\/blogs\/paul\/"},{"@type":"ListItem","position":2,"name":"When DBCC DROPCLEANBUFFERS doesn&#8217;t work&#8230;"}]},{"@type":"WebSite","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#website","url":"https:\/\/www.sqlskills.com\/blogs\/paul\/","name":"Paul S. Randal","description":"In Recovery...","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sqlskills.com\/blogs\/paul\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce","name":"Paul Randal","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/0b6a266bba2f088f2551ef529293001bd73bf026bc1908b9866728c062beeeb6?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/0b6a266bba2f088f2551ef529293001bd73bf026bc1908b9866728c062beeeb6?s=96&d=mm&r=g","caption":"Paul Randal"},"sameAs":["http:\/\/3.209.169.194\/blogs\/paul"],"url":"https:\/\/www.sqlskills.com\/blogs\/paul\/author\/paul\/"}]}},"_links":{"self":[{"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/posts\/4495","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/comments?post=4495"}],"version-history":[{"count":0,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/posts\/4495\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/media?parent=4495"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/categories?post=4495"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/tags?post=4495"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}