Why Should I Care About … Partitioned Views?

Slides:



Advertisements
Similar presentations
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Advertisements

Big Data Working with Terabytes in SQL Server Andrew Novick
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.
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.
DAT702.  Standard Query Language  Ability to access and manipulate databases ◦ Retrieve data ◦ Insert, delete, update records ◦ Create and set permissions.
Module 9: Managing Schema Objects. Overview Naming guidelines for identifiers in schema object definitions Storage and structure of schema objects Implementing.
Database Design for DNN Developers Sebastian Leupold.
HAP 709 – Healthcare Databases SQL Data Manipulation Language (DML) Updated Fall, 2009.
DBSQL 14-1 Copyright © Genetic Computer School 2009 Chapter 14 Microsoft SQL Server.
Insert, Update & Delete Performance Joe Chang
SQL Server Indexes Indexes. Overview Indexes are used to help speed search results in a database. A careful use of indexes can greatly improve search.
Partitioning Design For Performance and Maintainability Martin Cairns
Chapter 16 Practical Database Design and Tuning Copyright © 2004 Pearson Education, Inc.
M1G Introduction to Database Development 2. Creating a Database.
SQL Basic. What is SQL? SQL (pronounced "ess-que-el") stands for Structured Query Language. SQL is used to communicate with a database.
Indexes / Session 2/ 1 of 36 Session 2 Module 3: Types of Indexes Module 4: Maintaining Indexes.
Introduction to Database System Adisak Intana Lecturer Chapter 7 : Data Integrity.
Database Fundamental & Design by A.Surasit Samaisut Copyrights : All Rights Reserved.
Working with SQL Server Database Objects Faculty: Nguyen Ngoc Tu.
Lec 7 Practical Database Design and Tuning Copyright © 2004 Pearson Education, Inc.
Chapter 5 Index and Clustering
Session 1 Module 1: Introduction to Data Integrity
Student Centered ODS ETL Processing. Insert Search for rows not previously in the database within a snapshot type for a specific subject and year Search.
A Guide to SQL, Eighth Edition Chapter Six Updating Data.
SQL Query Analyzer. Graphical tool that allows you to:  Create queries and other SQL scripts and execute them against SQL Server databases. (Query window)
Retele de senzori Curs 2 - 1st edition UNIVERSITATEA „ TRANSILVANIA ” DIN BRAŞOV FACULTATEA DE INGINERIE ELECTRICĂ ŞI ŞTIINŢA CALCULATOARELOR.
 What is DB Testing ?  Testing at the Data Access Layer  Need for Testing DB Objects  Common Problems that affect the Application  Should Testers.
SQL Basics Review Reviewing what we’ve learned so far…….
Views / Session 3/ 1 of 40 Session 3 Module 5: Implementing Views Module 6: Managing Views.
In this session, you will learn to: Manage databases Manage tables Objectives.
Data Integrity & Indexes / Session 1/ 1 of 37 Session 1 Module 1: Introduction to Data Integrity Module 2: Introduction to Indexes.
SQL IMPLEMENTATION & ADMINISTRATION Indexing & Views.
Getting started with Accurately Storing Data
Introduction to Partitioning in SQL Server
Practical Database Design and Tuning
Temporal Databases Microsoft SQL Server 2016
Temporal Databases Microsoft SQL Server 2016
Introduction to SQL 2016 Temporal Tables
© 2016, Mike Murach & Associates, Inc.
MIS2502: Data Analytics SQL – Putting Information Into a Database
Physical Changes That Don’t Change the Logical Design
Instructor: Jason Carter
Applied CyberInfrastructure Concepts Fall 2017
Why Should I Care About … Partitioned Views?
Why Should I Care About … Partitioned Views?
The Ins and Outs of Partitioned Tables
මොඩියුල විශ්ලේෂණය Buffer Pool Extension භාවිතය.
Beginner Table Partitioning
Module 5: Implementing Data Integrity by Using Constraints
SQL 101.
Simple Partitioning Building a simple partitioning solution with SQL Server Stephen Fulcher.
Introduction to partitioning
Teaching slides Chapter 8.
Why Should I Care About … Partitioned Views?
Why Should I Care About … Partitioned Views?
Practical Database Design and Tuning
Table Partitioning Intro and make that a sliding window too!
Microsoft SQL Server 2014 for Oracle DBAs Module 7
Data Management Innovations 2017 High level overview of DB
Why Should I Care About … Partitioned Views?
Table Partitioning Intro and make that a sliding window too!
Why Should I Care About … Partitioned Views?
Introduction To Structured Query Language (SQL)
Table Partitioning Intro and make that a sliding window too!
MIS2502: Data Analytics SQL 4– Putting Information Into a Database
IST 318 Database Administration
Partition Switching Joe Tempel.
Why Should I Care About … Partitioned Views?
Presentation transcript:

