SQL Server 2005 – Table Partitioning Chad Gronbach Microsoft.

Slides:



Advertisements
Similar presentations
Yukon – What is New Rajesh Gala. Yukon – What is new.NET Framework Programming Data Types Exception Handling Batches Databases Database Engine Administration.
Advertisements

Tuning: overview Rewrite SQL (Leccotech)Leccotech Create Index Redefine Main memory structures (SGA in Oracle) Change the Block Size Materialized Views,
CHAPTER OBJECTIVE: NORMALIZATION THE SNOWFLAKE SCHEMA.
Big Data Working with Terabytes in SQL Server Andrew Novick
SQL Server 2005 features for VLDBs. SQL Server 2005 features for VLDBs aka (it’s fixed in the next release)
Tables Lesson 6. Skills Matrix Tables Tables store data. Tables are relational –They store data organized as row and columns. –Data can be retrieved.
Module 6 Implementing Table Structures in SQL Server ®2008 R2.
Introduction to Structured Query Language (SQL)
A Guide to MySQL 7. 2 Objectives Understand, define, and drop views Recognize the benefits of using views Use a view to update data Grant and revoke users’
Transaction log grows unexpectedly
Architecting a Large-Scale Data Warehouse with SQL Server 2005 Mark Morton Senior Technical Consultant IT Training Solutions DAT313.
Dual Partitioning for improved performance in VLDBs Ashwin Rao Karavadi, Rakesh Parida Microsoft IT.
Database Constraints. Database constraints are restrictions on the contents of the database or on database operations Database constraints provide a way.
Building Highly Available Systems with SQL Server™ 2005 Robert Rea Brandon Consulting.
1  MyOnlineITCourses.com 1 MyOnlineITCourses.com Oracle Partitioning -- A Primer.
Module 9: Managing Schema Objects. Overview Naming guidelines for identifiers in schema object definitions Storage and structure of schema objects Implementing.
Building Highly Available Systems with SQL Server™ 2005 Vineet Gupta Evangelist – Data and Integration Microsoft Corp.
SQL Server 2008 Implementation and Maintenance Chapter 7: Performing Backups and Restores.
Exam QUESTION CertKiller.com has hired you as a database administrator for their network. Your duties include administering the SQL Server 2008.
Practical Database Design and Tuning. Outline  Practical Database Design and Tuning Physical Database Design in Relational Databases An Overview of Database.
DAY 15: ACCESS CHAPTER 2 Larry Reaves October 7,
ISV Innovation Presented by ISV Innovation Presented by Business Intelligence Fundamentals: Data Loading Ola Ekdahl IT Mentors 9/12/08.
Sofia, Bulgaria | 9-10 October SQL Server 2005 High Availability for developers Vladimir Tchalkov Crossroad Ltd. Vladimir Tchalkov Crossroad Ltd.
Physical Database Design & Performance. Optimizing for Query Performance For DBs with high retrieval traffic as compared to maintenance traffic, optimizing.
Extents, segments and blocks in detail. Database structure Database Table spaces Segment Extent Oracle block O/S block Data file logical physical.
© 2010 IBM Corporation September 9, 2010 IDS 11.7 – New Fragmentation Strategies Scott Pickett – WW Informix Technical Sales For questions about this presentation.
1 Chapter 14 DML Tuning. 2 DML Performance Fundamentals DML Performance is affected by: – Efficiency of WHERE clause – Amount of index maintenance – Referential.
Partitioning Design For Performance and Maintainability Martin Cairns
Module 16: Performing Ongoing Database Maintenance
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
7 1 Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
Database Snapshot By: Mahta Woldeselassie Julian Bester.
M1G Introduction to Database Development 5. Doing more with queries.
Database structure and space Management. Database Structure An ORACLE database has both a physical and logical structure. By separating physical and logical.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Indexes / Session 2/ 1 of 36 Session 2 Module 3: Types of Indexes Module 4: Maintaining Indexes.
Week 7 : Chapter 7 Agenda SQL 710 Maintenance Plan:
SQL Server 2005 – Table Partitioning Vinod Kumar Intel Technology India Pvt. Ltd. MVP – SQL Server
Praveen Srivatsa Director| AstrhaSoft Consulting blogs.asthrasoft.com/praveens |
SQL/Lesson 7/Slide 1 of 32 Implementing Indexes Objectives In this lesson, you will learn to: * Create a clustered index * Create a nonclustered index.
SQLintersection Putting the "Squeeze" on Large Tables Improve Performance and Save Space with Data Compression Justin Randall Tuesday,
Physical Database Design Purpose- translate the logical description of data into the technical specifications for storing and retrieving data Goal - create.
Connect with life Vinod Kumar Technology Evangelist - Microsoft
Chapter 5 Index and Clustering
Session 1 Module 1: Introduction to Data Integrity
Creating Indexes on Tables An index provides quick access to data in a table, based on the values in specified columns. A table can have more than one.
Data Management Conference Performance & Scalability Simon Sabin London September 29th.
Danny Tambs – Senior Consultant Microsoft.
1 CS 430 Database Theory Winter 2005 Lecture 13: SQL DML - Modifying Data.
Best Practices in Loading Large Datasets Asanka Padmakumara (BSc,MCTS) SQL Server Sri Lanka User Group Meeting Oct 2013.
Praveen Srivatsa Director| AstrhaSoft Consulting blogs.asthrasoft.com/praveens |
Backing Up and Restoring Databases Advanced Database Dr. AlaaEddin Almabhouh.
# CCNZ What is going on here???
SQL Basics Review Reviewing what we’ve learned so far…….
SQL IMPLEMENTATION & ADMINISTRATION Indexing & Views.
Introduction to Partitioning in SQL Server
Antonio Abalos Castillo
Designing Database Solutions for SQL Server
Introduction to SQL Server Management for the Non-DBA
The Ins and Outs of Partitioned Tables
Introduction to partitioning
Practical Database Design and Tuning
Table Partitioning Intro and make that a sliding window too!
Microsoft SQL Server 2014 for Oracle DBAs Module 7
Table Partitioning Intro and make that a sliding window too!
Table Partitioning Intro and make that a sliding window too!
IST 318 Database Administration
Partition Switching Joe Tempel.
Using Columnstore indexes in Azure DevOps Services. Lessons learned
Using Columnstore indexes in Azure DevOps Services. Lessons learned
Presentation transcript:

