Download presentation
Presentation is loading. Please wait.
Published byPeter Porter Modified over 9 years ago
1
Partitioning techniques in SQL Server Eladio Rincon (ERincon@solidq.com)ERincon@solidq.com Javier Loria (javier@solidq.com)javier@solidq.com Solid Quality Mentors
2
Agenda 2 © 2008 Solid Quality Mentors Why?How?What?Where?Partitioning Toolbox
3
Agenda 3 © 2008 Solid Quality Mentors Why? Definition I/O Basics Table Basics Operational Benefits How?What?Where? Toolbox
4
Definition 4 © 2008 Solid Quality Mentors
5
I/O Basics OperationFileTypeReadWrite SELECTDatabaseRandomSynchronous- INSERT UPDATE DELETE LogSequential-Synchronous DatabaseRandom-Asynchronous Bulk InsertDatabaseRandomSynchronous Full BackupDatabaseSequentialSynchronous* Log BackupLogSequentialSynchronous- ReindexRandom?? 5 © 2008 Solid Quality Mentors 8 8 8 24 2424 2424 2424 S S S S
6
Table Basics 6 © 2008 Solid Quality Mentors
7
Operational Benefits Performance Query (OLPT/OLAP) Bulk-Insert (OLAP) Availability Full Backups Maintainability Archiving Pruning Reindex 7 © 2008 Solid Quality Mentors
8
Poor’s Mans Table Partitioning Creating and using partitioned views
9
Agenda 9 © 2008 Solid Quality Mentors Why?How? Partition Function Partition Scheme Create Table Reloaded Create Index Reloaded What?Where? Toolbox
10
Partition Function 10 © 2008 Solid Quality Mentors CREATE PARTITION FUNCTION Annual (INT) AS RANGE RIGHT FOR VALUES (20060101, 20070101, 20080101, 20090101, 20100101);
11
Partition Scheme 11 © 2008 Solid Quality Mentors CREATE PARTITION SCHEME Annual AS PARTITION Annual TO (EmptyHistory, Fact2006, Fact2007, Fact2008, Fact2009, EmptyFuture)
12
Create Table Reloaded 12 © 2008 Solid Quality Mentors CREATE TABLE SalesDataMart.FactVendas( IdDimDateINT NOT NULL, IdDimProductINT NOT NULL, IdDimCustomersINT NOT NULL, IdDimStoreINT NOT NULL, OrderedQuantityINT NOT NULL, TotalSalesAmountDECIMAL (19, 2) NOT NULL, TotalProductCostDECIMAL (19, 2) NOT NULL, POSNumINT NOT NULL, InvoceNumINT NOT NULL ) ON Annual(IdDimDate);
13
Create Index Reloaded 13 © 2008 Solid Quality Mentors CREATE CLUSTERED INDEX IDX_FactSales ON SalesDataMart.FactSales(IdDimDate, IdDimStore) ON Annual(IdDimDate); ALTER TABLE SalesDataMart.FactSales ADD CONSTRAINT PK_FactSales PRIMARY KEY(IdDimDate, IdDimProduct, IdDimCustomers, IdDimStore) ON Annual(IdDimDate);
14
Partition 101 Partitioned Hello World
15
Agenda 15 © 2008 Solid Quality Mentors Why?How? What? Table Design Patterns Partition Types Partition Methods Index Partitions Where? How?
16
Table and Design Patterns 16 © 2008 Solid Quality Mentors OLTP Reference Transactional History/Audit OLAP Dimension Fact Tables
17
Partition Types: Horizontal 17 Out of the Box : in SQL 2005/2008
18
Horizontal Partition Methods RANGE –Out of the Box (SQL 2005, SQL 2008) HASH –Build your own (Calculated Column/Hash/Range) LIST –Build your own (RANGE or Partitioned Views) 18 © 2008 Solid Quality Mentors
19
Partition Types: Vertical 19 Out of the Box : (n)text, image, xml, (n)varchar(max), varbinary(max) and CLR Types. Build your own : Views and Instead of Trigger
20
Index Structures 20 © 2008 Solid Quality Mentors Clustered IndexNon-clustered Index
21
Partitioned Table/non-partitioned Index 21 © 2008 Solid Quality Mentors Clustered IndexNon-clustered Index
22
Non Partitioned Table/Partitioned Index 22 © 2008 Solid Quality Mentors Clustered IndexNon-clustered Index Filtered Indexes
23
Partitioned Table/Aligned Index 23 © 2008 Solid Quality Mentors Clustered IndexNon-clustered Index
24
Partitioned View CREATE VIEW SalesDataMart.FactSalesByStore WITH SCHEMABINDING AS( SELECT IdDimDate, IdDimStore, SUM(OrderedQuantity) AS OrderedQuantity, SUM(TotalSalesAmount) AS TotalSalesAmount, SUM(TotalProductCost) AS TotalProductCost, COUNT_BIG(*) AS OrderNum FROM SalesDataMart.FactSales GROUP BY IdDimDate, IdDimStore) GO CREATE UNIQUE CLUSTERED INDEX PK_FactSalesByStore ON SalesDataMart.FactSalesByStore(IdDimDate, IdDimStore) ON Annual(IdDimDate); GO
25
Partitioning and Query Performance
26
Agenda 26 © 2008 Solid Quality Mentors Why?How?What?Where? Logical/Physical Method Toolbox
27
Without Partitions Disk File Filegroup Partition Primary
28
Simple: Partitioned Disk File Filegroup Partition Primary 2006200720082009
29
Multiple: Without Partitions Disk File Filegroup Partition Primary
30
Multiple: with Partitions (1/3) Disk File Filegroup Partition Primary 2006200720082009
31
Multiple: with Partitions (2/3) Disk File Filegroup Partition Primary 2006200720082009
32
Multiple: with Partitions (3/3) Disk File Filegroup Partition Primary 2006200720082009
33
Partitioning Availability and Maintainability Backup/Restore
34
Agenda 34 © 2008 Solid Quality Mentors Why?How?What?Where?Toolbox Pruning Loading
35
Pruning
36
Sliding Window Loading
37
Agenda 37 © 2008 Solid Quality Mentors Why?How?What?Where?Partitioning Toolbox
38
Please remember to fill out evaluations
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.