Why Should I Care About … Partitioned Views?

Frederick (Rick) Lowe rick@data-flowe.com DataFLowe

I’m Not Here to Start the Retrolution Partitioned tables are awesome for almost all partitioning cases Main takeaway from this talk – you’re not doomed if you have Standard Also, there are a couple of cases where views make sense even in EE

First … Why Are Partitioned Tables So Exciting? Appears to be a normal table Table is broken into multiple partitions based on the value of a single column Migrating a partition in or out is a metadata-only operation (i.e. basically instantaneous) Select statements can eliminate partitions Enterprise edition, MSSQL 2008 and higher

Working With Partitioned Tables Create a partition function and scheme Build clustered and nonclustered indexes on the partition scheme Views, CRUD etc reference a partitioned table pretty much like any other table SQL Server does all the heavy lifting

Partitioned Table Update/Insert/Select MyTable 2005? 2006? 2007? 2008? Partition Scheme Associated With Table P0 … P1 … P2 … P3 …

Defining a Partitioned Table CREATE PARTITION FUNCTION MyFunction(DATE) AS RANGE RIGHT FOR VALUES (…); CREATE PARTITON SCHEME MyPartitionScheme AS PARTITION MyFunction TO( … ); CREATE TABLE Sales.SalesOrderHeader( OrderDate DATETIME2(3), SalesOrderID INT IDENTITY NOT NULL, … CONSTRAINT PK_SalesOrderHeader PRIMARY KEY CLUSTERED(OrderDate, SalesOrderID) ON MyPartitionScheme( OrderDate ) );

Working With Partitioned Views Build individual tables Typically, create check constraints on tables View unions together all underlying tables *Create procedure determines which table to insert the data into *Update/Delete also need to either determine which table to work on or operate on all * indicates operations on view can save work

Partitioned View Update Insert Select UpdateMyTable CreateMyTable vwMyTable 2005? 2006? 2007? 2008? Data Boundaries Coded Into View / Procs MyTbl_05 … MyTbl_06 … MyTbl_07 … MyTbl_08 …

Defining a Partitioned View CREATE VIEW Sales.vwSalesOrderHeader AS SELECT OrderDate, SalesOrderID, … FROM Sales.SalesOrderHeader_2005 UNION ALL SELECT OrderDate, SalesOrderID, … FROM Sales.SalesOrderHeader_2006 SELECT OrderDate, SalesOrderID, … FROM Sales.SalesOrderHeader_2007 SELECT OrderDate, SalesOrderID, … FROM Sales.SalesOrderHeader_2008; CREATE PROCEDURE Sales.SalesOrderHeader_Create … AS INSERT INTO Sales.SalesOrderHeader_2008( OrderDate, SalesOrderID, ….) VALUES( …. )

Limitations of Partitioned Tables Prior to MSSQL 2016 SP1, Enterprise feature Horizontal partitioning scheme only Statistics tracked at table (not partition) level Indexing defined at the table level Partitioning can only occur on one column Prior to MSSQL 2014, online rebuild only supported at table level

Vertical Partitioning Horizontal partitioning separates groups of rows into partitions (table) or tables (view) Vertical partitioning on the other hand separates columns from the rest of the table Can be driven by normalization In practice, this term is more often associated with row splitting

Horizontal Partition

Vertical Partition

Before Row Splitting ID_Int ID_GUID Name … Big_xml Rating 1 1a23… Anna <doc <a name=a/>… /> 2 2ff0… Bubba <doc <a name=b/>… /> 9001 10ab… Goku

After Row Splitting ID_Int ID_GUID Name … 1 1a23… Anna 2 2ff0… Bubba 9001 10ab… Goku ID_Int Big_xml Rating 1 <… /> … 2 9001

Statistics Sampling

Common Answer

Possible Answer

Moving Data Around – Partitioned Table To extract an entire partition from a table Use ALTER TABLE SWITCH to instantly switch the partition out to a new table Archive / delete / manipulate the new table To add existing data to partitioned table Get data into table with same structure/indexing Add check constraints Switch the new table into the partitioned table

Moving Data Around – Partitioned View To separate a table from the view Alter the view so that it no longer references table Update stored procedures if necessary To add existing data to partitioned view Get data into table with same structure Ideally, add check constraints Update view and stored procedures to reference new table

Demo Startup Conditions in Execution Plan

Thank You Rick Lowe – rick@data-flowe.com DataFLowe