{"id":576,"date":"2010-12-23T17:17:00","date_gmt":"2010-12-23T17:17:00","guid":{"rendered":"\/blogs\/bobb\/post\/SQL-Server-Denali-the-new-autogrid-spatial-index.aspx"},"modified":"2010-12-23T17:17:00","modified_gmt":"2010-12-23T17:17:00","slug":"sql-server-denali-the-new-autogrid-spatial-index","status":"publish","type":"post","link":"https:\/\/www.sqlskills.com\/blogs\/bobb\/sql-server-denali-the-new-autogrid-spatial-index\/","title":{"rendered":"SQL Server Denali &#8211; the new autogrid spatial index"},"content":{"rendered":"<p>\nI&#39;ve been trying out the new Denali &quot;AUTO_GRID&quot; spatial index (that is &#8230;USING GEOGRAPHY_AUTO_GRID or GEOMETRY_AUTO_GRID in the CREATE SPATIAL INDEX DDL) on some of my old spatial performance use cases. It&#39;s worth repeating (from Ed&#39;s excellent whitepaper) that the AUTOGRID index uses 8 levels of tessellation instead of the 4 levels that the original &quot;manual grid&quot; spatial index uses. Let&#39;s go on from there. BTW, If you&#39;re not familiar with spatial indexes you might want to skip to the last paragraph for the motivation first.\n<\/p>\n<p>\nIn the manual-grid index, you can specify a grid resolution of high\/medium\/low for each of the 4 levels. This equates to a grid cell size of 16 (low), 64 (medium), or 256 (high) cells for grid level. I&#39;ve adopted a convension of calling an index with grid level of GRIDS = (HIGH, HIGH, HIGH, HIGH ), as &quot;HHHH&quot;, GRIDS = (MEDIUM, LOW, MEDIUM, HIGH ) as &quot;MLMH&quot;, etc.\n<\/p>\n<p>\nUsing this convention, the new AUTOGRID index is &quot;HLLLLLLL&quot; that is high-res at the first level, low-res at the other 7 levels. You can&#39;t specify an 8 level index AND specify grid-res at the same time, the only 8- level index supported is the &quot;AUTOGRID&quot;. And you can&#39;t get the grid-res of an AUTOGRID via the usual mechanism, sys.spatial_index_tessellations reports NULL for these fields. I got the info from the spatial diagnostic stored procs.\n<\/p>\n<p>\nSo far, I&#39;ve tried it on two use cases: point-in-polygon with a zipcode polygon and intersecting polygons (zipcode and congressional district). With the intersecting polygons, a &quot;HHHH&quot; index seems to outperform the autogrid by 17 vs 24 seconds with a &quot;primed&quot; data cache. With the point-in-polygon case, the autogrid beats the &quot;HHHH&quot; index by 14 vs 21 seconds with a primed data cache and 1000 points. I&#39;m also encouraged by the fact that, given multiple spatial indexes, the query optimizer picked the correct (best) one in both cases.\n<\/p>\n<p>\nHowever, I&#39;m less impressed by the spatial diagnostic procedures, which picked the new autogrid as best both times, that is, Primary_Filter_Efficiency and Percentage_Of_Rows_NotSelected_By_Primary_Filter were better for the autogrid spatial index even when its not the better choice. Hmmm&#8230;well I can still adjust cells_per_object and try again&#8230; And perhaps I used a non-representative query sample in the disgnostic procs&nbsp;for the&nbsp;polygon case.\n<\/p>\n<p>\nSo what&#39;s this autogrid index for anyhow? It&#39;s there for software products that can automatically create a single spatial index for each spatial table\/column. These products can get a &quot;usually best&quot; and at least &quot;good enough&quot; default spatial index without doing any special analysis of the spatial objects in the table or knowing what spatial queries you&#39;re going to perform. Autogrid is supposed to be often the best choice and certainly never a bad choice (as the old default of&nbsp;&quot;MMMM&quot; sometimes was. And if you can find a better spatial index for your specific queries, you&#39;re still allowed to use it, of course. Nice feature.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#39;ve been trying out the new Denali &quot;AUTO_GRID&quot; spatial index (that is &#8230;USING GEOGRAPHY_AUTO_GRID or GEOMETRY_AUTO_GRID in the CREATE SPATIAL INDEX DDL) on some of my old spatial performance use cases. It&#39;s worth repeating (from Ed&#39;s excellent whitepaper) that the AUTOGRID index uses 8 levels of tessellation instead of the 4 levels that the original [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[31,36],"tags":[],"class_list":["post-576","post","type-post","status-publish","format-standard","hentry","category-sql-server-2012","category-sql-server-spatial"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.9.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>SQL Server Denali - the new autogrid spatial index - Bob Beauchemin<\/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\/bobb\/sql-server-denali-the-new-autogrid-spatial-index\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SQL Server Denali - the new autogrid spatial index - Bob Beauchemin\" \/>\n<meta property=\"og:description\" content=\"I&#039;ve been trying out the new Denali &quot;AUTO_GRID&quot; spatial index (that is &#8230;USING GEOGRAPHY_AUTO_GRID or GEOMETRY_AUTO_GRID in the CREATE SPATIAL INDEX DDL) on some of my old spatial performance use cases. It&#039;s worth repeating (from Ed&#039;s excellent whitepaper) that the AUTOGRID index uses 8 levels of tessellation instead of the 4 levels that the original [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqlskills.com\/blogs\/bobb\/sql-server-denali-the-new-autogrid-spatial-index\/\" \/>\n<meta property=\"og:site_name\" content=\"Bob Beauchemin\" \/>\n<meta property=\"article:published_time\" content=\"2010-12-23T17:17:00+00:00\" \/>\n<meta name=\"author\" content=\"Bob Beauchemin\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Bob Beauchemin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/sql-server-denali-the-new-autogrid-spatial-index\/\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/sql-server-denali-the-new-autogrid-spatial-index\/\",\"name\":\"SQL Server Denali - the new autogrid spatial index - Bob Beauchemin\",\"isPartOf\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#website\"},\"datePublished\":\"2010-12-23T17:17:00+00:00\",\"dateModified\":\"2010-12-23T17:17:00+00:00\",\"author\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/62bfa986c5b5d28fcffd8b4fc409c73e\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/sql-server-denali-the-new-autogrid-spatial-index\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.sqlskills.com\/blogs\/bobb\/sql-server-denali-the-new-autogrid-spatial-index\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/sql-server-denali-the-new-autogrid-spatial-index\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SQL Server 2012\",\"item\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/category\/sql-server-2012\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"SQL Server Denali &#8211; the new autogrid spatial index\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#website\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/\",\"name\":\"Bob Beauchemin\",\"description\":\"SQL Server Blog\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/62bfa986c5b5d28fcffd8b4fc409c73e\",\"name\":\"Bob Beauchemin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/6f80e6cc667410857fa6a21931dc528b8092f4d112bf7a8ff7c267674d44ee37?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/6f80e6cc667410857fa6a21931dc528b8092f4d112bf7a8ff7c267674d44ee37?s=96&d=mm&r=g\",\"caption\":\"Bob Beauchemin\"},\"sameAs\":[\"http:\/www.sqlskills.com\/blogs\/bobb\/\"],\"url\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/author\/bobb\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"SQL Server Denali - the new autogrid spatial index - Bob Beauchemin","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\/bobb\/sql-server-denali-the-new-autogrid-spatial-index\/","og_locale":"en_US","og_type":"article","og_title":"SQL Server Denali - the new autogrid spatial index - Bob Beauchemin","og_description":"I&#39;ve been trying out the new Denali &quot;AUTO_GRID&quot; spatial index (that is &#8230;USING GEOGRAPHY_AUTO_GRID or GEOMETRY_AUTO_GRID in the CREATE SPATIAL INDEX DDL) on some of my old spatial performance use cases. It&#39;s worth repeating (from Ed&#39;s excellent whitepaper) that the AUTOGRID index uses 8 levels of tessellation instead of the 4 levels that the original [&hellip;]","og_url":"https:\/\/www.sqlskills.com\/blogs\/bobb\/sql-server-denali-the-new-autogrid-spatial-index\/","og_site_name":"Bob Beauchemin","article_published_time":"2010-12-23T17:17:00+00:00","author":"Bob Beauchemin","twitter_misc":{"Written by":"Bob Beauchemin","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/sql-server-denali-the-new-autogrid-spatial-index\/","url":"https:\/\/www.sqlskills.com\/blogs\/bobb\/sql-server-denali-the-new-autogrid-spatial-index\/","name":"SQL Server Denali - the new autogrid spatial index - Bob Beauchemin","isPartOf":{"@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#website"},"datePublished":"2010-12-23T17:17:00+00:00","dateModified":"2010-12-23T17:17:00+00:00","author":{"@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/62bfa986c5b5d28fcffd8b4fc409c73e"},"breadcrumb":{"@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/sql-server-denali-the-new-autogrid-spatial-index\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqlskills.com\/blogs\/bobb\/sql-server-denali-the-new-autogrid-spatial-index\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/sql-server-denali-the-new-autogrid-spatial-index\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqlskills.com\/blogs\/bobb\/"},{"@type":"ListItem","position":2,"name":"SQL Server 2012","item":"https:\/\/www.sqlskills.com\/blogs\/bobb\/category\/sql-server-2012\/"},{"@type":"ListItem","position":3,"name":"SQL Server Denali &#8211; the new autogrid spatial index"}]},{"@type":"WebSite","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#website","url":"https:\/\/www.sqlskills.com\/blogs\/bobb\/","name":"Bob Beauchemin","description":"SQL Server Blog","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sqlskills.com\/blogs\/bobb\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/62bfa986c5b5d28fcffd8b4fc409c73e","name":"Bob Beauchemin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/6f80e6cc667410857fa6a21931dc528b8092f4d112bf7a8ff7c267674d44ee37?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6f80e6cc667410857fa6a21931dc528b8092f4d112bf7a8ff7c267674d44ee37?s=96&d=mm&r=g","caption":"Bob Beauchemin"},"sameAs":["http:\/www.sqlskills.com\/blogs\/bobb\/"],"url":"https:\/\/www.sqlskills.com\/blogs\/bobb\/author\/bobb\/"}]}},"_links":{"self":[{"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/posts\/576","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/comments?post=576"}],"version-history":[{"count":0,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/posts\/576\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/media?parent=576"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/categories?post=576"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/tags?post=576"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}