{"id":917,"date":"2018-05-11T09:13:54","date_gmt":"2018-05-11T16:13:54","guid":{"rendered":"http:\/\/3.209.169.194\/blogs\/erin\/?p=917"},"modified":"2018-05-14T18:38:56","modified_gmt":"2018-05-15T01:38:56","slug":"do-you-need-to-update-statistics-after-an-upgrade","status":"publish","type":"post","link":"https:\/\/www.sqlskills.com\/blogs\/erin\/do-you-need-to-update-statistics-after-an-upgrade\/","title":{"rendered":"Do you need to update statistics after an upgrade?"},"content":{"rendered":"<p><span style=\"color: #3366ff;\">This post originally went live on May 11, 2018, but modifications were made on May 14, 2018 after some additional internal discussions with Microsoft.\u00a0 Changes made on May 14, 2018 are in blue.\u00a0\u00a0<\/span><\/p>\n<p>There are a variety of methods we use for helping customers upgrade to a new SQL Server version, and one question we often get asked is whether or not statistics need to be updated as part of the upgrade process.<\/p>\n<p>tl;dr<\/p>\n<p><strong><em>Yes.\u00a0 Update statistics after an upgrade.\u00a0<\/em><\/strong> Further, if you\u2019re upgrading to 2012 or higher from an earlier version, you should rebuild your indexes (which will update index statistics, so then you just need to update column statistics).<\/p>\n<p><strong>History<\/strong><\/p>\n<p>Some of you may remember that the stats blob changed between SQL Server 2000 and SQL Server 2005, and Microsoft specifically recommended updating statistics after upgrading from SQL Server 2000.\u00a0 Official Microsoft documentation about the stats blog change in SQL Server 2005 is difficult to find, but <a href=\"https:\/\/docs.microsoft.com\/en-us\/previous-versions\/sql\/sql-server-2008-r2\/bb933942(v=sql.105)\">this article<\/a> includes the following paragraph:<\/p>\n<blockquote><p>After you upgrade from SQL Server 2000, update statistics on all databases. Use the\u00a0<a href=\"https:\/\/docs.microsoft.com\/en-us\/previous-versions\/sql\/sql-server-2008-r2\/ms173804%28v%3dsql.105%29\">sp_updatestats<\/a>\u00a0stored procedure to update statistics in user-defined tables in SQL Server\u00a0databases. This step is not necessary for upgrading from SQL Server 2005.<\/p><\/blockquote>\n<p><a href=\"https:\/\/docs.microsoft.com\/en-us\/sql\/database-engine\/install-windows\/complete-the-database-engine-upgrade?view=sql-server-2017\">Current Microsoft documentation related to upgrading<\/a> does not state anything specific about updating statistics, but people continue to ask and if you peruse forums, blog posts, and other social media options, you\u2019ll see recommendations to update statistics.\u00a0 <span style=\"color: #3366ff;\">Further, the documentation that Microsoft provides about\u00a0<a style=\"color: #3366ff;\" href=\"https:\/\/docs.microsoft.com\/en-us\/sql\/relational-databases\/statistics\/statistics#UpdateStatistics\"><em>when<\/em><\/a><a style=\"color: #3366ff;\" href=\"https:\/\/docs.microsoft.com\/en-us\/sql\/relational-databases\/statistics\/statistics#UpdateStatistics\"><span style=\"color: #3366ff;\"> t<\/span>o update statistics<\/a> does not mention anything about upgrades.<\/span><\/p>\n<p><em><strong>Side bar:<\/strong> I don\u2019t recommend using sp_updatestats, and here\u2019s why: <a href=\"https:\/\/sqlperformance.com\/2013\/07\/sql-statistics\/statistics-updates\">Understanding What sp_updatestats Really Updates<\/a>.<\/em><\/p>\n<p><strong>Today<\/strong><\/p>\n<p>The statistics blob has not changed since SQL Server 2000 to my knowledge, but I thought I would ask someone from Microsoft for an official recommendation to share publicly.\u00a0 Here you go:<\/p>\n<p style=\"padding-left: 30px;\"><strong><em>Microsoft suggests that customers\u00a0<span style=\"color: #3366ff;\">test the need for<\/span> a full update of statistics after a major version change and\/or a database compatibility level change.<\/em><\/strong><\/p>\n<p>Further items to note:<\/p>\n<ol>\n<li>If Microsoft updates the format of statistics (e.g. the stats blog), customers will be expected to update statistics after an upgrade.\n<ol>\n<li>Microsoft does not always upgrade the statistics format as part of a major version upgrade.<\/li>\n<\/ol>\n<\/li>\n<li>There are occasions where Microsoft does not change the format of statistics, but they do <em>change the algorithm for creating statistics<\/em> as part of a major version upgrade or database compatibility level change.<\/li>\n<\/ol>\n<p>In addition, there was a change in the nonclustered leaf level internals in SQL Server 2012, so if you are upgrading to 2012 or higher from an earlier version (e.g. 2008, 2008R2), rebuild your nonclustered indexes.\u00a0 And remember, rebuilding indexes updates the statistics for those indexes with a fullscan, so you do not need to update them again.<\/p>\n<p><strong>Conclusion<\/strong><\/p>\n<p>As part of your upgrade methodology, it is recommended <span style=\"color: #3366ff;\">(by me, based on experience with <em>a lot<\/em> of customer upgrades)<\/span> to build in time to update statistics.\u00a0 I\u2019ve gotten some pushback from customers who don\u2019t want to update statistics after upgrade because it takes too long.\u00a0 Some kind reminders:<\/p>\n<ul>\n<li>Updating statistics is an online operation, therefore, the database and related applications are accessible and usable. A statistics update does take a schema modification lock so you\u2019re not allowed to make any changes to a table while its stats are updating.\u00a0 Therefore, if you decide to change your schema after upgrading your SQL Server version (not something I would typically recommend), do that before you update stats.<\/li>\n<li>You need to update statistics regularly to provide the optimizer with current information about your data, so at some point it needs to be done. Immediately after an upgrade is a really good time, considering the aforementioned items.<\/li>\n<\/ul>\n<p>If you\u2019re not comfortable upgrading to a newer version of SQL Server, <a href=\"https:\/\/www.sqlskills.com\/contact-us\/\">we can help<\/a>!\u00a0 I\u2019m in the process of helping a customer migrate from SQL Server 2012 to SQL Server 2017, and I\u2019m so excited to get them up to the latest version so they can start using some new features\u2026like Query Store &#x1f609;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This post originally went live on May 11, 2018, but modifications were made on May 14, 2018 after some additional internal discussions with Microsoft.\u00a0 Changes made on May 14, 2018 are in blue.\u00a0\u00a0 There are a variety of methods we use for helping customers upgrade to a new SQL Server version, and one question we [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15,17,43],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.9.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Do you need to update statistics after an upgrade? - Erin Stellato<\/title>\n<meta name=\"description\" content=\"You do need to update statistics after an upgrade to a newer version of SQL Server, and in this post we&#039;ll talk about why.\" \/>\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\/erin\/do-you-need-to-update-statistics-after-an-upgrade\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Do you need to update statistics after an upgrade? - Erin Stellato\" \/>\n<meta property=\"og:description\" content=\"You do need to update statistics after an upgrade to a newer version of SQL Server, and in this post we&#039;ll talk about why.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqlskills.com\/blogs\/erin\/do-you-need-to-update-statistics-after-an-upgrade\/\" \/>\n<meta property=\"og:site_name\" content=\"Erin Stellato\" \/>\n<meta property=\"article:published_time\" content=\"2018-05-11T16:13:54+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-05-15T01:38:56+00:00\" \/>\n<meta name=\"author\" content=\"Erin Stellato\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Erin Stellato\" \/>\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\/erin\/do-you-need-to-update-statistics-after-an-upgrade\/\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/erin\/do-you-need-to-update-statistics-after-an-upgrade\/\",\"name\":\"Do you need to update statistics after an upgrade? - Erin Stellato\",\"isPartOf\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/erin\/#website\"},\"datePublished\":\"2018-05-11T16:13:54+00:00\",\"dateModified\":\"2018-05-15T01:38:56+00:00\",\"author\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/erin\/#\/schema\/person\/76170223ffffa1df03fd9be5b66cb158\"},\"description\":\"You do need to update statistics after an upgrade to a newer version of SQL Server, and in this post we'll talk about why.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/erin\/do-you-need-to-update-statistics-after-an-upgrade\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.sqlskills.com\/blogs\/erin\/do-you-need-to-update-statistics-after-an-upgrade\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/erin\/do-you-need-to-update-statistics-after-an-upgrade\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.sqlskills.com\/blogs\/erin\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Do you need to update statistics after an upgrade?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/erin\/#website\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/erin\/\",\"name\":\"Erin Stellato\",\"description\":\"The SQL Sequel\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.sqlskills.com\/blogs\/erin\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/erin\/#\/schema\/person\/76170223ffffa1df03fd9be5b66cb158\",\"name\":\"Erin Stellato\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/erin\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/0c8b485bd54ea26b57e99f79b525f409?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/0c8b485bd54ea26b57e99f79b525f409?s=96&d=mm&r=g\",\"caption\":\"Erin Stellato\"},\"sameAs\":[\"http:\/\/3.209.169.194\/blogs\/erin\"],\"url\":\"https:\/\/www.sqlskills.com\/blogs\/erin\/author\/erin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Do you need to update statistics after an upgrade? - Erin Stellato","description":"You do need to update statistics after an upgrade to a newer version of SQL Server, and in this post we'll talk about why.","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\/erin\/do-you-need-to-update-statistics-after-an-upgrade\/","og_locale":"en_US","og_type":"article","og_title":"Do you need to update statistics after an upgrade? - Erin Stellato","og_description":"You do need to update statistics after an upgrade to a newer version of SQL Server, and in this post we'll talk about why.","og_url":"https:\/\/www.sqlskills.com\/blogs\/erin\/do-you-need-to-update-statistics-after-an-upgrade\/","og_site_name":"Erin Stellato","article_published_time":"2018-05-11T16:13:54+00:00","article_modified_time":"2018-05-15T01:38:56+00:00","author":"Erin Stellato","twitter_misc":{"Written by":"Erin Stellato","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.sqlskills.com\/blogs\/erin\/do-you-need-to-update-statistics-after-an-upgrade\/","url":"https:\/\/www.sqlskills.com\/blogs\/erin\/do-you-need-to-update-statistics-after-an-upgrade\/","name":"Do you need to update statistics after an upgrade? - Erin Stellato","isPartOf":{"@id":"https:\/\/www.sqlskills.com\/blogs\/erin\/#website"},"datePublished":"2018-05-11T16:13:54+00:00","dateModified":"2018-05-15T01:38:56+00:00","author":{"@id":"https:\/\/www.sqlskills.com\/blogs\/erin\/#\/schema\/person\/76170223ffffa1df03fd9be5b66cb158"},"description":"You do need to update statistics after an upgrade to a newer version of SQL Server, and in this post we'll talk about why.","breadcrumb":{"@id":"https:\/\/www.sqlskills.com\/blogs\/erin\/do-you-need-to-update-statistics-after-an-upgrade\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqlskills.com\/blogs\/erin\/do-you-need-to-update-statistics-after-an-upgrade\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqlskills.com\/blogs\/erin\/do-you-need-to-update-statistics-after-an-upgrade\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqlskills.com\/blogs\/erin\/"},{"@type":"ListItem","position":2,"name":"Do you need to update statistics after an upgrade?"}]},{"@type":"WebSite","@id":"https:\/\/www.sqlskills.com\/blogs\/erin\/#website","url":"https:\/\/www.sqlskills.com\/blogs\/erin\/","name":"Erin Stellato","description":"The SQL Sequel","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sqlskills.com\/blogs\/erin\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.sqlskills.com\/blogs\/erin\/#\/schema\/person\/76170223ffffa1df03fd9be5b66cb158","name":"Erin Stellato","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sqlskills.com\/blogs\/erin\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/0c8b485bd54ea26b57e99f79b525f409?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/0c8b485bd54ea26b57e99f79b525f409?s=96&d=mm&r=g","caption":"Erin Stellato"},"sameAs":["http:\/\/3.209.169.194\/blogs\/erin"],"url":"https:\/\/www.sqlskills.com\/blogs\/erin\/author\/erin\/"}]}},"_links":{"self":[{"href":"https:\/\/www.sqlskills.com\/blogs\/erin\/wp-json\/wp\/v2\/posts\/917"}],"collection":[{"href":"https:\/\/www.sqlskills.com\/blogs\/erin\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sqlskills.com\/blogs\/erin\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/erin\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/erin\/wp-json\/wp\/v2\/comments?post=917"}],"version-history":[{"count":0,"href":"https:\/\/www.sqlskills.com\/blogs\/erin\/wp-json\/wp\/v2\/posts\/917\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sqlskills.com\/blogs\/erin\/wp-json\/wp\/v2\/media?parent=917"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/erin\/wp-json\/wp\/v2\/categories?post=917"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/erin\/wp-json\/wp\/v2\/tags?post=917"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}