This work is by Kendra Little and is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported LicenseCreative Commons Attribution-NonCommercial-NoDerivs.

Slides:



Advertisements
Similar presentations
Tuning: overview Rewrite SQL (Leccotech)Leccotech Create Index Redefine Main memory structures (SGA in Oracle) Change the Block Size Materialized Views,
Advertisements

Module 13: Performance Tuning. Overview Performance tuning methodologies Instance level Database level Application level Overview of tools and techniques.
Denny Cherry Manager of Information Systems MVP, MCSA, MCDBA, MCTS, MCITP.
By: Jose Chinchilla July 31, Jose Chinchilla MCITP: SQL Server 2008, Database Administrator MCTS: SQL Server 2005/2008, Business Intelligence DBA.
Data Management and Index Options for SQL Server Data Warehouses Atlanta MDF.
CHAPTER OBJECTIVE: NORMALIZATION THE SNOWFLAKE SCHEMA.
Big Data Working with Terabytes in SQL Server Andrew Novick
EXECUTION PLANS By Nimesh Shah, Amit Bhawnani. Outline  What is execution plan  How are execution plans created  How to get an execution plan  Graphical.
©Silberschatz, Korth and Sudarshan12.1Database System Concepts Chapter 12: Indexing and Hashing Basic Concepts Ordered Indices B+-Tree Index Files B-Tree.
Module 6 Implementing Table Structures in SQL Server ®2008 R2.
Chapter 9 Overview  Reasons to monitor SQL Server  Performance Monitoring and Tuning  Tools for Monitoring SQL Server  Common Monitoring and Tuning.
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.
IMS 4212: Distributed Databases 1 Dr. Lawrence West, Management Dept., University of Central Florida Distributed Databases Business needs.
IT The Relational DBMS Section 06. Relational Database Theory Physical Database Design.
Physical Database Design & Performance. Optimizing for Query Performance For DBs with high retrieval traffic as compared to maintenance traffic, optimizing.
Architecture Rajesh. Components of Database Engine.
Chapter 6 1 © Prentice Hall, 2002 The Physical Design Stage of SDLC (figures 2.4, 2.5 revisited) Project Identification and Selection Project Initiation.
Views Lesson 7.
Chapter 15: Achieving High Availability Through Replication.
Database Management COP4540, SCS, FIU Physical Database Design (ch. 16 & ch. 3)
1 Chapter 10 Joins and Subqueries. 2 Joins & Subqueries Joins – Methods to combine data from multiple tables – Optimizer information can be limited based.
ESRI User Conference 2004 ArcSDE. Some Nuggets Setup Performance Distribution Geodatabase History.
SQL Server 2005 Implementation and Maintenance Chapter 12: Achieving High Availability Through Replication.
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.
Physical Database Design Purpose- translate the logical description of data into the technical specifications for storing and retrieving data Goal - create.
Introduction.  Administration  Simple DBMS  CMPT 454 Topics John Edgar2.
Partition Architecture Yeon JongHeum
Session 1 Module 1: Introduction to Data Integrity
Visual Basic for Application - Microsoft Access 2003 Finishing the application.
Last Updated : 27 th April 2004 Center of Excellence Data Warehousing Group Teradata Performance Optimization.
1 Chapter 9 Tuning Table Access. 2 Overview Improve performance of access to single table Explain access methods – Full Table Scan – Index – Partition-level.
CS4432: Database Systems II
Retele de senzori Curs 2 - 1st edition UNIVERSITATEA „ TRANSILVANIA ” DIN BRAŞOV FACULTATEA DE INGINERIE ELECTRICĂ ŞI ŞTIINŢA CALCULATOARELOR.
LAYERED PARTITIONING Josip Šaban, Hypo Alpe Adria AG, Klagenfurt.
October 15-18, 2013 Charlotte, NC Accelerating Database Performance Using Compression Joseph D’Antoni, Solutions Architect Anexinet.
How to kill SQL Server Performance Håkan Winther.
SQL Server Statistics DEMO SQL Server Statistics SREENI JULAKANTI,MCTS.MCITP,MCP. SQL SERVER Database Administration.
October 15-18, 2013 Charlotte, NC SQL Server Index Internals Tim Chapman Premier Field Engineer.
Scott Fallen Sales Engineer, SQL Sentry Blog: scottfallen.blogspot.com.
Execution Plans Detail From Zero to Hero İsmail Adar.
SQL Basics Review Reviewing what we’ve learned so far…….
SQL Server Statistics DEMO SQL Server Statistics SREENI JULAKANTI,MCTS.MCITP SQL SERVER Database Administration.
Big and Tall: When to Partition Kendra Little Founder, Brent Ozar PLF.
Oracle Announced New In- Memory Database G1 Emre Eftelioglu, Fen Liu [09/27/13] 1 [1]
Doing fast! Optimizing Query performance with ColumnStore Indexes in SQL Server 2012 Margarita Naumova | SQL Master Academy.
SQL IMPLEMENTATION & ADMINISTRATION Indexing & Views.
Introduction to Partitioning in SQL Server
Temporal Databases Microsoft SQL Server 2016
Indexes By Adrienne Watt.
Hitting the SQL Server “Go Faster” Button
Tree-Structured Indexes
Physical Database Design and Performance
Module 4: Creating and Tuning Indexes
The Ins and Outs of Partitioned Tables
SQL Server May Let You Do It, But it Doesn’t Mean You Should
Database Applications (15-415) DBMS Internals- Part III Lecture 15, March 11, 2018 Mohammad Hammoud.
Hitting the SQL Server “Go Faster” Button
SQL 2014 In-Memory OLTP What, Why, and How
Introduction to partitioning
Physical Database Design
JULIE McLAIN-HARPER LINKEDIN: JM HARPER
Steve Hood SimpleSQLServer.com
Indexing For Optimal Performance
Table Partitioning Intro and make that a sliding window too!
Why Should I Care About … Partitioned Views?
Table Partitioning Intro and make that a sliding window too!
Using Columnstore indexes in Azure DevOps Services. Lessons learned
Presentation transcript:

This work is by Kendra Little and is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported LicenseCreative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License Kendra Little Introduction to SQL Server Partitioning

About Kendra

Index 1. A sample case. 2. What is partitioning? 3. When is partitioning helpful? 4. Whats the fine print? 5. Revisiting our sample case. You are here

Should this client use partitioning?

Index 1. A sample case. 2. What is partitioning? 3. When is partitioning helpful? 4. Whats the fine print? 5. Revisiting our sample case. You are here

All tables have at least one partition. In SQL Server, all tables and indexes in a database are considered partitioned, even if they are made up of only one partition. Essentially, partitions form the basic unit of organization in the physical architecture of tables and indexes. This means that the logical and physical architecture of tables and indexes comprised of multiple partitions mirrors that of single-partition tables and indexes. …Partitioned Table and Index Concepts (msdn)Partitioned Table and Index Concepts (msdn) One Partition

Partitioning actually means horizontal partitioning Horizontal partitioning takes groups of rows in a single table and allocates them in semi- independent physical sections. SQL Servers horizontal partitioning is RANGE based.

Horizontal ranges are based on a partition key. A single column in the table. Just one! Use a computed column if you must, but make sure it performs well as a criterion and works for joins. Typically a date or integer value Consider: A column you will join on A column you can always use as a criterion I must choose wisely.

Ranges of data are defined by a partition function which uses the key. The partition function defines your boundary points and can use either RANGE LEFT or RIGHT. LEFT: the first value is an UPPER boundary point in partition #1 RIGHT: the first value is a LOWER boundary point in partition #2 Keep to the right. Its easier.

RIGHT based partition function for Doll Orders keyed on OrderDate 1/1/2008 1/1/2009 1/1/2010 1/1/2011 Partition 1 Partition 2 Partition 3 Partition 4 Partition 5

RIGHT based partition function keyed on PartName (effectively LIST) Boundary Point 1: BODY Boundary Point 2: SHOE Partition 1 Partition 2 Partition 3 Question: how do we get rows into Partition 1?

Filegroups are mapped to the partition function using a partition scheme. 1/1/2008 1/1/2009 1/1/2010 1/1/2011 Partition 1: Compressed Partition 2: Compressed Partition 3 Partition 4 Partition 5 Slow, Read-only FG_A FG_B FG_C FG_D

Objects are created on the partition scheme. Table (and indexes) Created on partition scheme. Partition Scheme Maps partitions defined by the partition function to physical filegroups Partition Function Boundary points Defines ranges Define an algorithm the engine will use to know where to put rows

Indexes can be created on the partition scheme. Or not. Located on your partitioning scheme (or an identical partitioning scheme) Must contain the partitioning key. If the partitioning key is not specified, it will be added for you. Note: this affects your primary key for the table! Indexes are aligned by default unless it is otherwise specified at creation time. Perform better for aggregations and when partition elimination can be used. Aligned Indexes Physically located elsewhere- either non partitioned or on a non-identical partitioning scheme May perform better with single-record lookup Allow unique indexes (because they do not have to contain the partitioning key) However, the presence of these preclude partition-switching! Non- aligned indexes

Switching Requires all indexes to be aligned. Compatible with filtered indexes Data may be switched in or out only within the same filegroup. Is a metadata-only operation requiring a schema modification lock. This can be blocked by DML operations, which require a schema stability lock. Is an exceptionally fast way to load or remove a large amount of data from a table!

Creating the partition function Our hero.

Creating filegroups We left the Primary FG default on purpose!

Creating the partition scheme The partition scheme can map each partition to a specific filegroup, or all partitions to the PRIMARY filegroup. Where the rubber meets the road.

Query FGs mapped to the partition function via the partition scheme This gets a little complicated.

Creating a table on the partition scheme and add some rows. A partitioned heap: you can totally do that.