SQL Server 2005 – Table Partitioning Chad Gronbach Microsoft

Types of Partitioning in Database Designs Application-managed partitioning Data is divided among multiple tables or across servers Data is divided among multiple tables or across servers Application decides where to direct specific queries at execution time Application decides where to direct specific queries at execution time Partition Views ‘UNION’ Views link tables within or across databases and servers (DPVs) ‘UNION’ Views link tables within or across databases and servers (DPVs) Partitioned Tables and Indexes New in SQL Server 2005 New in SQL Server 2005 Applies to objects in a single database and instance Applies to objects in a single database and instance Focus of this talk! Focus of this talk!

Partitioned Tables and Indexes Split tables and indexes into multiple storage objects based on the value of a data column Based on range of a single column’s value Based on range of a single column’s value Still treated as single object by the relational engine Handled as multiple objects by the storage engine Up to 1000 partitions per object supported Up to 1000 partitions per object supported

Partitioning and Storage Customer ID Index Order History Table Nonpartitioned: Filegroup DATA Filegroup IDX Example: Table ORDER HISTORY with a Nonclustered Index on CUSTOMER ID Order History Customer ID Order Date Amount … Order ID

Partitioning and Storage Customer ID Index Partitioned by ORDER DATE: Order Date < ‘ ’ Order Date >= ‘ ’ and Order Date < ‘ ’ Order Date >= ‘ ’ Filegroup DATA_2002 Filegroup DATA_2003 Filegroup DATA_2004 Filegroup IDX_2002 Filegroup IDX_2003 Filegroup IDX_2004 Orders Customer ID Order Date Amount … Order ID Order History Customer ID Order Date Amount … Order ID Order History Table

