{"id":1027,"date":"2008-08-20T19:11:02","date_gmt":"2008-08-20T19:11:02","guid":{"rendered":"\/blogs\/paul\/post\/Can-GUID-cluster-keys-cause-non-clustered-index-fragmentation.aspx"},"modified":"2008-08-20T19:11:02","modified_gmt":"2008-08-20T19:11:02","slug":"can-guid-cluster-keys-cause-non-clustered-index-fragmentation","status":"publish","type":"post","link":"https:\/\/www.sqlskills.com\/blogs\/paul\/can-guid-cluster-keys-cause-non-clustered-index-fragmentation\/","title":{"rendered":"Can GUID cluster keys cause non-clustered index fragmentation?"},"content":{"rendered":"<p><FONT face=Verdana><FONT size=2><br \/>\n<P>At the user group meeting on Monday I spent some time explaining how GUIDs can cause fragmentation in clustered indexes AND in non-clustered indexes, even if the GUID isn&#8217;t specifically included in the non-clustered index key. GUIDs are essentially random values (pseudo-random in ranges if generated using <FONT face=\"Courier New\">NEWSEQUENTIALID<\/FONT>) that are also unique. Their uniqueness is what makes them attractive to many developers as a key value, without understanding the havoc they can cause in production in terms of fragmentation and poor query performance.<\/P><br \/>\n<P>A GUID key causes fragmentation because of its randomness. The insertion point of a new record in an index is dictated by the value of the index key, so if the key value is random, so is the insertion point. This means that if an index page is full, a random insert that happens to have to go onto that page will cause a page split to make room for the new record. A page-split is where a new page is allocated and (as near as possible to) half the rows from the splitting page are moved to the new page. The new row is then inserted into one of the two pages, determined by the key value. Usually the newly allocated page is not physically contiguous to the splitting page, and so fragmentation has been caused. In this case *two* kinds of fragmentation have been caused &#8211; logical fragmentation (where the next logical page as determined by the index order is not the next physical page in the data file) and physical (or internal) fragmentation (where space is being wasted on index pages). These can both affect query performance (topic for a later post), as well as the expense of having to do the page split in the first place.<\/P><br \/>\n<P>It&#8217;s fairly well known that GUIDs can cause fragmentation in the index where the GUID is the key (e.g. a clustered index), but not about the knock-on effects in non-clustered indexes. Here&#8217;s an example &#8211; I&#8217;ll create two clustered indexes with GUID keys (one generated from <FONT face=\"Courier New\">NEWID<\/FONT> and one from <FONT face=\"Courier New\">NEWSEQUENTIALID<\/FONT>), plus a non-clustered index on each. Let&#8217;s see what happens when we insert 100000 rows:<\/P><br \/>\n<BLOCKQUOTE dir=ltr style=\"MARGIN-RIGHT: 0px\"><FONT face=\"Courier New\" color=#008000><br \/>\n<P>&#8212; Create a table with a GUID key<BR><\/FONT><FONT color=#0000ff><FONT face=\"Courier New\">CREATE<\/FONT><\/FONT><FONT face=\"Courier New\"><FONT color=#000000> <\/FONT><FONT color=#0000ff>TABLE<\/FONT><FONT color=#000000> BadKeyTable <\/FONT><FONT color=#808080>(<BR>&nbsp;&nbsp;&nbsp;<\/FONT><\/FONT><FONT face=\"Courier New\">c1 <\/FONT><FONT face=\"Courier New\"><FONT color=#0000ff>UNIQUEIDENTIFIER<\/FONT> <FONT color=#0000ff>DEFAULT<\/FONT> <FONT color=#ff00ff>NEWID<\/FONT> <FONT color=#808080>()<\/FONT> <FONT color=#0000ff>ROWGUIDCOL<\/FONT><FONT color=#808080>,<BR>&nbsp;&nbsp;&nbsp;<\/FONT><\/FONT><FONT face=\"Courier New\">c2 <\/FONT><FONT face=\"Courier New\"><FONT color=#0000ff>DATETIME<\/FONT> <FONT color=#0000ff>DEFAULT<\/FONT> <FONT color=#ff00ff>GETDATE<\/FONT> <FONT color=#808080>(),<BR>&nbsp;&nbsp;&nbsp;<\/FONT><\/FONT><FONT face=\"Courier New\">c3 <\/FONT><FONT face=\"Courier New\"><FONT color=#0000ff>CHAR<\/FONT> <FONT color=#808080>(<\/FONT>400<FONT color=#808080>)<\/FONT> <FONT color=#0000ff>DEFAULT<\/FONT> <FONT color=#ff0000>&#8216;a&#8217;<\/FONT><FONT color=#808080>);<BR><\/FONT><\/FONT><FONT color=#0000ff><FONT face=\"Courier New\">CREATE<\/FONT><\/FONT><FONT face=\"Courier New\"><FONT color=#000000> <\/FONT><FONT color=#0000ff>CLUSTERED<\/FONT><FONT color=#000000> <\/FONT><FONT color=#0000ff>INDEX<\/FONT><FONT color=#000000> BadKeyTable_CL <\/FONT><FONT color=#0000ff>ON <\/FONT><\/FONT><FONT face=\"Courier New\">BadKeyTable <\/FONT><FONT face=\"Courier New\"><FONT color=#808080>(<\/FONT>c1<FONT color=#808080>);<\/FONT><\/FONT><FONT face=\"Courier New\"><BR><\/FONT><FONT color=#0000ff><FONT face=\"Courier New\">CREATE<\/FONT><\/FONT><FONT face=\"Courier New\"><FONT color=#000000> <\/FONT><FONT color=#0000ff>NONCLUSTERED<\/FONT><FONT color=#000000> <\/FONT><FONT color=#0000ff>INDEX<\/FONT><FONT color=#000000> BadKeyTable_NCL <\/FONT><FONT color=#0000ff>ON <\/FONT><\/FONT><FONT face=\"Courier New\">BadKeyTable <\/FONT><FONT face=\"Courier New\"><FONT color=#808080>(<\/FONT>c2<FONT color=#808080>);<BR><\/FONT><\/FONT><FONT face=\"Courier New\">GO<\/P><\/FONT><FONT color=#008000><br \/>\n<P><FONT face=\"Courier New\">&#8212; Create another one, but using <\/FONT><FONT face=\"Courier New\">NEWSEQUENTIALID instead<BR><\/FONT><\/FONT><FONT color=#0000ff><FONT face=\"Courier New\">CREATE<\/FONT><\/FONT><FONT face=\"Courier New\"><FONT color=#000000> <\/FONT><FONT color=#0000ff>TABLE<\/FONT><FONT color=#000000> BadKeyTable2 <\/FONT><FONT color=#808080>(<BR>&nbsp;&nbsp;&nbsp;<\/FONT><\/FONT><FONT face=\"Courier New\">c1 <\/FONT><FONT face=\"Courier New\"><FONT color=#0000ff>UNIQUEIDENTIFIER<\/FONT> <FONT color=#0000ff>DEFAULT<\/FONT> <FONT color=#ff00ff>NEWSEQUENTIALID<\/FONT> <FONT color=#808080>()<\/FONT> <FONT color=#0000ff>ROWGUIDCOL<\/FONT><FONT color=#808080>,<BR>&nbsp;&nbsp;&nbsp;<\/FONT><\/FONT><FONT face=\"Courier New\">c2 <\/FONT><FONT face=\"Courier New\"><FONT color=#0000ff>DATETIME<\/FONT> <FONT color=#0000ff>DEFAULT<\/FONT> <FONT color=#ff00ff>GETDATE<\/FONT> <FONT color=#808080>(),<BR>&nbsp;&nbsp;&nbsp;<\/FONT><\/FONT><FONT face=\"Courier New\">c3 <\/FONT><FONT face=\"Courier New\"><FONT color=#0000ff>CHAR<\/FONT> <FONT color=#808080>(<\/FONT>400<FONT color=#808080>)<\/FONT> <FONT color=#0000ff>DEFAULT<\/FONT> <FONT color=#ff0000>&#8216;a&#8217;<\/FONT><FONT color=#808080>);<BR><\/FONT><\/FONT><FONT color=#0000ff><FONT face=\"Courier New\">CREATE<\/FONT><\/FONT><FONT face=\"Courier New\"><FONT color=#000000> <\/FONT><FONT color=#0000ff>CLUSTERED<\/FONT><FONT color=#000000> <\/FONT><FONT color=#0000ff>INDEX<\/FONT><FONT color=#000000> BadKeyTable2_CL <\/FONT><FONT color=#0000ff>ON <\/FONT><\/FONT><FONT face=\"Courier New\">BadKeyTable2 <\/FONT><FONT face=\"Courier New\"><FONT color=#808080>(<\/FONT>c1<FONT color=#808080>);<\/FONT><\/FONT><FONT face=\"Courier New\"><BR><\/FONT><FONT color=#0000ff><FONT face=\"Courier New\">CREATE<\/FONT><\/FONT><FONT face=\"Courier New\"><FONT color=#000000> <\/FONT><FONT color=#0000ff>NONCLUSTERED<\/FONT><FONT color=#000000> <\/FONT><FONT color=#0000ff>INDEX<\/FONT><FONT color=#000000> BadKeyTable2_NCL <\/FONT><FONT color=#0000ff>ON <\/FONT><\/FONT><FONT face=\"Courier New\">BadKeyTable2 <\/FONT><FONT face=\"Courier New\"><FONT color=#808080>(<\/FONT>c2<FONT color=#808080>);<BR><\/FONT><\/FONT><FONT face=\"Courier New\">GO<\/P><\/FONT><FONT color=#0000ff><br \/>\n<P><FONT face=\"Courier New\">DECLARE<\/FONT><\/FONT><FONT face=\"Courier New\"><FONT color=#000000> @a <\/FONT><FONT color=#0000ff>INT<\/FONT><FONT color=#808080>;<BR><\/FONT><\/FONT><FONT color=#0000ff><FONT face=\"Courier New\">SELECT<\/FONT><\/FONT><FONT face=\"Courier New\"><FONT color=#000000> @a <\/FONT><FONT color=#808080>=<\/FONT><FONT color=#000000> 1<\/FONT><FONT color=#808080>;<BR><\/FONT><\/FONT><FONT color=#0000ff><FONT face=\"Courier New\">WHILE<\/FONT><\/FONT><FONT face=\"Courier New\"><FONT color=#000000> <\/FONT><FONT color=#808080>(<\/FONT><FONT color=#000000>@a <\/FONT><FONT color=#808080>&lt;<\/FONT><FONT color=#000000> 10000<\/FONT><FONT color=#808080>)<BR><\/FONT><\/FONT><FONT face=\"Courier New\" color=#0000ff>BEGIN<BR>&nbsp;&nbsp;&nbsp;<\/FONT><FONT face=\"Courier New\"><FONT color=#0000ff>INSERT<\/FONT> <FONT color=#0000ff>INTO<\/FONT> BadKeyTable <FONT color=#0000ff>DEFAULT<\/FONT> <FONT color=#0000ff>VALUES<\/FONT><FONT color=#808080>;<BR>&nbsp;&nbsp;&nbsp;<\/FONT><\/FONT><FONT face=\"Courier New\"><FONT color=#0000ff>INSERT<\/FONT> <FONT color=#0000ff>INTO<\/FONT> BadKeyTable2 <FONT color=#0000ff>DEFAULT<\/FONT> <FONT color=#0000ff>VALUES<\/FONT><FONT color=#808080>;<BR>&nbsp;&nbsp;&nbsp;<\/FONT><\/FONT><FONT face=\"Courier New\"><FONT color=#0000ff>SELECT<\/FONT> @a <FONT color=#808080>=<\/FONT> @a <FONT color=#808080>+<\/FONT> 1<FONT color=#808080>;<BR><\/FONT><\/FONT><FONT color=#0000ff><FONT face=\"Courier New\">END<\/FONT><\/FONT><FONT color=#808080><FONT face=\"Courier New\">;<BR><\/FONT><\/FONT><FONT face=\"Courier New\">GO<\/FONT><\/P><FONT face=\"Courier New\"><FONT color=#008000><br \/>\n<P>&#8212; And now check for fragmentation<BR><\/FONT><FONT color=#0000ff>SELECT<BR>&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#ff00ff>OBJECT_NAME<\/FONT> <FONT color=#808080>(<\/FONT>ips<FONT color=#808080>.<\/FONT>[object_id]<FONT color=#808080>)<\/FONT> <FONT color=#0000ff>AS<\/FONT> <FONT color=#ff0000>&#8216;Object Name&#8217;<\/FONT><FONT color=#808080>,<BR>&nbsp;&nbsp;&nbsp;<\/FONT>si<FONT color=#808080>.<\/FONT>name <FONT color=#0000ff>AS<\/FONT> <FONT color=#ff0000>&#8216;Index Name&#8217;<\/FONT><FONT color=#808080>,<BR><FONT color=#ff00ff>&nbsp;&nbsp;&nbsp;ROUND<\/FONT> <FONT color=#808080>(<\/FONT>ips<FONT color=#808080>.<\/FONT>avg_fragmentation_in_percent<FONT color=#808080>,<\/FONT> 2<FONT color=#808080>)<\/FONT> <FONT color=#0000ff>AS<\/FONT> <FONT color=#ff0000>&#8216;Fragmentation&#8217;<\/FONT><FONT color=#808080>,<BR>&nbsp;&nbsp;&nbsp;<\/FONT>ips<FONT color=#808080>.<\/FONT>page_count <FONT color=#0000ff>AS<\/FONT> <FONT color=#ff0000>&#8216;Pages&#8217;<\/FONT><FONT color=#808080>,<BR>&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#ff00ff>ROUND<\/FONT> <FONT color=#808080>(<\/FONT>ips<FONT color=#808080>.<\/FONT>avg_page_space_used_in_percent<FONT color=#808080>,<\/FONT> 2<FONT color=#808080>)<\/FONT> <FONT color=#0000ff>AS<\/FONT> <FONT color=#ff0000>&#8216;Page Density&#8217;<BR><\/FONT><\/FONT><FONT color=#0000ff>FROM<\/FONT><FONT color=#000000> sys.dm_db_index_physical_stats <\/FONT><FONT color=#808080>(<\/FONT><FONT color=#ff00ff>DB_ID<\/FONT> <FONT color=#808080>(<\/FONT><FONT color=#ff0000>&#8216;DBMaint2008&#8217;<\/FONT><FONT color=#808080>), <\/FONT><FONT color=#808080>NULL, <\/FONT><FONT color=#808080>NULL, <\/FONT><FONT color=#808080>NULL, <\/FONT><FONT color=#ff0000>&#8216;DETAILED&#8217;<\/FONT><FONT color=#808080>)<\/FONT> ips<BR><FONT color=#808080>CROSS<\/FONT><FONT color=#000000> <\/FONT><FONT color=#808080>APPLY<\/FONT><FONT color=#000000> <\/FONT><FONT color=#008000>sys.indexes<\/FONT><FONT color=#000000> si<BR><\/FONT><FONT color=#0000ff>WHERE<BR>&nbsp;&nbsp;&nbsp;<\/FONT>si<FONT color=#808080>.<\/FONT><FONT color=#ff00ff>object_id<\/FONT> <FONT color=#808080>=<\/FONT> ips<FONT color=#808080>.<\/FONT><FONT color=#ff00ff>object_id<BR>&nbsp;&nbsp;&nbsp;<\/FONT><FONT color=#808080>AND<\/FONT> si<FONT color=#808080>.<\/FONT>index_id <FONT color=#808080>=<\/FONT> ips<FONT color=#808080>.<\/FONT>index_id<BR>&nbsp;&nbsp;&nbsp;<FONT color=#808080>AND<\/FONT> ips<FONT color=#808080>.<\/FONT>index_level <FONT color=#808080>=<\/FONT><FONT size=5><FONT size=2> 0<FONT color=#808080>;<\/FONT><BR><\/FONT><FONT size=2>GO<\/FONT><\/FONT><\/P><br \/>\n<P><FONT size=5><FONT size=2>Object Name&nbsp;&nbsp;&nbsp; Index Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Fragmentation&nbsp; Pages&nbsp; Page Density<BR>&#8212;&#8212;&#8212;&#8212;-&nbsp; &#8212;&#8212;&#8212;&#8212;&#8212;-&nbsp; &#8212;&#8212;&#8212;&#8212;-&nbsp; &#8212;&#8211;&nbsp; &#8212;&#8212;&#8212;&#8212;<BR>BadKeyTable&nbsp;&nbsp;&nbsp; BadKeyTable_CL&nbsp;&nbsp;&nbsp; 99.13&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8092&nbsp;&nbsp; 66.08<BR>BadKeyTable&nbsp;&nbsp;&nbsp; BadKeyTable_NCL&nbsp;&nbsp; 30.97&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 78&nbsp;&nbsp;&nbsp;&nbsp; 64.1<BR>BadKeyTable2&nbsp;&nbsp; BadKeyTable2_CL&nbsp;&nbsp; 0.83&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 5556&nbsp;&nbsp; 96.26<BR>BadKeyTable2&nbsp;&nbsp; BadKeyTable2_NCL&nbsp; 1.88&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 372&nbsp;&nbsp;&nbsp; 99.61<\/FONT><\/FONT><\/P><\/BLOCKQUOTE><br \/>\n<P dir=ltr><FONT size=5><FONT size=2><FONT face=Verdana>The <FONT face=\"Courier New\">BadKeyTable_CL<\/FONT> clustered index with the GUID key generated from <FONT face=\"Courier New\">NEWID<\/FONT> is almost perfectly fragmented, with 34% space being wasted on each page. Conversely, the <FONT face=\"Courier New\">BadKeyTable2_CL<\/FONT> clustered index with the GUID key generated from <FONT face=\"Courier New\">NEWSEQUENTIALID<\/FONT> is hardly fragmented and only 4% of free space is wasted (and this is just because of the row size chosen). These numbers are entirely expected given the nature of the cluster keys.<\/FONT><\/FONT><\/FONT><\/P><br \/>\n<P dir=ltr><FONT size=5><FONT size=2><FONT face=Verdana>Now look at the non-clustered indexes. <FONT face=\"Courier New\">BadKeyTable_NCL<\/FONT> is 31% fragmented with 36% space wasted on each page! <FONT face=\"Courier New\">BadKeyTable2_NCL<\/FONT> is harldy fragmented with no free space wasted on each page. So what&#8217;s going on? The non-clustered index key in both cases is a datetime column, which has a minimum granularity of 3 milliseconds. The code above runs in a tight loop inserting records and so can insert more than one record per 3ms time interval &#8211; and I allow this because I didn&#8217;t create make the non-clustered indexes unique. For all the records inserted in one 3ms time interval, there *has* to be something that makes the non-clustered index key unique internally (as even though an index can be defined as non-unique, the Storage Engine requires that each record really is unique in an index and will add whatever it needs to so that happens).<\/FONT><\/FONT><\/FONT><\/P><br \/>\n<P dir=ltr><FONT size=5><FONT size=2><FONT face=Verdana>In this case, the clustered index key (which must be present in the non-clustered index anyway) is used to differentiate between all the non-clustered index records with the same datetime value. For <FONT face=\"Courier New\">BadKeyTable_NCL<\/FONT>, the cluster key is a random GUID, so the non-clustered index record insertion points ALSO become random within each 3ms time interval &#8211; leading to the fragmentation above. The <FONT face=\"Courier New\">BadKeyTable2_NCL<\/FONT> non-clustered index has the same time interval issue, but it&#8217;s cluster key is a sequential GUID, so the non-clustered index doesn&#8217;t get fragmented. If the non-clustered index key was a time datatype with a larger minimum granularity (like smalldatetime, or the new date), the fragmentation of <FONT face=\"Courier New\">BadKeyTable_NCL<\/FONT> would be even worse &#8211; try it for yourself and you&#8217;ll see.<\/FONT><\/FONT><\/FONT><\/P><br \/>\n<P dir=ltr><FONT size=5><FONT size=2><FONT face=Verdana>So the answer to the question in the blog post title is really &#8211; it depends! Under the right conditions, a GUID cluster key can also seriously fragment a non-clustered index as well.<\/FONT><\/P><\/FONT><\/FONT><\/FONT><\/FONT><\/FONT><\/p>\n","protected":false},"excerpt":{"rendered":"<p>At the user group meeting on Monday I spent some time explaining how GUIDs can cause fragmentation in clustered indexes AND in non-clustered indexes, even if the GUID isn&#8217;t specifically included in the non-clustered index key. GUIDs are essentially random values (pseudo-random in ranges if generated using NEWSEQUENTIALID) that are also unique. Their uniqueness is [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[31,42,47,66],"tags":[],"class_list":["post-1027","post","type-post","status-publish","format-standard","hentry","category-database-maintenance","category-fragmentation","category-indexes-from-every-angle","category-performance-tuning"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Can GUID cluster keys cause non-clustered index fragmentation? - 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\/can-guid-cluster-keys-cause-non-clustered-index-fragmentation\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Can GUID cluster keys cause non-clustered index fragmentation? - Paul S. Randal\" \/>\n<meta property=\"og:description\" content=\"At the user group meeting on Monday I spent some time explaining how GUIDs can cause fragmentation in clustered indexes AND in non-clustered indexes, even if the GUID isn&#8217;t specifically included in the non-clustered index key. GUIDs are essentially random values (pseudo-random in ranges if generated using NEWSEQUENTIALID) that are also unique. Their uniqueness is [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqlskills.com\/blogs\/paul\/can-guid-cluster-keys-cause-non-clustered-index-fragmentation\/\" \/>\n<meta property=\"og:site_name\" content=\"Paul S. Randal\" \/>\n<meta property=\"article:published_time\" content=\"2008-08-20T19:11:02+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=\"5 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\/can-guid-cluster-keys-cause-non-clustered-index-fragmentation\/\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/can-guid-cluster-keys-cause-non-clustered-index-fragmentation\/\",\"name\":\"Can GUID cluster keys cause non-clustered index fragmentation? - Paul S. Randal\",\"isPartOf\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#website\"},\"datePublished\":\"2008-08-20T19:11:02+00:00\",\"author\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/can-guid-cluster-keys-cause-non-clustered-index-fragmentation\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.sqlskills.com\/blogs\/paul\/can-guid-cluster-keys-cause-non-clustered-index-fragmentation\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/can-guid-cluster-keys-cause-non-clustered-index-fragmentation\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Can GUID cluster keys cause non-clustered index fragmentation?\"}]},{\"@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":"Can GUID cluster keys cause non-clustered index fragmentation? - 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\/can-guid-cluster-keys-cause-non-clustered-index-fragmentation\/","og_locale":"en_US","og_type":"article","og_title":"Can GUID cluster keys cause non-clustered index fragmentation? - Paul S. Randal","og_description":"At the user group meeting on Monday I spent some time explaining how GUIDs can cause fragmentation in clustered indexes AND in non-clustered indexes, even if the GUID isn&#8217;t specifically included in the non-clustered index key. GUIDs are essentially random values (pseudo-random in ranges if generated using NEWSEQUENTIALID) that are also unique. Their uniqueness is [&hellip;]","og_url":"https:\/\/www.sqlskills.com\/blogs\/paul\/can-guid-cluster-keys-cause-non-clustered-index-fragmentation\/","og_site_name":"Paul S. Randal","article_published_time":"2008-08-20T19:11:02+00:00","author":"Paul Randal","twitter_misc":{"Written by":"Paul Randal","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/can-guid-cluster-keys-cause-non-clustered-index-fragmentation\/","url":"https:\/\/www.sqlskills.com\/blogs\/paul\/can-guid-cluster-keys-cause-non-clustered-index-fragmentation\/","name":"Can GUID cluster keys cause non-clustered index fragmentation? - Paul S. Randal","isPartOf":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#website"},"datePublished":"2008-08-20T19:11:02+00:00","author":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce"},"breadcrumb":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/can-guid-cluster-keys-cause-non-clustered-index-fragmentation\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqlskills.com\/blogs\/paul\/can-guid-cluster-keys-cause-non-clustered-index-fragmentation\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/can-guid-cluster-keys-cause-non-clustered-index-fragmentation\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqlskills.com\/blogs\/paul\/"},{"@type":"ListItem","position":2,"name":"Can GUID cluster keys cause non-clustered index fragmentation?"}]},{"@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\/1027","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=1027"}],"version-history":[{"count":0,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/posts\/1027\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/media?parent=1027"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/categories?post=1027"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/tags?post=1027"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}