Lets have a look at that heap. Well use this query again, but not show it on every slide for obvious reasons.

Adding indexes Someones not in line.

Notice that aligned indexes always have the clustering key Thats not usually there!

Adding another partition We now have a full staging table and empty partition on dailyFG4

Switching in! Dont forget to drop ordersDaily : your staging table is still there, its just empty now. And youre gonna have to rebuild that non-aligned NC if you want it back.

Say we want to get rid of some things. I hate deleting data.

Split can move data between filegroups. Extra credit: How do we get rid of data for 12/25 and 12/24?

Index 1. A sample case. 2. What is partitioning? 3. When is partitioning helpful? 4. Whats the fine print? 5. Revisiting our sample case. You are here

Is maintenance a significant problem for availability? YES Partitioning may be what you are looking for. Keep checking other factors. NO You may have other reasons to partition, but one of its big benefits is to help with this. Maintenance includes index rebuilds, loading data, and deleting data.

Are query patterns defined by regions? YES Finding regions of data which are queried together and have a good partitioning key is important to good query performance. This is the basis of partition elimination. NO You may not have a good partitioning key. Keep looking at the query patterns for your workload and evaluating different partitioning keys. Data regions may be dates, integers, codes

Can applications and queries be optimized for partitioning? YES This means you will be able to rewrite some queries and procedures as needed to take advantage of partition elimination. NO If you do not have the ability to tune user and application queries, some will likely perform very poorly. Some assembly required.

Do you have resources to support the partitioned system? Can your disk configuration be optimized? Is enough buffer pool available for what will need to be read into memory concurrently? Will you be able to tune and configure parallelism appropriately for the workload? Do you have a system you can test with a production-like workload, or a suitable rollback plan?

Index 1. A sample case. 2. What is partitioning? 3. When is partitioning helpful? 4. Whats the fine print? 5. Revisiting our sample case. You are here

Editions with partitioning EnterpriseDatacenterDeveloperEvaluation

Support for HOW MANY partitions? 15,000 partitions are available in SQL 2008 with SP2 applied SQL Server 2005, 2008, and 2008 R2 (for now) are limited to 1,000 partitions. This is less than 3 years for daily partitioning. What problems could happen with lots of partitions?

Parallelism In 2005, a query touching more than one partition typically had only one thread per partition. In 2008, the Partitioned Table Parallelism improvement allows multiple threads to be used on each partition for parallel plans. Partition 1! Partition 2! Partition 3!

Lock escalation AUTO Lock escalation can be set to AUTO for a table. If the table is partitioned, locks will escalate to the partition level rather than the table level. Whats awesome: greater concurrency! Partition level deadlocks Partition level deadlocks are not awesome. Test your workload (like with any feature).

Partition aware seeks In SQL 2008, the optimizer has been made more clever and has a greater chance at achieving partition elimination. This has been done by: Changing the internal representation of a partitioned table to be more optimized for seeking on the PartitionID (even when the tables CX is on another column) A skip scan operation has been added to allow the optimizer greater flexibility. More optimized optimizin.

Be careful with your statistics Statistics are not maintained per partition, they are maintained for the entire index or column. Since there is a limit to the number of steps in the histogram, the statistics can become invalid, and on very large tables may take a long time to update. Filtered statistics can be used to help with this in 2008: you can create new filtered statistics for your new partition. This sounds like work.

Index rebuilds and compression Individual partitions cannot be rebuilt online. The entirety of a partitioned index can be rebuilt online. Individual partitions can be compressed. For fact tables with archive data, older partitions can be be rebuilt once with compression. Their filegroups can then be made read-only. Id better check my maintenance jobs.

Switching Feature Compatibility Works with replication in 2008 and later Some subscribers can have the partitioning scheme, others dont have to This means you can have some subscribers on Standard. Works with Change Data Capture (with some special steps) Does not work with Change replicates her partitioned tables, check out her blog.

Logshipping/Mirroring Logshipping and mirroring have no compatibility with partitioning specifically. Be aware that if you are going to start using filegroups distributed on different drives, this will impact the configuration of your logshipping secondaries or mirrors, and you must plan appropriately. Okey dokey.

2008R2 Improvements Improved Performance on partition merges Details here: e/2010/02/03/performance-improvement-by-orders-of- magnitude-when-merging-partitions-in-sql-server- 2008r2.aspx e/2010/02/03/performance-improvement-by-orders-of- magnitude-when-merging-partitions-in-sql-server- 2008r2.aspx

Index 1. A sample case. 2. What is partitioning? 3. When is partitioning helpful? 4. Whats the fine print? 5. Revisiting our sample case. You are here

So, should this client use partitioning?

This work is by Kendra Little and is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported LicenseCreative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License Resources/ Contact There is a very large amount of documentation online for horizontal table partitioning. Get my recommendations here: This presentation would not have been possibly without whitepapers and blogs by Kimberly Tripp, Michelle Ufford, and Ron Talmage. LinkedIn: