{"id":880,"date":"2009-04-30T17:34:00","date_gmt":"2009-04-30T17:34:00","guid":{"rendered":"\/blogs\/paul\/post\/Performance-bug-NOLOCK-scans-involving-off-row-LOB-data.aspx"},"modified":"2017-04-13T09:51:45","modified_gmt":"2017-04-13T16:51:45","slug":"performance-bug-nolock-scans-involving-off-row-lob-data","status":"publish","type":"post","link":"https:\/\/www.sqlskills.com\/blogs\/paul\/performance-bug-nolock-scans-involving-off-row-lob-data\/","title":{"rendered":"Performance bug: NOLOCK scans involving off-row LOB data"},"content":{"rendered":"<p>\n<font face=\"verdana,geneva\" size=\"2\">Here&#39;s an interesting bug that was just recently fixed, and someone actually hit it today, so it&#39;s time to blog it.<\/font>\n<\/p>\n<p>\n<font face=\"verdana,geneva\" size=\"2\">Bottom line is that if you&#39;re doing NOLOCK scans of tables involving LOB data, the perfmance might suck. 2005 SP3 CU3 has the bug fix, but unfortunately the KB article was written by someone who didn&#39;t seem to know what they were talking about, so I suggested it was rewritten, which it has been (but not republished yet). The original KB article is at <\/font><a href=\"https:\/\/support.microsoft.com\/kb\/961049\"><font face=\"verdana,geneva\" size=\"2\">http:\/\/support.microsoft.com\/kb\/961049\/<\/font><\/a><font face=\"verdana,geneva\" size=\"2\">. It&#39;s also fixed in 2008, but I don&#39;t know which build (I believe CU4 at least).<\/font>\n<\/p>\n<p>\n<font face=\"verdana,geneva\" size=\"2\">Here&#39;s my explanation of the problem.<\/font>\n<\/p>\n<p>\n<font face=\"verdana,geneva\" size=\"2\">LOB data can be stored in-row or off-row (my previous LOB post <\/font><a href=\"https:\/\/www.sqlskills.com\/blogs\/paul\/importance-of-choosing-the-right-lob-storage-technique\/\"><font face=\"verdana,geneva\" size=\"2\">Importance of choosing the right LOB storage technique<\/font><\/a><font face=\"verdana,geneva\" size=\"2\">&nbsp;has more details). When it&#39;s stored off-row, it must be accessed by first reading the pointer to the LOB data from the data\/index record, and then following the pointer (remember that &#39;record&#39; is synonymous with &#39;row&#39;). When a LOB data value is updated, the off-row value is updated first, and then if the off-row link changed, the data\/index record is updated with the new link. There&#39;s obvioulsy a window here, where someone reading the data\/index record might see the wrong\/non-existent off-row pointer. This is exactly what can happen when a NOLOCK scan occurs.<\/font>\n<\/p>\n<p>\n<font face=\"verdana,geneva\" size=\"2\">To mitigate the possibility of a NOLOCK scan trying to follow a bad off-row link, the old behavior was to scan all the IAM pages (see <\/font><a href=\"https:\/\/www.sqlskills.com\/blogs\/paul\/inside-the-storage-engine-iam-pages-iam-chains-and-allocation-units\/\"><font face=\"verdana,geneva\" size=\"2\">Inside the Storage Engine: IAM pages, IAM chains, and allocation units<\/font><\/a><font face=\"verdana,geneva\" size=\"2\">) for the table\/index to make sure that the off-row link actually pointed to a page allocated to the table\/index. If there are lots of IAM pages, this means lots of logical IOs, and poorly performing SELECT queries. And it does the scan once for *every row*. The person that hit it today had a 500 row select of ~20KB per row taking 20 seconds &#8211; 10MB of physical IOs and 30MB of logical IOs!<\/font>\n<\/p>\n<p>\n<font face=\"verdana,geneva\" size=\"2\">The fix is to make further use of an already existing in-memory cache of IAM pages to do a quick lookup of the right IAM page covering the GAM interval of the LOB page being read, without having to scan the whole IAM chain.<\/font>\n<\/p>\n<p>\n<font face=\"verdana,geneva\" size=\"2\">Hope this helps explain things, and track down perf problems for some of you.<\/font><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here&#39;s an interesting bug that was just recently fixed, and someone actually hit it today, so it&#39;s time to blog it. Bottom line is that if you&#39;re doing NOLOCK scans of tables involving LOB data, the perfmance might suck. 2005 SP3 CU3 has the bug fix, but unfortunately the KB article was written by someone [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19,48,56,66],"tags":[],"class_list":["post-880","post","type-post","status-publish","format-standard","hentry","category-bugfixes","category-inside-the-storage-engine","category-lob-data","category-performance-tuning"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Performance bug: NOLOCK scans involving off-row LOB data - 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\/performance-bug-nolock-scans-involving-off-row-lob-data\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Performance bug: NOLOCK scans involving off-row LOB data - Paul S. Randal\" \/>\n<meta property=\"og:description\" content=\"Here&#039;s an interesting bug that was just recently fixed, and someone actually hit it today, so it&#039;s time to blog it. Bottom line is that if you&#039;re doing NOLOCK scans of tables involving LOB data, the perfmance might suck. 2005 SP3 CU3 has the bug fix, but unfortunately the KB article was written by someone [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqlskills.com\/blogs\/paul\/performance-bug-nolock-scans-involving-off-row-lob-data\/\" \/>\n<meta property=\"og:site_name\" content=\"Paul S. Randal\" \/>\n<meta property=\"article:published_time\" content=\"2009-04-30T17:34:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-04-13T16:51:45+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\/performance-bug-nolock-scans-involving-off-row-lob-data\/\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/performance-bug-nolock-scans-involving-off-row-lob-data\/\",\"name\":\"Performance bug: NOLOCK scans involving off-row LOB data - Paul S. Randal\",\"isPartOf\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#website\"},\"datePublished\":\"2009-04-30T17:34:00+00:00\",\"dateModified\":\"2017-04-13T16:51:45+00:00\",\"author\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/performance-bug-nolock-scans-involving-off-row-lob-data\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.sqlskills.com\/blogs\/paul\/performance-bug-nolock-scans-involving-off-row-lob-data\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/performance-bug-nolock-scans-involving-off-row-lob-data\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Performance bug: NOLOCK scans involving off-row LOB data\"}]},{\"@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":"Performance bug: NOLOCK scans involving off-row LOB data - 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\/performance-bug-nolock-scans-involving-off-row-lob-data\/","og_locale":"en_US","og_type":"article","og_title":"Performance bug: NOLOCK scans involving off-row LOB data - Paul S. Randal","og_description":"Here&#39;s an interesting bug that was just recently fixed, and someone actually hit it today, so it&#39;s time to blog it. Bottom line is that if you&#39;re doing NOLOCK scans of tables involving LOB data, the perfmance might suck. 2005 SP3 CU3 has the bug fix, but unfortunately the KB article was written by someone [&hellip;]","og_url":"https:\/\/www.sqlskills.com\/blogs\/paul\/performance-bug-nolock-scans-involving-off-row-lob-data\/","og_site_name":"Paul S. Randal","article_published_time":"2009-04-30T17:34:00+00:00","article_modified_time":"2017-04-13T16:51:45+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\/performance-bug-nolock-scans-involving-off-row-lob-data\/","url":"https:\/\/www.sqlskills.com\/blogs\/paul\/performance-bug-nolock-scans-involving-off-row-lob-data\/","name":"Performance bug: NOLOCK scans involving off-row LOB data - Paul S. Randal","isPartOf":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#website"},"datePublished":"2009-04-30T17:34:00+00:00","dateModified":"2017-04-13T16:51:45+00:00","author":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce"},"breadcrumb":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/performance-bug-nolock-scans-involving-off-row-lob-data\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqlskills.com\/blogs\/paul\/performance-bug-nolock-scans-involving-off-row-lob-data\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/performance-bug-nolock-scans-involving-off-row-lob-data\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqlskills.com\/blogs\/paul\/"},{"@type":"ListItem","position":2,"name":"Performance bug: NOLOCK scans involving off-row LOB data"}]},{"@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\/880","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=880"}],"version-history":[{"count":0,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/posts\/880\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/media?parent=880"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/categories?post=880"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/tags?post=880"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}