Benefits of Partitioned Tables Manageability Fast Data Deletion and Data Load Fast Data Deletion and Data Load Piecemeal backup / restore of historical data Piecemeal backup / restore of historical data Partition-wise index management Partition-wise index management Minimize index fragmentation for historically- partitioned tables Minimize index fragmentation for historically- partitioned tables Support alternative storage for historical data Support alternative storage for historical data Performance querying Large Tables Join efficiency Join efficiency Smaller index tree or table scan when querying a single partition Smaller index tree or table scan when querying a single partition Simpler query plans compared to Partition Views Simpler query plans compared to Partition Views

Improvement Over Partition Views Partitioned Table: a single object in query plans Single set of statistics Single set of statistics Smaller plans, faster compilation than Partition Views Smaller plans, faster compilation than Partition Views Auto-parameterization supported Insert / Bulk Insert / BCP fully supported Numerous fine-grained partitions work well Queries may access partitions in parallel Partition is the unit of parallelism Partition is the unit of parallelismBut… Cannot span multiple DBs or instances Potentially use PV or DPVs atop Partitioned Tables Potentially use PV or DPVs atop Partitioned Tables

Partition Building Blocks Objects: Partition Function Partition Scheme Operations: Split Partition Merge Partition Switch Partition

Partition Function Maps ranges of a data type to integer values Defined by specifying boundary points N boundary points define N+1 partitions Partition # Boundary 1Boundary 2Boundary 3Boundary 4

Partition Function DDL CREATE PARTITION FUNCTION annual_range (DATETIME) as RANGE RIGHT for values (-- Partition and earlier ' ',-- Partition ' ',-- Partition ' ',-- Partition ' '-- Partition and later )

Values < <=Values< <=Values< <=Values< <=Values Range Right Datetime Partition Example Partition # Boundary 1Boundary 2Boundary 3Boundary & Earlier 2002 Data 2003 Data 2004 Data 2005 & Later

Partition Function Notes Understand the difference between LEFT and RIGHT Understand the difference between LEFT and RIGHT Use $partition. to query partition function values Best practice: Use RANGE RIGHT for ‘continuous’ data values – more intuitive Use RANGE RIGHT for ‘continuous’ data values – more intuitive Boundary becomes starting point for each range Boundary becomes starting point for each range

Partition Scheme Associates a storage location (Filegroup) with each partition defined by a partition function No requirement to use different filegroups for different partitions Useful for Manageability Useful for Manageability Filegroup-based backup or storage location Filegroup-based backup or storage location Best Practice: Spread all of your Filegroups in a Partition Scheme across as many disk spindles as possible. Rarely want to dedicate separate drives to separate partitions Rarely want to dedicate separate drives to separate partitions

Partition Scheme DDL CREATE PARTITION SCHEME annual_scheme_1 as PARTITION annual_range to (annual_min,-- filegroup for pre-2002 annual_2002,-- filegroup for 2002 annual_2003,-- filegroup for 2003 annual_2004,-- filegroup for 2004 annual_2005)-- filegroup for 2005 and later Create PARTITION SCHEME annual_scheme_2 as PARTITION annual_range ALL to ([PRIMARY])

Range Right Datetime Partition # Boundary 1Boundary 2Boundary 3Boundary & Earlier 2002 Data 2003 Data 2004 Data 2005 & Later Filegroup Annual_Min Filegroup Annual_2002 Filegroup Annual_2003 Filegroup Annual_2004 Filegroup Annual_2005 Partition Function Partition Scheme

Partitioned Tables & Indexes A single column must be selected as the Partitioning Key Partitioned Tables and Indexes are created on Partition Schemes instead of Filegroups All query operations on tables or indexes are transparent to partitioning Different tables and indexes may share common partition functions and schemes Table or Index PartitionScheme PartitionFunction 1 manymany

