{"id":293,"date":"2019-04-27T18:00:23","date_gmt":"2019-04-27T18:00:23","guid":{"rendered":"https:\/\/datablog.roman-halliday.com\/?p=293"},"modified":"2019-06-11T06:18:51","modified_gmt":"2019-06-11T06:18:51","slug":"partitions-in-sql-server-a-collection-of-thoughts","status":"publish","type":"post","link":"https:\/\/datablog.roman-halliday.com\/index.php\/2019\/04\/27\/partitions-in-sql-server-a-collection-of-thoughts\/","title":{"rendered":"Partitions in SQL Server: A collection Of Thoughts"},"content":{"rendered":"<p>Like when I started writing about <a href=\"https:\/\/datablog.roman-halliday.com\/index.php\/2018\/05\/01\/dates-in-sql-server-managing-manipulating-dates\/\">Dates in SQL Server<\/a>, a couple of notes on partitioning has turned into a series&#8230; And not one I&#8217;m so happy with (I had a lot to cover and at the same time a lack of a bigger picture direction). Rather than ramble on about aspects of partitioning in numerous posts, I thought I&#8217;d try just summarising some ideas all in one, with a few links to external reading.<\/p>\n<h1>When to partition, and how big?<\/h1>\n<p>Partitioning is as much about managing the data as anything else. In some database architectures, it can improve performance. In SQL Server, partitions don&#8217;t infer performance. I tried to write some &#8220;rule of thumb&#8221; notes, but couldn&#8217;t create anything as useful as this article: <a href=\"https:\/\/www.sqlskills.com\/blogs\/kimberly\/sqlskills-sql101-partitioning\/\">SQLskills SQL101: Partitioning<\/a> (Kimberly L. Tripp).<\/p>\n<p>A key point to note about partitions is the\u00a0limitation on the number of partitions! SQL Server 2017 supports up to 15,000 partitions. Before that, it&#8217;s only 1,000! If you have one a day, you might get in trouble after only a few years.<\/p>\n<h1>Partitioned Tables &amp; Views<\/h1>\n<p>Often, to get around the limit in the available number of partitions, or the fact that outside of enterprise SQL Server partitions weren&#8217;t a thing. Developers created partitioned views. Effectively, multiple tables (each representing a partition) and sticking them together using views.<\/p>\n<ul>\n<li><a href=\"https:\/\/www.itprotoday.com\/partitioned-tables-v-partitioned-views-why-are-they-even-still-around\">Partitioned Tables v. Partitioned Views\u2013Why are they even still around?<\/a><\/li>\n<\/ul>\n<h1>Truncating &amp; Moving Partitions<\/h1>\n<p>One key advantage of partitions is that they can be moved\/switched. This allows a simple (and fast) statement to be executed, but doing a large movement of data. A key use for this is archiving (or dropping) partitions with minimum overhead on the table. See these links:<\/p>\n<ul>\n<li><a href=\"https:\/\/www.mssqltips.com\/sqlservertip\/4436\/sql-server-2016-truncate-table-with-partitions\/\">SQL Server 2016 Truncate Table with Partitions<\/a><\/li>\n<li><a href=\"https:\/\/www.cathrinewilhelmsen.net\/2015\/04\/19\/table-partitioning-in-sql-server-partition-switching\/\">Table Partitioning in SQL Server \u2013 Partition Switching<\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Like when I started writing about Dates in SQL Server, a couple of notes on partitioning has turned into a series&#8230; And not one I&#8217;m so happy with (I had a lot to cover and at the same time a lack of a bigger picture direction). Rather than ramble on about aspects of partitioning in&hellip;<\/p>\n<p class=\"read-more\"><a class=\"readmore-btn\" href=\"https:\/\/datablog.roman-halliday.com\/index.php\/2019\/04\/27\/partitions-in-sql-server-a-collection-of-thoughts\/\">Read More<span class=\"screen-reader-text\">  Read More<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,4],"tags":[24],"class_list":["post-293","post","type-post","status-publish","format-standard","hentry","category-databases","category-sql-server","tag-partition"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Partitions in SQL Server: A collection Of Thoughts - Rows Across The Lake<\/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:\/\/datablog.roman-halliday.com\/index.php\/2019\/04\/27\/partitions-in-sql-server-a-collection-of-thoughts\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Partitions in SQL Server: A collection Of Thoughts - Rows Across The Lake\" \/>\n<meta property=\"og:description\" content=\"Like when I started writing about Dates in SQL Server, a couple of notes on partitioning has turned into a series&#8230; And not one I&#8217;m so happy with (I had a lot to cover and at the same time a lack of a bigger picture direction). Rather than ramble on about aspects of partitioning in&hellip;Read More Read More\" \/>\n<meta property=\"og:url\" content=\"https:\/\/datablog.roman-halliday.com\/index.php\/2019\/04\/27\/partitions-in-sql-server-a-collection-of-thoughts\/\" \/>\n<meta property=\"og:site_name\" content=\"Rows Across The Lake\" \/>\n<meta property=\"article:published_time\" content=\"2019-04-27T18:00:23+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-06-11T06:18:51+00:00\" \/>\n<meta name=\"author\" content=\"david\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@d_roman_h\" \/>\n<meta name=\"twitter:site\" content=\"@d_roman_h\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"david\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/datablog.roman-halliday.com\\\/index.php\\\/2019\\\/04\\\/27\\\/partitions-in-sql-server-a-collection-of-thoughts\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/datablog.roman-halliday.com\\\/index.php\\\/2019\\\/04\\\/27\\\/partitions-in-sql-server-a-collection-of-thoughts\\\/\"},\"author\":{\"name\":\"david\",\"@id\":\"https:\\\/\\\/datablog.roman-halliday.com\\\/#\\\/schema\\\/person\\\/575f96d2590c3085923ff9e1b565748b\"},\"headline\":\"Partitions in SQL Server: A collection Of Thoughts\",\"datePublished\":\"2019-04-27T18:00:23+00:00\",\"dateModified\":\"2019-06-11T06:18:51+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/datablog.roman-halliday.com\\\/index.php\\\/2019\\\/04\\\/27\\\/partitions-in-sql-server-a-collection-of-thoughts\\\/\"},\"wordCount\":309,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/datablog.roman-halliday.com\\\/#\\\/schema\\\/person\\\/575f96d2590c3085923ff9e1b565748b\"},\"keywords\":[\"partition\"],\"articleSection\":[\"Databases\",\"SQL Server\"],\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/datablog.roman-halliday.com\\\/index.php\\\/2019\\\/04\\\/27\\\/partitions-in-sql-server-a-collection-of-thoughts\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/datablog.roman-halliday.com\\\/index.php\\\/2019\\\/04\\\/27\\\/partitions-in-sql-server-a-collection-of-thoughts\\\/\",\"url\":\"https:\\\/\\\/datablog.roman-halliday.com\\\/index.php\\\/2019\\\/04\\\/27\\\/partitions-in-sql-server-a-collection-of-thoughts\\\/\",\"name\":\"Partitions in SQL Server: A collection Of Thoughts - Rows Across The Lake\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/datablog.roman-halliday.com\\\/#website\"},\"datePublished\":\"2019-04-27T18:00:23+00:00\",\"dateModified\":\"2019-06-11T06:18:51+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/datablog.roman-halliday.com\\\/index.php\\\/2019\\\/04\\\/27\\\/partitions-in-sql-server-a-collection-of-thoughts\\\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/datablog.roman-halliday.com\\\/index.php\\\/2019\\\/04\\\/27\\\/partitions-in-sql-server-a-collection-of-thoughts\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/datablog.roman-halliday.com\\\/index.php\\\/2019\\\/04\\\/27\\\/partitions-in-sql-server-a-collection-of-thoughts\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/datablog.roman-halliday.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Partitions in SQL Server: A collection Of Thoughts\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/datablog.roman-halliday.com\\\/#website\",\"url\":\"https:\\\/\\\/datablog.roman-halliday.com\\\/\",\"name\":\"Rows Across The Lake\",\"description\":\"Data &amp; Databases\",\"publisher\":{\"@id\":\"https:\\\/\\\/datablog.roman-halliday.com\\\/#\\\/schema\\\/person\\\/575f96d2590c3085923ff9e1b565748b\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/datablog.roman-halliday.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-GB\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/datablog.roman-halliday.com\\\/#\\\/schema\\\/person\\\/575f96d2590c3085923ff9e1b565748b\",\"name\":\"david\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/acddbc676a1d5c73795edcf0627ee39e5aa947da9033b58373e03d93122cb3b7?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/acddbc676a1d5c73795edcf0627ee39e5aa947da9033b58373e03d93122cb3b7?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/acddbc676a1d5c73795edcf0627ee39e5aa947da9033b58373e03d93122cb3b7?s=96&d=mm&r=g\",\"caption\":\"david\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/acddbc676a1d5c73795edcf0627ee39e5aa947da9033b58373e03d93122cb3b7?s=96&d=mm&r=g\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Partitions in SQL Server: A collection Of Thoughts - Rows Across The Lake","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:\/\/datablog.roman-halliday.com\/index.php\/2019\/04\/27\/partitions-in-sql-server-a-collection-of-thoughts\/","og_locale":"en_GB","og_type":"article","og_title":"Partitions in SQL Server: A collection Of Thoughts - Rows Across The Lake","og_description":"Like when I started writing about Dates in SQL Server, a couple of notes on partitioning has turned into a series&#8230; And not one I&#8217;m so happy with (I had a lot to cover and at the same time a lack of a bigger picture direction). Rather than ramble on about aspects of partitioning in&hellip;Read More Read More","og_url":"https:\/\/datablog.roman-halliday.com\/index.php\/2019\/04\/27\/partitions-in-sql-server-a-collection-of-thoughts\/","og_site_name":"Rows Across The Lake","article_published_time":"2019-04-27T18:00:23+00:00","article_modified_time":"2019-06-11T06:18:51+00:00","author":"david","twitter_card":"summary_large_image","twitter_creator":"@d_roman_h","twitter_site":"@d_roman_h","twitter_misc":{"Written by":"david","Estimated reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/datablog.roman-halliday.com\/index.php\/2019\/04\/27\/partitions-in-sql-server-a-collection-of-thoughts\/#article","isPartOf":{"@id":"https:\/\/datablog.roman-halliday.com\/index.php\/2019\/04\/27\/partitions-in-sql-server-a-collection-of-thoughts\/"},"author":{"name":"david","@id":"https:\/\/datablog.roman-halliday.com\/#\/schema\/person\/575f96d2590c3085923ff9e1b565748b"},"headline":"Partitions in SQL Server: A collection Of Thoughts","datePublished":"2019-04-27T18:00:23+00:00","dateModified":"2019-06-11T06:18:51+00:00","mainEntityOfPage":{"@id":"https:\/\/datablog.roman-halliday.com\/index.php\/2019\/04\/27\/partitions-in-sql-server-a-collection-of-thoughts\/"},"wordCount":309,"commentCount":0,"publisher":{"@id":"https:\/\/datablog.roman-halliday.com\/#\/schema\/person\/575f96d2590c3085923ff9e1b565748b"},"keywords":["partition"],"articleSection":["Databases","SQL Server"],"inLanguage":"en-GB","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/datablog.roman-halliday.com\/index.php\/2019\/04\/27\/partitions-in-sql-server-a-collection-of-thoughts\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/datablog.roman-halliday.com\/index.php\/2019\/04\/27\/partitions-in-sql-server-a-collection-of-thoughts\/","url":"https:\/\/datablog.roman-halliday.com\/index.php\/2019\/04\/27\/partitions-in-sql-server-a-collection-of-thoughts\/","name":"Partitions in SQL Server: A collection Of Thoughts - Rows Across The Lake","isPartOf":{"@id":"https:\/\/datablog.roman-halliday.com\/#website"},"datePublished":"2019-04-27T18:00:23+00:00","dateModified":"2019-06-11T06:18:51+00:00","breadcrumb":{"@id":"https:\/\/datablog.roman-halliday.com\/index.php\/2019\/04\/27\/partitions-in-sql-server-a-collection-of-thoughts\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/datablog.roman-halliday.com\/index.php\/2019\/04\/27\/partitions-in-sql-server-a-collection-of-thoughts\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/datablog.roman-halliday.com\/index.php\/2019\/04\/27\/partitions-in-sql-server-a-collection-of-thoughts\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/datablog.roman-halliday.com\/"},{"@type":"ListItem","position":2,"name":"Partitions in SQL Server: A collection Of Thoughts"}]},{"@type":"WebSite","@id":"https:\/\/datablog.roman-halliday.com\/#website","url":"https:\/\/datablog.roman-halliday.com\/","name":"Rows Across The Lake","description":"Data &amp; Databases","publisher":{"@id":"https:\/\/datablog.roman-halliday.com\/#\/schema\/person\/575f96d2590c3085923ff9e1b565748b"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/datablog.roman-halliday.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-GB"},{"@type":["Person","Organization"],"@id":"https:\/\/datablog.roman-halliday.com\/#\/schema\/person\/575f96d2590c3085923ff9e1b565748b","name":"david","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/secure.gravatar.com\/avatar\/acddbc676a1d5c73795edcf0627ee39e5aa947da9033b58373e03d93122cb3b7?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/acddbc676a1d5c73795edcf0627ee39e5aa947da9033b58373e03d93122cb3b7?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/acddbc676a1d5c73795edcf0627ee39e5aa947da9033b58373e03d93122cb3b7?s=96&d=mm&r=g","caption":"david"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/acddbc676a1d5c73795edcf0627ee39e5aa947da9033b58373e03d93122cb3b7?s=96&d=mm&r=g"}}]}},"_links":{"self":[{"href":"https:\/\/datablog.roman-halliday.com\/index.php\/wp-json\/wp\/v2\/posts\/293","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/datablog.roman-halliday.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/datablog.roman-halliday.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/datablog.roman-halliday.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/datablog.roman-halliday.com\/index.php\/wp-json\/wp\/v2\/comments?post=293"}],"version-history":[{"count":4,"href":"https:\/\/datablog.roman-halliday.com\/index.php\/wp-json\/wp\/v2\/posts\/293\/revisions"}],"predecessor-version":[{"id":303,"href":"https:\/\/datablog.roman-halliday.com\/index.php\/wp-json\/wp\/v2\/posts\/293\/revisions\/303"}],"wp:attachment":[{"href":"https:\/\/datablog.roman-halliday.com\/index.php\/wp-json\/wp\/v2\/media?parent=293"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/datablog.roman-halliday.com\/index.php\/wp-json\/wp\/v2\/categories?post=293"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/datablog.roman-halliday.com\/index.php\/wp-json\/wp\/v2\/tags?post=293"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}