Table Partitioning Intro and make that a sliding window too! Using SQL Server
About Me Jeff Reinhard 20+ years database development experience @SQLMajor Jeff@Reinhard.com Employment Highlights: Ernst & Young Internet Security Systems/IBM AirWatch WebMD CheckFree 2 | 4/3/2019 | Sliding Window Table Partition Intro
Agenda What is Partitioning? Why use Partitioning? The 4 main steps The Sliding window Add new partitions (switching in) Switch Out old partition Demo to see the magic 3 | 4/3/2019 | Sliding Window Table Partition Intro
Agenda What is Partitioning? Why use Partitioning? The 4 main steps The Sliding window Add new partitions (switching in) Switch Out old partition Demo to see the magic 4 | 4/3/2019 | Sliding Window Table Partition Intro
What is partitioning? Enterprise Edition only First Available in 2005 5 | 4/3/2019 | Sliding Window Table Partition Intro
What is partitioning? The data in partitioned tables and indexes are horizontally divided into units that can be spread across more than one filegroup in a database. Aligns the data in the clustered and non-clustered indexes with the partition key. 6 | 4/3/2019 | Sliding Window Table Partition Intro
What is partitioning? Before partitioned example 7 | 4/3/2019 | 7 | 4/3/2019 | Sliding Window Table Partition Intro
What is partitioning? After partitioning example 8 | 4/3/2019 | 8 | 4/3/2019 | Sliding Window Table Partition Intro
Agenda What is Partitioning? Why use Partitioning? The 4 main steps The Sliding window Add new partitions (switching in) Switch Out old partition Demo to see the magic 9 | 4/3/2019 | Sliding Window Table Partition Intro
Why Partition? Improved read performance Loading large amounts of data in batch Easier and faster archiving and purging Partitioning can make large tables and indexes more manageable and scalable Partition elimination and aligned indexes Load into separate table then switch into partitioned table Switching partitions out and switching into other table By having smaller structures 10 | 4/3/2019 | Sliding Window Table Partition Intro
Agenda What is Partitioning? Why use Partitioning The 4 main steps The Sliding window Add new partitions (switching in) Switch Out old partition Demo to see the magic 11 | 4/3/2019 | Sliding Window Table Partition Intro
The Four main steps - Overview Create a filegroup or filegroups Create a partition function Create a partition scheme Create or modify a table or index and specify the partition scheme as the storage location. 12 | 4/3/2019 | Sliding Window Table Partition Intro
Step 1: File Groups Static file groups can require less frequent backups Can put some on slower storage, others on faster May need to honor space restrictions of drive sizes for SAN, OS or backups Sliding partitions and staging tables must be on same file group 13 | 4/3/2019 | Sliding Window Table Partition Intro
Step 2: Function Uses the 1 column chosen to be the key Defines ranges and boundaries to separate data Uses specific values It can be dynamic and change over time, adding new partitions 14 | 4/3/2019 | Sliding Window Table Partition Intro
Step 2: Function example CREATE PARTITION FUNCTION [pfSample](datetime) AS RANGE LEFT FOR VALUES (1, 100, 1000); A function must cover all data: from minus infinity to infinity. 15 | 4/3/2019 | Sliding Window Table Partition Intro
Step 3: Scheme Maps functions to file groups Can do one partition per file group Can map multiple partitions to each file group Can map all partitions to the same file group 16 | 4/3/2019 | Sliding Window Table Partition Intro
Step 4: Set scheme as storage Drop all indexes Alter table using scheme This moves the data into the partition Add back clustered and non clustered indexes using scheme (to align) 17 | 4/3/2019 | Sliding Window Table Partition Intro
Agenda What is Partitioning? Why use Partitioning The 4 main steps The Sliding window Add new partitions (switching in) Switch Out old partition Demo to see the magic 18 | 4/3/2019 | Sliding Window Table Partition Intro
Sliding Window Good use case is for date ranges of data to keep online Add new date partitions in Switch out old partitions to archive or purge 19 | 4/3/2019 | Sliding Window Table Partition Intro
Agenda What is Partitioning? Why use Partitioning The 4 main steps The Sliding window Add new partitions (switching in) Switch Out old partition Demo to see the magic 20 | 4/3/2019 | Sliding Window Table Partition Intro
Demonstration 4/3/2019 | Sliding Window Table Partition Intro
Demo Review We picked a table and strategy Did the 4 step shuffle File Group and File Create partition function Create partition scheme Set scheme as storage The Rolling window Add new partitions Switch out old partition 22 | 4/3/2019 | Sliding Window Table Partition Intro
Resources Best Practices Partitioning Concepts CodePlex https://msdn.microsoft.com/en-us/library/ms190787.aspx CodePlex https://sqlpartitionmgmt.codeplex.com Tool to help manage and script sliding window partitioning Best Practices https://technet.microsoft.com/en-us/library/cc966380.aspx 23 | 4/3/2019 | Sliding Window Table Partition Intro
Questions? Thank you 4/3/2019 | Sliding Window Table Partition Intro