Table and Index Creation CREATE TABLE Order_History ( Order_ID bigint, Order_Datedatetime, Customer_IDbigint … ) ON Annual_Scheme_1(Order_Date) CREATE INDEX Order_Cust_Idx ON Order_History(Order_ID) ON Annual_Scheme_1(Order_Date)

Index Partitioning Partitioning Key of an Index need not be part of the Index Key SQL 2005 indexes can include columns outside of the btree, at the leaf level only SQL 2005 indexes can include columns outside of the btree, at the leaf level only Essential for partitioning, and also great for covering index scenarios Essential for partitioning, and also great for covering index scenarios If an index uses a similar partition function and same partitioning key as the base table, then the index is “aligned” One-to-one correspondence between data in table and index partition One-to-one correspondence between data in table and index partition All index entries in one partition map to data in a single partition of the base table All index entries in one partition map to data in a single partition of the base table

Aligned Index One-to-one partition correspondence Table Partitions Index Partitions Having all aligned indexes is a best practice

Index Alignment The Good Aligned Indexes are the default Aligned Indexes are the default Partitioning key is automatically added to the index Partitioning key is automatically added to the index Defaults to same partition scheme as the base table Defaults to same partition scheme as the base table The Bad A Non-Aligned Index reduces the manageability benefits of partitioning a large table A Non-Aligned Index reduces the manageability benefits of partitioning a large table Prevent fast Switching of data into / out of table Prevent fast Switching of data into / out of table The Ugly For a UNIQUE or PK Index to be partitioned, the Partitioning Key must be part of the Unique Key For a UNIQUE or PK Index to be partitioned, the Partitioning Key must be part of the Unique Key Otherwise the index will be non-partitioned – and therefore Non-Aligned Otherwise the index will be non-partitioned – and therefore Non-Aligned

Key vs. Alignment Tradeoff Example: A large table of Orders Natural Partitioning Key = Order_Date Natural Partitioning Key = Order_Date Unique Business Key = Order_ID Unique Business Key = Order_ID Design Alternatives: 1. Partition table on Order_Date, Non-Unique, aligned index on Order_ID 2. Partition table on Order_Date a Unique, non-aligned index on Order_ID 3. Design the Order ID to always increase in time, Partition on Order_ID, align table and indexes Best Solution depends on your workload!

Restrict the Partitioning Key in the WHERE clause to reduce # of partitions touched Critical for performance of both large queries and high-volume small queries Critical for performance of both large queries and high-volume small queries Select * from OrderHistory o where … o.date_key between ‘ ’ and ‘ ’ Beware: Restrictions applied via a join will not eliminate partitions Following query will touch all Region partitions: Following query will touch all Region partitions: Select * from Sales s INNER JOIN Region d on d.region_id = s.region_id where … d.Name = ‘Asia’ Resolve by placing restriction on region_id instead Resolve by placing restriction on region_id instead Querying -- Best Practices s.region_id = 7

DEMO: Query Plans Should see a CONSTANT SCAN joined to Partitioned Table or Index Drives partition selection during execution Drives partition selection during execution Constants are the partition numbers based on the predicates Constants are the partition numbers based on the predicates NOTE: Partition Constants are 0-based but the Partition Numbers are 1-based integers! NOTE: Partition Constants are 0-based but the Partition Numbers are 1-based integers! Look for parallel execution when multiple partitions are accessed by a query

Other Query Enhancements Many other operations can be performed “per-partition” Grouping, filtering, projection Grouping, filtering, projection Inserts, updates, deletes Inserts, updates, deletes Create index, bulk insert Create index, bulk insert SQL Server tries to find large groups of operations that can be performed per-partition to improve query performance

DW Partitioning Best Practices Typically partition Fact Tables by Period Easily unload history and load new periods Easily unload history and load new periods Make typical queries more efficient Make typical queries more efficient Partition on a meaningful datetime or integer column that is usually directly restricted in queries, e.g. WHERE Date_key between ‘ ’ and ‘ ’ WHERE Date_key between ‘ ’ and ‘ ’ WHERE Period_key = (month = Feb 2004) WHERE Period_key = (month = Feb 2004) WHERE Year_key = 2004 WHERE Year_key = 2004 Don’t Partition based on a surrogate period key …unless the query application can explicitly restrict the key …unless the query application can explicitly restrict the key Users typically don’t know those keys and can’t constrain them directly in ad-hoc queries Users typically don’t know those keys and can’t constrain them directly in ad-hoc queries

OLTP Partitioning Best Practices When partitioning large transaction tables for manageability Partition directly on a Primary Key that increases monotonically over time Partition directly on a Primary Key that increases monotonically over time Allows fast lookup on the key, simple maintenance Allows fast lookup on the key, simple maintenance Avoids non-aligned indexes Avoids non-aligned indexes Some applications benefit from partitioning on Organization or Geography Especially if these are naturally part of a Primary Key Especially if these are naturally part of a Primary Key Potential query performance benefits Potential query performance benefits

Add & Drop Partitions? A typical requirement is to insert or remove entire partitions of data in bulk Achieve this with a sequence of basic operations on partitions: Split Split Merge Merge Switch Switch

Split ALTER PARTITION FUNCTION … SPLIT RANGE … Adds a boundary point to a Partition Function Affects all objects using that Partition Function One partition is split into two The new partition is the one containing the new boundary point: The new partition is the one containing the new boundary point: To the right of boundary if RANGE RIGHT To the right of boundary if RANGE RIGHT To the left of boundary if RANGE LEFT To the left of boundary if RANGE LEFT Data that falls into the new range is moved from the split partition

Split Example: Range Right Partition # Boundary 1Boundary 2Boundary 3Boundary and Earlier 2002 Data 2003 Data 2004 Data 2005 and Later Boundary and Later 2006 and later data moved ALTER PARTITION FUNCTION annual_range() SPLIT RANGE (‘ ’) 2005 Data

Split -- Considerations Instantaneous if partition is empty This is IO-intensive if partition is populated Any data on new side of the boundary is physically deleted from old partition and inserted into the new partition Any data on new side of the boundary is physically deleted from old partition and inserted into the new partition Fully logged operation Fully logged operation Exclusive table lock held for duration of Split Exclusive table lock held for duration of Split Schema change, so plans are invalidated Always assign ‘Next Used’ filegroup in Partition Scheme before using Split ALTER PARTITION SCHEME NEXT USED … ALTER PARTITION SCHEME NEXT USED … Specifies which filegroup holds new partition’s data Specifies which filegroup holds new partition’s data

Merge ALTER PARTITION FUNCTION … MERGE RANGE Removes a boundary point from a Partition Function Affects all objects using that Partition Function The partitions on each side of the boundary are merged into one The partition that held the boundary value is removed The partition that held the boundary value is removed To the right of boundary if RANGE RIGHT To the right of boundary if RANGE RIGHT To the left of boundary if RANGE LEFT To the left of boundary if RANGE LEFT Data that was in the removed partition is moved to the remaining partition

Boundary 1Boundary 1Boundary 2Boundary 3Boundary 4 Merge Example: Range Right Boundary 2Boundary 3Boundary and Earlier 2002 Data 2003 Data 2004 Data 2005 Data Boundary and Later 2002 Data Moved ALTER PARTITION FUNCTION annual_range() MERGE RANGE (‘ ’) and Earlier

Merge -- Considerations Instantaneous if merged range is empty IO intensive if the partition is already populated Any rows in the removed partition are physically moved into the remaining partition. Any rows in the removed partition are physically moved into the remaining partition. Fully logged operation Fully logged operation Exclusive table lock held for duration of Split Exclusive table lock held for duration of Split Schema change, so plans are invalidated

Switch Instantly swaps the content of one partition or table (source) with another table’s empty partition or an empty table (target) Metadata-only operation, no data moves Restrictions: Target table or partition must be empty Target table or partition must be empty Source and target must be in same filegroup Source and target must be in same filegroup Source must have all indexes required by the target, aligned and in matching filegroups Source must have all indexes required by the target, aligned and in matching filegroups If Target is a partition, Source must have check constraints (if table) or a partition range that fits within the target range If Target is a partition, Source must have check constraints (if table) or a partition range that fits within the target range All associated indexes are automatically Switched along with the table / partition

Switch – Table to Partition Partition # Data 2004 Data Data 2006 & Later 2002 Data & Earlier 6 Alter Table B SWITCH TO A PARTITION 2 Table A: Table B: Filegroup DATA_2002 [EMPTY] CHECK CONSTRAINT: B.Date_Key >= ‘ ’ and B.Date_Key < ‘ ’ [EMPTY]

Switch – Partition to Table Partition # Data 2004 Data Data 2006 & Later 2002 Data & Earlier 6 Alter Table A SWITCH PARTITION 2 to B Table A: Table B: Filegroup DATA_2002 [EMPTY] [EMPTY]

Switch – Partition to Partition Partition # Data 2004 Data Data 2006 & Later 2002 Data & Earlier 6 Alter Table A SWITCH PARTITION 2 to B PARTITION 2 Table A: Table B: Filegroup DATA_2002 [EMPTY] [EMPTY] Partition # 2003 & Later 2002 Data & Earlier

Switch Tips If Switching between a nonpartitioned table and a partition, be sure that the nonpartitioned table’s indexes include the partitioning key May need to explicitly specify the column using the INCLUDE option of CREATE INDEX (Beta 3) May need to explicitly specify the column using the INCLUDE option of CREATE INDEX (Beta 3) Use the $partition function in scripts that automate the Switch command Avoids absolute partition number references Avoids absolute partition number references Helpful since partition numbers may change over time Helpful since partition numbers may change over time

Scenarios Sliding Window Load and Delete Efficient Backup and Restore Partition-wise Index Maintenance Snapshot (for availability)

Sliding Window Scenario Assumptions Large database Each hour/day/week/month…add new partition and remove the oldest one. New partition – May need to batch load, scrub, and transform before incorporating into the whole table May need to batch load, scrub, and transform before incorporating into the whole table Or start partition as empty and populate gradually using transactions. Or start partition as empty and populate gradually using transactions. Old partition – may need backup, archive, restore.

Loading Most Recent Data Partition # & Earlier 2002 Data 2003 Data 2004 Data 2005 & Later [EMPTY][EMPTY] Create staging table in same filegroup as target partition (2005) Split most recent partition, adding boundary point for following period Bulk load and index staging table Switch data into next-to-last partition [EMPTY] Data 2006 & Later Staging Table

Unloading Oldest Data Partition # Data 2004 Data Create unload table in same filegroup as partition to remove (2002) Switch data out of second partition Merge first partition, removing the boundary point for the unload period Archive or Truncate the unload table [EMPTY] Data 2006 & Later 2002 Data & Earlier [EMPTY] Unload Table [EMPTY] & Earlier

Sliding Window – Best Practices Using Range Right Partitioning: Always maintain empty partitions for the earliest and latest date ranges Ensures that Split and Merge is instantaneous Ensures that Split and Merge is instantaneous Adding New Data: First Split latest date range, then Switch data into the partition to the left of the boundary First Split latest date range, then Switch data into the partition to the left of the boundary Removing Old Data: First Switch data out of the oldest populated partition (Partition #2), then Merge the first date range First Switch data out of the oldest populated partition (Partition #2), then Merge the first date range

DEMO

Backup & Restore Partitioning leverage Filegroup Backup / Restore enhancements in SQL Server 2005 Read-Only Filegroups can now be restored without applying transaction logs Read-Only Filegroups can now be restored without applying transaction logs Reduces data volume for regular backups when historical data is not changing

Online Restore SQL Server 2000 Database is not available during restore Database is not available during restoreYukon Database remains online Database remains online Only data being restored is offline Only data being restored is offline Options Options File / Filegroup Restore File / Filegroup Restore Damaged Page Tracking and Page-Level Restore Damaged Page Tracking and Page-Level Restore

Piecemeal Restore Online restore of filegroups by priority Database is online if Primary filegroup is online Online throughout restore Database PrimaryFilegroup Filegroup A Filegroup B Filegroup A PrimaryBackupsLog

Piecemeal Backup & Restore Mark filegroups for unchanging, historical partitions as READ ONLY Perform one-time backup of these READ ONLY filegroups Regularly backup only the Primary filegroup and other filegroups containing active, changing data Potentially a small percentage of total data Potentially a small percentage of total data To Restore, restore Primary and active filegroups and recover log. Then restore the read-only filegroups separately

Partitioned Index Maintenance To reindex (REBUILD INDEX) a single partition: ALTER INDEX … REBUILD PARTITION = To reindex (REBUILD INDEX) a single partition: ALTER INDEX … REBUILD PARTITION = To defragment (REORGANIZE) a single partition: ALTER INDEX … REORGANIZE PARTITION = To defragment (REORGANIZE) a single partition: ALTER INDEX … REORGANIZE PARTITION = SQL Server 2000 SQL Server 2005 DBCC DBREINDEX ALTER INDEX …REBUILD DBCC INDEXDEFRAG ALTER INDEX … REORGANIZE

Online Index Operations Online Index Operations allow concurrent modification of the underlying table or index Updates, Inserts, Deletes Updates, Inserts, Deletes Online Index Maintenance Create, Rebuild, Drop Create, Rebuild, Drop Reorganize (including BLOBs) Reorganize (including BLOBs) Index-based constraints (PK, Unique) Index-based constraints (PK, Unique) DDL is simple Online / Offline are both supported Updates incur some additional cost during an online index operation

Index Maintenance Notes Historical partitions may never need rebuilding or reorganizing indexes For large, partitioned transaction tables Different partitions may be reindexed on different schedules (See ALTER INDEX) Different partitions may be reindexed on different schedules (See ALTER INDEX) Potential to shorten maintenance cycle Potential to shorten maintenance cycle Note: Online index rebuilds cannot be performed on individual partitions

Snapshots General Snapshot of a database at a point in time Created instantly Created instantly Read only Read only Base database continues to change Snapshot does not restrict the base database Snapshot does not restrict the base database Snapshot requires a different database name from base database Revert to previously created Snapshot to recover from errors

Snapshot Technology Extremely space efficient Does not require a complete copy of the data Shares unchanged pages of the database Shares unchanged pages of the database Only requires extra storage for changed pages Only requires extra storage for changed pages Uses a “copy on write” mechanism Snapshot does affect performance on the base database

Value R D B H J L Y M Space Used Command Create Northwind_SS NorthwindNorthwind_SS Update Northwind 0% Value DX Read Northwind_SS 12.5% Result: Snapshot (Copy on Write) DD

Conclusion Plan ahead: Consider Partition Keys and relationship to any required unique indexes Consider Partition Keys and relationship to any required unique indexes Ensure Partition Keys are restricted in important queries’ WHERE clauses Ensure Partition Keys are restricted in important queries’ WHERE clauses Design for bulk load and bulk delete strategy Design for bulk load and bulk delete strategy Design for backup and restore strategy Design for backup and restore strategy

General Best Practices Use ALIGNED indexes Split and Merge only empty partitions for best maintenance performance Spread all data across as many disks as possible Test all of your partitioning operations & scripts on empty tables and indexes first, including Piecemeal backup and restore Piecemeal backup and restore Maintenance plans Maintenance plans Split / merge / switch operations Split / merge / switch operations New filegroups and ALTER PARTITION SCHEME New filegroups and ALTER PARTITION SCHEME

© 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.