Vous êtes sur la page 1sur 36

The Sliding Window Scenario

The sliding window scenario is a method for aging old data out and bringing new data into a partitioned table on a periodic basis. Using a time-based or date-based partitioned table, the technique employs the SWITCH option of ALTER TABLE, along with the MERGE and SPLIT operations of ALTER PARTITION FUNCTION, to move the table's partitions forward in time one partition at a time, leaving the overall number of partitions the same The key feature of a sliding window scenario is that the partitions represent time linearly, and the window of time slides forward period by period, keeping the overall number of partitions in the partitioned table constant. The window moves forward partition by partition, reflecting the period of time chosen by the boundary values of the partition function.

Sliding Window Steps


In general, a sliding window consists of the following steps: 1. Create a nonpartitioned archive table with the same structure, and a matching clustered index (if required). Optionally you can add matching secondary indexes and constraints. Place it on the same filegroup as the oldest partition. 2. Use SWITCH to move the oldest partition from the partitioned table to the archive table. 3. Remove the boundary value of the oldest partition using MERGE. 4. Designate the NEXT USED filegroup. 5. Create a new boundary value for the new partition using SPLIT (the best practice is to split an empty partition at the leading end of the table into two empty partitions to minimize data movement.). 6. Create a staging table that has the same structure as the partitioned table on the target filegroup. 7. Populate the staging table. 8. Add indexes. 9. Add a check constraint that matches the constraint of the new partition. 10. Ensure that all indexes are aligned. 11. Switch the newest data into the partitioned table (the staging table is now empty). 12. Update statistics on the partitioned table. In addition, to protect the partitioned table from allowing any data values from beyond the desired boundary range, a check constraint over the entire boundary range can be applied. There are a number of things you can do to make the sliding window scenario as efficient as possible: Minimize data movement by using SPLIT and MERGE on empty partitions. Switching out the oldest data partition and leaving an empty partition in its place allows you to merge an empty partition. The same is true when you use the SPLIT operation to create the partition for the newest data: It is initially an empty partition, so the SPLIT operation does not cause any data movement. Create the staging table for new data as initially a heap, load the data, and then build indexes (and indexed views, if any) as a preparation for switching. Update statistics on the table after every partition switching cycle (because statistics are kept at the table level, this operation can be time-consuming and resource intensive).

In a sliding window scenario, the oldest data switched out of the partition can be archived or deleted, depending on business requirements. We'll deal with archiving scenarios in the next section.

Partitioning analysis on UNFI


We had found following tables having high number of rows and the best candidates for the partitioning: Database: East Datamart Tables tblOrders tblLines tblCredit tblReceivedPOheader tblReceivedPOline tblInventoryHistory tblEDLCDetails tblAcctsRcvTxnHistory tblRebateHistory tblMCB_History tblMCBOverpullResultsAuditByDivi sion Row Count 18181943 894524104 20948720 1761872 15292957 873059714 8066270 40893592 139405538 77320823 98042526 East_Group File Group

Database: National Datamart Tables tblMPWDailyOrderHeader tblMPWDailyOrderLines tblMPWDailyCreditHeader tblMPWDailyCreditLines tblMPWDailyOrderLines_Remarks tbl_MPW_MCBLines tbl_MPW_ProductCostPromoAllo wances tbl_MPW_POHeader Row Count 13402588 557382636 1801026 9064997 National_Group 14292975 57890065 2672353 2420328 FileGroup

Proposed Partition Schemes


The proposed partition schema is Horizontal Range Base Partition based on Index. 1. One Partition Function for Clustered Indexed Columns 2. One Partition Function for Non Clustered Indexed Columns (if Required).

Advantages related to Horizontal Range Base Partition already discussed above.

UNFI Partitioning Objects Scope & Impacts


Please find below the analysis on partition columns of above mentioned tables.

Data Compression for Previous Partition Data:


Table Compression:
ALTER TABLE <table_name> REBUILD PARTITION = 1 WITH (DATA_COMPRESSION = GO PAGE)

Index Compression:
ALTER INDEX IX_TransactionHistory_ProductID ON Production.TransactionHistory REBUILD PARTITION = 1 WITH (DATA_COMPRESSION = PAGE); GO

List of Compression Tables / Indexes:


---Get List of Compression Tables--USE [East_Datmart] SELECT [t].[name] AS [Table], [p].[partition_number] AS [Partition], [p].[data_compression_desc] AS [Compression] FROM [sys].[partitions] AS [p] INNER JOIN sys.tables AS [t] ON [t].[object_id] = [p].[object_id] WHERE [p].[data_compression_desc] <> 'NONE' ---Get List of Compression Indexes--USE [East_Datmart] SELECT [t].[name] AS [Table], [i].[name] AS [Index], [p].[partition_number] AS [Partition], [p].[data_compression_desc] AS [Compression] FROM [sys].[partitions] AS [p] INNER JOIN sys.tables AS [t] ON [t].[object_id] = [p].[object_id] INNER JOIN sys.indexes AS [i] ON [i].[object_id] = [p].[object_id] WHERE [p].[data_compression_desc] <> 'NONE'

TblOrders

File Groups and Data Files Distribution


Files for Previous data:
ALTER DATABASE EAST_Datamart ADD FILEGROUP TblOrders_FG1 GO ALTER DATABASE EAST_Datamart ADD FILE ( NAME = TblOrders_FG_DF01, FILENAME = 'M:\ TblOrders_FG_DF01.mdf', SIZE = 1024MB,MAXSIZE = UNLIMITED,FILEGROWTH = 500MB ) TO FILEGROUP TblOrders_FG1 GO

Files for latest data (2013):


ALTER DATABASE EAST_Datamart ADD FILEGROUP TblOrders_FG2 GO ALTER DATABASE EAST_Datamart ADD FILE ( NAME = TblOrders_FG_DF02, FILENAME = 'M:\ TblOrders_FG_DF02.mdf', SIZE = 1024MB,MAXSIZE = UNLIMITED,FILEGROWTH = 500MB ) TO FILEGROUP TblOrders_FG2 GO

Column need partitioning details tblOrders


Table Name
TblOrders

Candidate column for Partitioning


DeliveryDate

Filegroup
East_Group

DataFile
TblOrders_df

Partition Function and partition Scheme


CREATE PARTITION FUNCTION East_PF (datetime) AS RANGE left FOR VALUES ('20130101'); GO

CREATE PARTITION SCHEME TblOrders_PS AS PARTITION East_PF TO (TblOrders_FG1,TblOrders_FG2) GO

Indexes on Table ( TblOrders)


Index Name idx_InvNUm idx_InvoiceDate idx_RptDte tblOrder_Index_3 tblOrders_Index_1 tblOrders_Index_2 Index Description nonclustered located on PRIMARY nonclustered located on PRIMARY nonclustered located on PRIMARY nonclustered located on PRIMARY clustered, ignore duplicate keys, unique located on PRIMARY nonclustered located on PRIMARY Index Keys InvoiceNumber InvoiceDate ReportingDate DateLoaded OrderNumber, DeliveryDate CustomerNumber

Partitioned Aligned Indexes:


All non-clustered indexes will be partitioned aligned as per clustered indexes . (required for sliding window operation) Clustered index will partition the already created table
Alter table Table_Name; drop constraint Constraint_Name;

Alter Table Add constraint using New file group.

Data Analysis Pattern (2013) on tblOrders


Years TblOrders 2013 587763 Records

TblLines File Groups and Data Files Distribution


Files for Previous data:
ALTER DATABASE EAST_Datamart ADD FILEGROUP TblLines_FG1

GO ALTER DATABASE EAST_Datamart ADD FILE ( NAME = TblLines_DF01, FILENAME = 'M:\ TblLines_DF01.mdf', SIZE = 1024MB,MAXSIZE = UNLIMITED,FILEGROWTH = 500MB ) TO FILEGROUP TblLines_FG1 GO

Files for latest data (2013):


ALTER DATABASE EAST_Datamart ADD FILEGROUP TblLines_FG2 GO ALTER DATABASE EAST_Datamart ADD FILE ( NAME = TblLines_DF02, FILENAME = 'M:\ TblLines_DF02.mdf', SIZE = 1024MB,MAXSIZE = UNLIMITED,FILEGROWTH = 500MB ) TO FILEGROUP TblLines_FG2 GO

Column need partitioning details TblLines


Table Name
TblLines

Candidate column for Partitioning


DeliveryDate

Filegroup
East_Group

DataFile
TblLines_df

Data Analysis Pattern (2013) on TblLines


Years TblLines 2013 30013995 Records

Partition Function and partition Scheme


CREATE PARTITION FUNCTION East_PF (datetime) AS RANGE left FOR VALUES ('20130101'); GO CREATE PARTITION SCHEME TblLines_PS

AS PARTITION East_PF TO (TblLines_FG1, TblLines_FG2) GO

Indexes on Table ( TblLines)


Index Name ix_prd tblLines_Ind ex_1 tblLines_Ind ex_2 Index Description nonclustered located on PRIMARY clustered, ignore duplicate keys, unique located on PRIMARY nonclustered located on PRIMARY Index Keys ProductNumber OrderNumber, DeliveryDate, LineSequenceNumber DateLoaded

Partitioned Aligned Indexes:


All non-clustered indexes will be partitioned aligned as per clustered indexes . (required for sliding window operation) Clustered index will partition the already created table
Alter table Table_Name; drop constraint Constraint_Name;

Alter Table Add constraint using New file group.

TblCredit File Groups and Data Files Distribution


Files for Previous data:
ALTER DATABASE EAST_Datamart ADD FILEGROUP TblCredit_FG1 GO ALTER DATABASE EAST_Datamart ADD FILE ( NAME = TblCredit_DF01, FILENAME = 'M:\ TblCredit_DF01.mdf', SIZE = 1024MB,MAXSIZE = UNLIMITED,FILEGROWTH = 500MB ) TO FILEGROUP TblCredit_FG1 GO

Files for latest data (2013):


ALTER DATABASE EAST_Datamart ADD FILEGROUP TblCredit_FG2 GO ALTER DATABASE EAST_Datamart ADD FILE ( NAME = TblCredit_DF02, FILENAME = 'M:\ TblCredit_DF02.mdf', SIZE = 1024MB,MAXSIZE = UNLIMITED,FILEGROWTH = 500MB ) TO FILEGROUP TblCredit_FG2 GO

Column need partitioning details TblCredit


Table Name
TblCredit

Candidate column for Partitioning


ReleaseDate

Filegroup
East_Group

DataFile
TblCredit_df

Data Analysis Pattern (2013) on TblCredit


Year 2013 Records 700284

TblCredit

Partition Function and partition Scheme


CREATE PARTITION FUNCTION East_PF (datetime) AS RANGE left FOR VALUES ('20130101'); GO CREATE PARTITION SCHEME TblCredit_PS AS PARTITION East_PF TO (TblCredit_FG1, TblCredit_FG2) GO

Indexes on Table ( TblCredit)


Index Name Index Description Index Keys

Idx_RelDteCredN umLinSeqMsgSeq ix_applyTo

clustered, ignore duplicate keys, unique located on PRIMARY nonclustered located on PRIMARY

ReleaseDate, CustomerNumber, CreditNumber, LineSequenceNumber, MessageSequenceNumber ApplyToInvoiceNumber

Partitioned Aligned Indexes:


All non-clustered indexes will be partitioned aligned as per clustered indexes . (required for sliding window operation) Clustered index will partition the already created table
Alter table Table_Name; drop constraint Constraint_Name;

Alter Table Add constraint using New file group.

TblReceivedPOheader File Groups and Data Files Distribution


Files for Previous data:
ALTER DATABASE EAST_Datamart ADD FILEGROUP TblReceivedPOheader_FG1 GO ALTER DATABASE EAST_Datamart ADD FILE ( NAME = TblReceivedPOheader_DF01, FILENAME = 'M:\TblReceivedPOheader_DF01.mdf', SIZE = 1024MB,MAXSIZE = UNLIMITED,FILEGROWTH = 500MB ) TO FILEGROUP TblReceivedPOheader_FG1 GO

Files for latest data (2013):


ALTER DATABASE EAST_Datamart ADD FILEGROUP TblReceivedPOheader_FG2 GO ALTER DATABASE EAST_Datamart ADD FILE ( NAME = TblReceivedPOheader_DF01,

FILENAME = 'M:\TblReceivedPOheader_DF02.mdf', SIZE = 1024MB,MAXSIZE = UNLIMITED,FILEGROWTH = 500MB ) TO FILEGROUP TblReceivedPOheader_FG2 GO

Column need partitioning details TblReceivedPOheader


Table Name
TblReceivedPOheader

Candidate column for Partitioning


ReceivedDate

Filegroup
East_Group

DataFile
TblReceivedPOheader_df

Data Analysis Pattern (2013) on TblReceivedPOheader


Year TblReceivedPOheader 2013 56696 Records

Partition Function and partition Scheme


CREATE PARTITION FUNCTION East_PF (datetime) AS RANGE left FOR VALUES ('20130101'); GO CREATE PARTITION SCHEME TblReceivedPOheader_PS AS PARTITION East_PF TO (TblReceivedPOheader_FG1, TblReceivedPOheader_FG2) GO

Indexes on Table ( TblReceivedPOheader)


Index Name idx_vend tblReceivedPOheader_Ind ex_1 Index Description nonclustered located on PRIMARY clustered, ignore duplicate keys, unique located on PRIMARY Index Keys VendorNumber ReceivedDate, PONumber

Partitioned Aligned Indexes:


All non-clustered indexes will be partitioned aligned as per clustered indexes . (required for sliding window operation)

Clustered index will partition the already created table


Alter table Table_Name; drop constraint Constraint_Name;

Alter Table Add constraint using New file group.

TblReceivedPOline File Groups and Data Files Distribution


Files for Previous data:
ALTER DATABASE EAST_Datamart ADD FILEGROUP TblReceivedPOline_FG1 GO ALTER DATABASE EAST_Datamart ADD FILE ( NAME = TblReceivedPOline_DF01, FILENAME = 'M:\TblReceivedPOline_DF01.mdf', SIZE = 1024MB,MAXSIZE = UNLIMITED,FILEGROWTH = 500MB ) TO FILEGROUP TblReceivedPOline_FG1 GO

Files for latest data (2013):


ALTER DATABASE EAST_Datamart ADD FILEGROUP TblReceivedPOline_FG2 GO ALTER DATABASE EAST_Datamart ADD FILE ( NAME = TblReceivedPOline_DF02, FILENAME = 'M:\TblReceivedPOline_DF02.mdf', SIZE = 1024MB,MAXSIZE = UNLIMITED,FILEGROWTH = 500MB ) TO FILEGROUP TblReceivedPOline_FG2 GO

Column need partitioning details TblReceivedPOline


Table Name
TblReceivedPOline

Candidate column for Partitioning


ReceivedDate

Filegroup
East_Group

DataFile
TblReceivedPOline_df

Data Analysis Pattern (2013) on TblReceivedPOline


Year TblReceivedPOline 2013 477652 Records

Partition Function and partition Scheme


CREATE PARTITION FUNCTION East_PF (datetime) AS RANGE left FOR VALUES ('20130101'); GO CREATE PARTITION SCHEME TblReceivedPOline_PS AS PARTITION East_PF TO (TblReceivedPOline_FG1, TblReceivedPOline_FG2) GO

Indexes on Table ( TblReceivedPOline)


Index Name ix_entryDate ix_vendor tblReceivedPOline_I ndex_1 tblReceivedPOline_I ndex_2 Index Description nonclustered located on PRIMARY nonclustered located on PRIMARY clustered, ignore duplicate keys, unique located on PRIMARY nonclustered located on PRIMARY Index Keys EntryDate VendorNumber ReceivedDate, PONumber, POSequenceNumber WarehouseNumber, ProductNumber

Partitioned Aligned Indexes:


All non-clustered indexes will be partitioned aligned as per clustered indexes . (required for sliding window operation) Clustered index will partition the already created table
Alter table Table_Name; drop constraint Constraint_Name;

Alter Table Add constraint using New file group.

TblInventoryHistory File Groups and Data Files Distribution


Files for Previous data:

ALTER DATABASE EAST_Datamart ADD FILEGROUP tblInventoryHistory_FG1 GO ALTER DATABASE EAST_Datamart ADD FILE ( NAME = tblInventoryHistory_DF01, FILENAME = 'M:\ tblInventoryHistory_DF01.mdf', SIZE = 1024MB,MAXSIZE = UNLIMITED,FILEGROWTH = 500MB ) TO FILEGROUP tblInventoryHistory_FG1 GO

Files for latest data (2013):


ALTER DATABASE EAST_Datamart ADD FILEGROUP tblInventoryHistory_FG2 GO ALTER DATABASE EAST_Datamart ADD FILE ( NAME = tblInventoryHistory_DF02, FILENAME = 'M:\ tblInventoryHistory_DF02.mdf', SIZE = 1024MB,MAXSIZE = UNLIMITED,FILEGROWTH = 500MB ) TO FILEGROUP tblInventoryHistory_FG2 GO

Column need partitioning details TblInventoryHistory


Table Name
tblInventoryHistory

Candidate column for Partitioning


ReceivedDate

Filegroup
East_Group

DataFile
tblInventoryHistory_df

Data Analysis Pattern (1-Months) on TblInventoryHistory


Month
tblInventoryHistory

Records 12453482

2013-Apr

Partition Function and partition Scheme

CREATE PARTITION FUNCTION East_PF (datetime) AS RANGE left FOR VALUES ('20130101'); GO CREATE PARTITION SCHEME tblInventoryHistory_PS AS PARTITION East_PF TO (tblInventoryHistory_FG1, tblInventoryHistory_FG2) GO

Indexes on Table ( TblInventoryHistory)


Index Name PK_tblInventory History Index Description nonclustered, unique, primary key located on PRIMARY Index Keys WHPDLoadDate, Region, Warehouse, ProductNumber

Partitioned Aligned Indexes:


All non-clustered indexes will be partitioned aligned as per clustered indexes . (required for sliding window operation) Clustered index will partition the already created table
Alter table Table_Name; drop constraint Constraint_Name;

Alter Table Add constraint using New file group.

TblAcctsRcvTxnHistory
File Groups and Data Files Distribution
Files for Previous data:
ALTER DATABASE EAST_Datamart ADD FILEGROUP tblAcctsRcvTxnHistory_FG1 GO ALTER DATABASE EAST_Datamart ADD FILE ( NAME = tblAcctsRcvTxnHistory_DF01, FILENAME = 'M:\ tblAcctsRcvTxnHistory_DF01.mdf', SIZE = 1024MB,MAXSIZE = UNLIMITED,FILEGROWTH = 500MB )

TO FILEGROUP tblAcctsRcvTxnHistory_FG1 GO

Files for latest data (2013):


ALTER DATABASE EAST_Datamart ADD FILEGROUP tblAcctsRcvTxnHistory_FG2 GO ALTER DATABASE EAST_Datamart ADD FILE ( NAME = tblAcctsRcvTxnHistory_DF02, FILENAME = 'M:\ tblAcctsRcvTxnHistory_DF02.mdf', SIZE = 1024MB,MAXSIZE = UNLIMITED,FILEGROWTH = 500MB ) TO FILEGROUP tblAcctsRcvTxnHistory_FG2 GO

Column need partitioning details TtblAcctsRcvTxnHistory


Table Name
tblAcctsRcvTxnHistory

Candidate column for Partitioning ARDatePosted

Filegroup
East_Group

DataFile
tblAcctsRcvTxnHistory_df

Data Analysis Pattern (2013) on TtblAcctsRcvTxnHistory


Year
tblAcctsRcvTxnHistory

Records 2098065

2013

Partition Function and partition Scheme


CREATE PARTITION FUNCTION East_PF (datetime) AS RANGE left FOR VALUES ('20130101'); GO CREATE PARTITION SCHEME tblAcctsRcvTxnHistory_PS AS PARTITION East_PF TO (tblAcctsRcvTxnHistory_FG1, tblAcctsRcvTxnHistory_FG2) GO

Indexes on Table ( TtblAcctsRcvTxnHistory)

Index Name Index Description ix_customer nonclustered located on PRIMARY tblAcctsRcvTxnHistory_Index_1 clustered located on PRIMARY

Index Keys CustomerNumber ARDatePosted

Partitioned Aligned Indexes:


All non-clustered indexes will be partitioned aligned as per clustered indexes . (required for sliding window operation) Clustered index will partition the already created table
Alter table Table_Name; drop constraint Constraint_Name;

Alter Table Add constraint using New file group.

TtblRebateHistory File Groups and Data Files Distribution


Files for Previous data:
ALTER DATABASE EAST_Datamart ADD FILEGROUP tblRebateHistory_FG1 GO ALTER DATABASE EAST_Datamart ADD FILE ( NAME = tblRebateHistory_DF01, FILENAME = 'M:\tblRebateHistory_DF01.mdf', SIZE = 1024MB,MAXSIZE = UNLIMITED,FILEGROWTH = 500MB ) TO FILEGROUP tblRebateHistory_FG1 GO

Files for latest data (2013):


ALTER DATABASE EAST_Datamart ADD FILEGROUP tblRebateHistory_FG2 GO ALTER DATABASE EAST_Datamart ADD FILE ( NAME = tblRebateHistory_DF02, FILENAME = 'M:\tblRebateHistory_DF02.mdf', SIZE = 1024MB,MAXSIZE = UNLIMITED,FILEGROWTH = 500MB

) TO FILEGROUP tblRebateHistory_FG2 GO

Column need partitioning details TblRebateHistory


Table Name
tblRebateHistory

Candidate column for Partitioning DeliveryDate

Filegroup
East_Group

DataFile
tblRebateHistory_df

Data Analysis Pattern (2013) on TblRebateHistory


Year
tblRebateHistory

Records 5638660

2013

Partition Function and partition Scheme


CREATE PARTITION FUNCTION East_PF (datetime) AS RANGE left FOR VALUES ('20130101'); GO CREATE PARTITION SCHEME tblRebateHistory_PS AS PARTITION East_PF TO (tblRebateHistory_FG1, tblRebateHistory_FG2) GO

Indexes on Table ( TblRebateHistory)


Index Name tblRebateHisto ry_Index_1 tblRebateHisto ry_Index_2 Index Description clustered, ignore duplicate keys, unique located on PRIMARY Index Keys InvoiceDate, InvoiceNumber, LineSequenceNumber, RebateHistorySequenceNumber OrderNumber, DeliveryDate, LineSequenceNumber, RebateHistorySequenceNumber

nonclustered located on PRIMARY

Partitioned Aligned Indexes:


All non-clustered indexes will be partitioned aligned as per clustered indexes . (required for sliding window operation)

Clustered index will partition the already created table


Alter table Table_Name; drop constraint Constraint_Name;

Alter Table Add constraint using New file group.

TblMCB_History File Groups and Data Files Distribution


Files for Previous data:
ALTER DATABASE EAST_Datamart ADD FILEGROUP tblMCB_History_FG1 GO ALTER DATABASE EAST_Datamart ADD FILE ( NAME = tblMCB_History_DF01, FILENAME = 'M:\ tblMCB_History_DF01.mdf', SIZE = 1024MB,MAXSIZE = UNLIMITED,FILEGROWTH = 500MB ) TO FILEGROUP tblMCB_History_FG1 GO

Files for latest data (2013):


ALTER DATABASE EAST_Datamart ADD FILEGROUP tblMCB_History_FG2 GO ALTER DATABASE EAST_Datamart ADD FILE ( NAME = tblMCB_History_DF02, FILENAME = 'M:\ tblMCB_History_DF02.mdf', SIZE = 1024MB,MAXSIZE = UNLIMITED,FILEGROWTH = 500MB ) TO FILEGROUP tblMCB_History_FG2 GO

Column need partitioning details TblMCB_History


Table Name
tblMCB_History

Candidate column for Partitioning ExtractDate

Filegroup
East_Group

DataFile
tblMCB_History_df

Data Analysis Pattern (2013) on TblMCB_History


Year
tblMCB_History

Records 4707746

2013

Partition Function and partition Scheme


CREATE PARTITION FUNCTION East_PF (datetime) AS RANGE left FOR VALUES ('20130101'); GO CREATE PARTITION SCHEME tblMCB_History_PS AS PARTITION East_PF TO (tblMCB_History_FG1, tblMCB_History_FG2) GO

Indexes on Table ( TblMCB_History)


Index Name
idx_PeriodEnd_RemitNum ix_Inv ix_prd

Index Description
clustered located on PRIMARY nonclustered located on PRIMARY nonclustered located on PRIMARY

Index Keys
PeriodEnd, RemitNum InvoiceNumber ProductNumber

Partitioned Aligned Indexes:


All non-clustered indexes will be partitioned aligned as per clustered indexes . (required for sliding window operation) Clustered index will partition the already created table
Alter table Table_Name; drop constraint Constraint_Name;

Alter Table Add constraint using New file group.

TblMCBOverpullResultsAuditByDivision

File Groups and Data Files Distribution


Files for Previous data:
ALTER DATABASE EAST_Datamart ADD FILEGROUP tblMCBOverpullResultsAuditByDivision_FG1 GO ALTER DATABASE EAST_Datamart ADD FILE ( NAME = tblMPWDailyOrderHeader_DF01, FILENAME = 'M:\tblMCBOverpullResultsAuditByDivision_DF01.mdf', SIZE = 1024MB,MAXSIZE = UNLIMITED,FILEGROWTH = 500MB ) TO FILEGROUP tblMCBOverpullResultsAuditByDivision_FG1 GO

Files for latest data (2013):


ALTER DATABASE EAST_Datamart ADD FILEGROUP tblMCBOverpullResultsAuditByDivision_FG2 GO ALTER DATABASE EAST_Datamart ADD FILE ( NAME = tblMPWDailyOrderHeader_DF02, FILENAME = 'M:\tblMCBOverpullResultsAuditByDivision_DF02.mdf', SIZE = 1024MB,MAXSIZE = UNLIMITED,FILEGROWTH = 500MB ) TO FILEGROUP tblMCBOverpullResultsAuditByDivision_FG2 GO

Column need partitioning tblMCBOverpullResultsAuditByDivision


Table Name tblMCBOverpullResultsAuditB yDivision Candidate column for Partitioning Deliverydate Filegro up
East_Gro up

DataFile tblMCBOverpullResultsAuditByD ivision_df

Data Analysis Pattern (36-Months) on

tblMCBOverpullResultsAuditByDivision
Year Records

tblMCBOverpullResultsAuditByDivisio

n 2013

9060267

Partition Function and partition Scheme


CREATE PARTITION FUNCTION East_PF (datetime) AS RANGE left FOR VALUES ('20130101'); GO CREATE PARTITION SCHEME tblMCBOverpullResultsAuditByDivision_PS AS PARTITION East_PF TO (tblMCBOverpullResultsAuditByDivision_FG1, tblMCBOverpullResultsAuditByDivision_FG2) GO

Indexes on Table (tblMCBOverpullResultsAuditByDivision)


Index Name idx_MCBOverpullResultsAuditB yDivision Index Description clustered located on PRIMARY Index Keys Division, PricingYear, CalendarMonth, ProductNumber

Partitioned Aligned Indexes:


All non-clustered indexes will be partitioned aligned as per clustered indexes . (required for sliding window operation) Clustered index will partition the already created table
Alter table Table_Name; drop constraint Constraint_Name;

Alter Table Add constraint using New file group.

tblMPWDailyOrderHeader File Groups and Data Files Distribution


Files for Previous data:
ALTER DATABASE National_Datamart ADD FILEGROUP tblMPWDailyOrderHeader_FG1 GO ALTER DATABASE National_Datamart ADD FILE ( NAME = tblMPWDailyOrderHeader_DF01,

FILENAME = 'M:\tblMPWDailyOrderHeader_DF01.mdf', SIZE = 1024MB,MAXSIZE = UNLIMITED,FILEGROWTH = 500MB ) TO FILEGROUP tblMPWDailyOrderHeader_FG1 GO

Files for latest data (2013):


ALTER DATABASE National_Datamart ADD FILEGROUP tblMPWDailyOrderHeader_FG2 GO ALTER DATABASE National_Datamart ADD FILE ( NAME = tblMPWDailyOrderHeader_DF02, FILENAME = 'M:\tblMPWDailyOrderHeader_DF02.mdf', SIZE = 1024MB,MAXSIZE = UNLIMITED,FILEGROWTH = 500MB ) TO FILEGROUP tblMPWDailyOrderHeader_FG2 GO

Column need partitioning details tblMPWDailyOrderHeader


Table Name tblMPWDailyOrderHead er Candidate column for Partitioning InvoiceDate Filegroup
National_Grou p

DataFile tblMPWDailyOrderHeader_ df

Data Analysis Pattern (2013) on tblMPWDailyOrderHeader


tblMPWDailyOrderHeader year 2013 Records 639244

Partition Function and partition Scheme


CREATE PARTITION FUNCTION East_PF (datetime) AS RANGE left FOR VALUES ('20130101'); GO CREATE PARTITION SCHEME tblMPWDailyOrderHeader_PS AS PARTITION East_PF TO (tblMPWDailyOrderHeader_FG1, tblMPWDailyOrderHeader_FG2) GO

Indexes on Table (tblMPWDailyOrderHeader)


index_name idx_Cust idx_DateLoaded idx_MPWWhse idx_OrderType idx_territory ix_RqstDte PK_tblMPWDailyOrde rHeader index_description nonclustered located on PRIMARY nonclustered located on PRIMARY nonclustered located on PRIMARY nonclustered located on PRIMARY nonclustered located on PRIMARY nonclustered located on PRIMARY clustered, unique, primary key located on PRIMARY index_keys CustAccount DateLoaded MPWWarehouseNumber OrderType Territory RequestDate InvoiceDate, OrderNumber, OrderSequenceNumber

Partitioned Aligned Indexes:


All non-clustered indexes will be partitioned aligned as per clustered indexes . (required for sliding window operation) Clustered index will partition the already created table
Alter table Table_Name; drop constraint Constraint_Name;

Alter Table Add constraint using New file group.

tblMPWDailyOrderLines File Groups and Data Files Distribution


Files for Previous data:
ALTER DATABASE National_Datamart ADD FILEGROUP tblMPWDailyOrderLines_FG1 GO ALTER DATABASE National_Datamart ADD FILE ( NAME = tblMPWDailyOrderLines_DF01, FILENAME = 'M:\tblMPWDailyOrderLines_DF01.mdf', SIZE = 1024MB,MAXSIZE = UNLIMITED,FILEGROWTH = 500MB ) TO FILEGROUP tblMPWDailyOrderLines_FG1 GO

Files for latest data (2013):


ALTER DATABASE National_Datamart ADD FILEGROUP tblMPWDailyOrderLines_FG2 GO ALTER DATABASE National_Datamart ADD FILE ( NAME = tblMPWDailyOrderLines_DF02, FILENAME = 'M:\tblMPWDailyOrderLines_DF02.mdf', SIZE = 1024MB,MAXSIZE = UNLIMITED,FILEGROWTH = 500MB ) TO FILEGROUP tblMPWDailyOrderLines_FG2 GO

Column need partitioning details tblMPWDailyOrderLines


Table Name tblMPWDailyOrderLine s Candidate column for Partitioning InvoiceDate Filegroup
National_Grou p

DataFile tblMPWDailyOrderLines_d f

Data Analysis Pattern (2013) on tblMPWDailyOrderLines


tblMPWDailyOrderLines year 2013 Records 22745231

Partition Function and partition Scheme


CREATE PARTITION FUNCTION East_PF (datetime) AS RANGE left FOR VALUES ('20130101'); GO CREATE PARTITION SCHEME tblMPWDailyOrderLines_PS AS PARTITION East_PF TO (tblMPWDailyOrderLines_FG1, tblMPWDailyOrderLines_FG2) GO

Indexes on Table (tblMPWDailyOrderLines)


index_name idx_CustAccount idx_DateLoaded index_description nonclustered located PRIMARY nonclustered located PRIMARY index_keys on CustAccount on DateLoaded

idx_MPWWhse idx_ProductNum ber idx_UPC PK_tblMPWDaily OrderLines

nonclustered located PRIMARY nonclustered located PRIMARY nonclustered located PRIMARY clustered, unique, primary located on PRIMARY

on MPWWarehouseNumber on ProductNumber on UPC key InvoiceDate, OrderNumber, OrderSequenceNumber, LineSeqeunceNumber

Partitioned Aligned Indexes:


All non-clustered indexes will be partitioned aligned as per clustered indexes . (required for sliding window operation) Clustered index will partition the already created table
Alter table Table_Name; drop constraint Constraint_Name;

Alter Table Add constraint using New file group.

tblMPWDailyCreditHeader File Groups and Data Files Distribution


Files for Previous data:
ALTER DATABASE National_Datamart ADD FILEGROUP tblMPWDailyCreditHeader_FG1 GO ALTER DATABASE National_Datamart ADD FILE ( NAME = tblMPWDailyCreditHeader_DF01, FILENAME = 'M:\tblMPWDailyCreditHeader_DF01.mdf', SIZE = 1024MB,MAXSIZE = UNLIMITED,FILEGROWTH = 500MB ) TO FILEGROUP tblMPWDailyCreditHeader_FG1 GO

Files for latest data (2013):


ALTER DATABASE National_Datamart ADD FILEGROUP tblMPWDailyCreditHeader_FG2 GO ALTER DATABASE National_Datamart ADD FILE (

NAME = tblMPWDailyCreditHeader_DF02, FILENAME = 'M:\tblMPWDailyCreditHeader_DF02.mdf', SIZE = 1024MB,MAXSIZE = UNLIMITED,FILEGROWTH = 500MB ) TO FILEGROUP tblMPWDailyCreditHeader_FG2 GO

Column need partitioning details tblMPWDailyCreditHeader


Table Name tblMPWDailyCreditHead er Candidate column for Partitioning InvoiceDate Filegroup
National_Grou p

DataFile tblMPWDailyCreditHeader_ df

Data Analysis Pattern (2013) on tblMPWDailyCreditHeader


tblMPWDailyCreditHeader year Records 2013 75688

Partition Function and partition Scheme


CREATE PARTITION FUNCTION East_PF (datetime) AS RANGE left FOR VALUES ('20130101'); GO CREATE PARTITION SCHEME tblMPWDailyCreditHeader_PS AS PARTITION East_PF TO (tblMPWDailyCreditHeader_FG1, tblMPWDailyCreditHeader_FG2) GO

Indexes on Table (tblMPWDailyCreditHeader)


index_name idx_CustAccount idx_dteLoad PK_tblMPWDailyCredi tHeader index_description nonclustered located on PRIMARY nonclustered located on PRIMARY clustered, unique, primary key located on PRIMARY index_keys CustAccount DateLoaded InvoiceDate, OrderNumber, OrderSequenceNumber

Partitioned Aligned Indexes:

All non-clustered indexes will be partitioned aligned as per clustered indexes . (required for sliding window operation) Clustered index will partition the already created table
Alter table Table_Name; drop constraint Constraint_Name;

Alter Table Add constraint using New file group.

tblMPWDailyCreditLines File Groups and Data Files Distribution


Files for Previous data:
ALTER DATABASE National_Datamart ADD FILEGROUP tblMPWDailyCreditLines_FG1 GO ALTER DATABASE National_Datamart ADD FILE ( NAME = tblMPWDailyCreditLines_DF01, FILENAME = 'M:\tblMPWDailyCreditLines_DF01.mdf', SIZE = 1024MB,MAXSIZE = UNLIMITED,FILEGROWTH = 500MB ) TO FILEGROUP tblMPWDailyCreditLines_FG1 GO

Files for latest data (2013):


ALTER DATABASE National_Datamart ADD FILEGROUP tblMPWDailyCreditLines_FG2 GO ALTER DATABASE National_Datamart ADD FILE ( NAME = tblMPWDailyCreditLines_DF02, FILENAME = 'M:\tblMPWDailyCreditLines_DF02.mdf', SIZE = 1024MB,MAXSIZE = UNLIMITED,FILEGROWTH = 500MB ) TO FILEGROUP tblMPWDailyCreditLines_FG2 GO

Column need partitioning details tblMPWDailyCreditLines


Table Name Candidate column for Filegroup DataFile

Partitioning tblMPWDailyCreditLine s InvoiceDate


National_Grou p

tblMPWDailyCreditLines_d f

Data Analysis Pattern (2013) on tblMPWDailyCreditLines


tblMPWDailyCreditLines year Records 2013 375652

Partition Function and partition Scheme


CREATE PARTITION FUNCTION East_PF (datetime) AS RANGE left FOR VALUES ('20130101'); GO CREATE PARTITION SCHEME tblMPWDailyCreditLines_PS AS PARTITION East_PF TO (tblMPWDailyCreditLines_FG1, tblMPWDailyCreditLines_FG2) GO

Indexes on Table (tblMPWDailyCreditLines)


index_name idx_CustAccount idx_DteLd idx_MPWWareho useNumber idx_ProductNumb er idx_UPC PK_tblMPWDailyC reditLines index_description nonclustered located on PRIMARY nonclustered located on PRIMARY nonclustered located on PRIMARY nonclustered located on PRIMARY nonclustered located on PRIMARY clustered, unique, primary key located on PRIMARY index_keys CustAccount DateLoaded MPWWarehouseNumber ProductNumber UPC InvoiceDate, OrderNumber, OrderSequenceNumber, LineSeqeunceNumber

Partitioned Aligned Indexes:


All non-clustered indexes will be partitioned aligned as per clustered indexes . (required for sliding window operation)

Clustered index will partition the already created table


Alter table Table_Name; drop constraint Constraint_Name;

Alter Table Add constraint using New file group.

tblMPWDailyOrderLines_Remarks File Groups and Data Files Distribution


Files for Previous data:
ALTER DATABASE National_Datamart ADD FILEGROUP tblMPWDailyOrderLines_Remarks_FG1 GO ALTER DATABASE National_Datamart ADD FILE ( NAME = tblMPWDailyOrderLines_Remarks_DF01, FILENAME = 'M:\tblMPWDailyOrderLines_Remarks_DF01.mdf', SIZE = 1024MB,MAXSIZE = UNLIMITED,FILEGROWTH = 500MB ) TO FILEGROUP tblMPWDailyOrderLines_Remarks_FG1 GO

Files for latest data (2013):


ALTER DATABASE National_Datamart ADD FILEGROUP tblMPWDailyOrderLines_Remarks_FG2 GO ALTER DATABASE National_Datamart ADD FILE ( NAME = tblMPWDailyOrderLines_Remarks_DF02, FILENAME = 'M:\tblMPWDailyOrderLines_Remarks_DF02.mdf', SIZE = 1024MB,MAXSIZE = UNLIMITED,FILEGROWTH = 500MB ) TO FILEGROUP tblMPWDailyOrderLines_Remarks_FG2 GO Column needs partitioning details tblMPWDailyOrderLines_Remarks

Table Name tblMPWDailyOrderLines_R emarks

Candidate column for Partitioning InvoiceDate

Filegroup
National_Gr oup

DataFile tblMPWDailyOrderLines_Rem arks_df

Data Analysis Pattern (2013) on tblMPWDailyOrderLines_Remarks


tblMPWDailyOrderLines_Remarks year Records 2013 679017

Partition Function and partition Scheme


CREATE PARTITION FUNCTION East_PF (datetime) AS RANGE left FOR VALUES ('20130101'); GO CREATE PARTITION SCHEME tblMPWDailyOrderLines_Remarks_PS AS PARTITION East_PF TO (tblMPWDailyOrderLines_Remarks_FG1, tblMPWDailyOrderLines_Remarks_FG2) GO

Indexes on Table (tblMPWDailyOrderLines_Remarks)


index_nam e idx_cust idx_ordSeq Dte idx_origPro d index_description nonclustered located on PRIMARY clustered located on PRIMARY nonclustered located on PRIMARY index_keys CustAccount OrderNumber, OrderSequenceNumber, InvoiceDate, LineSequenceNumber OriginalProductOrdered

Partitioned Aligned Indexes:


All non-clustered indexes will be partitioned aligned as per clustered indexes . (required for sliding window operation) Clustered index will partition the already created table
Alter table Table_Name; drop constraint Constraint_Name;

Alter Table Add constraint using New file group.

tbl_MPW_MCBLines File Groups and Data Files Distribution

Files for Previous data:


ALTER DATABASE National_Datamart ADD FILEGROUP tbl_MPW_MCBLines_FG1 GO ALTER DATABASE National_Datamart ADD FILE ( NAME = tbl_MPW_MCBLines_DF01, FILENAME = 'M:\tbl_MPW_MCBLines_DF01.mdf', SIZE = 1024MB,MAXSIZE = UNLIMITED,FILEGROWTH = 500MB ) TO FILEGROUP tbl_MPW_MCBLines_FG1 GO

Files for latest data (2013):


ALTER DATABASE National_Datamart ADD FILEGROUP tbl_MPW_MCBLines_FG2 GO ALTER DATABASE National_Datamart ADD FILE ( NAME = tbl_MPW_MCBLines_DF02, FILENAME = 'M:\tbl_MPW_MCBLines_DF02.mdf', SIZE = 1024MB,MAXSIZE = UNLIMITED,FILEGROWTH = 500MB ) TO FILEGROUP tbl_MPW_MCBLines_FG2 GO

Column need partitioning details tbl_MPW_MCBLines


Table Name Candidate column for Partitioning Filegroup
National_Group

DataFile tbl_MPW_MCBLines_df

tbl_MPW_MCBLines Shipdate

Data Analysis Pattern (2013) on tbl_MPW_MCBLines


tbl_MPW_MCBLines year Records 2013 3027811

Partition Function and partition Scheme


CREATE PARTITION FUNCTION East_PF (datetime) AS RANGE left FOR VALUES ('20130101'); GO

CREATE PARTITION SCHEME tbl_MPW_MCBLines_PS AS PARTITION East_PF TO (tbl_MPW_MCBLines_FG1, tbl_MPW_MCBLines_FG2) GO

Indexes on Table (tbl_MPW_MCBLines)


index_name idx_Cust idx_DateLoaded idx_OrdnumSeqnu mLineKey idx_Prod idx_ShipDate idx_VendorNumber index_description nonclustered located on PRIMARY nonclustered located on PRIMARY clustered, ignore duplicate keys, unique located on PRIMARY nonclustered located on PRIMARY nonclustered located on PRIMARY nonclustered located on PRIMARY index_keys CustomerNumber DateLoaded OrderNumber, OrderSequenceNumber, OrderLineKey ProductNumber Shipdate VendorNumber

Partitioned Aligned Indexes:


All non-clustered indexes will be partitioned aligned as per clustered indexes . (required for sliding window operation) Clustered index will partition the already created table
Alter table Table_Name; drop constraint Constraint_Name;

Alter Table Add constraint using New file group.

tbl_MPW_ProductCostPromoAllowances File Groups and Data Files Distribution


Files for Previous data:
ALTER DATABASE National_Datamart ADD FILEGROUP tbl_MPW_ProductCostPromoAllowances_FG1 GO ALTER DATABASE National_Datamart ADD FILE ( NAME = tbl_MPW_ProductCostPromoAllowances_DF01, FILENAME = 'M:\tbl_MPW_ProductCostPromoAllowances_DF01.mdf', SIZE = 1024MB,MAXSIZE = UNLIMITED,FILEGROWTH = 500MB )

TO FILEGROUP tbl_MPW_ProductCostPromoAllowances_FG1 GO

Files for latest data (2013):


ALTER DATABASE National_Datamart ADD FILEGROUP tbl_MPW_ProductCostPromoAllowances_FG2 GO ALTER DATABASE National_Datamart ADD FILE ( NAME = tbl_MPW_ProductCostPromoAllowances_DF02, FILENAME = 'M:\tbl_MPW_ProductCostPromoAllowances_DF02.mdf', SIZE = 1024MB,MAXSIZE = UNLIMITED,FILEGROWTH = 500MB ) TO FILEGROUP tbl_MPW_ProductCostPromoAllowances_FG2 GO

Column need partitioning tbl_MPW_ProductCostPromoAllowance


Table Name tbl_MPW_ProductCostPromo Allowances Candidate column for Partitioning PricePromoEndDate Filegroup
National_G roup

DataFile tbl_MPW_ProductCostPromoAll owances_df

Data Analysis Pattern (2013) on tbl_MPW_ProductCostPromoAllowance


tbl_MPW_ProductCostPromoAllowances year Records 2013 245153

Partition Function and partition Scheme


CREATE PARTITION FUNCTION East_PF (datetime) AS RANGE left FOR VALUES ('20130101'); GO CREATE PARTITION SCHEME tbl_MPW_ProductCostPromoAllowances_PS AS PARTITION East_PF TO (tbl_MPW_ProductCostPromoAllowances_FG1, tbl_MPW_ProductCostPromoAllowances_FG2) GO

Indexes on Table (tbl_MPW_ProductCostPromoAllowances)


index_name index_description index_keys

ix_ProdStart EndTypeRef

clustered, ignore duplicate keys, unique located on PRIMARY

ProductNumber, CostPromoStartDate, CostPromoEndDate, PromoType, CostPromoReferenceNumber

Partitioned Aligned Indexes:


All non-clustered indexes will be partitioned aligned as per clustered indexes . (required for sliding window operation) Clustered index will partition the already created table
Alter table Table_Name; drop constraint Constraint_Name;

Alter Table Add constraint using New file group.

tbl_MPW_POHeader File Groups and Data Files Distribution


Files for Previous data:
ALTER DATABASE National_Datamart ADD FILEGROUP tbl_MPW_POHeader_FG1 GO ALTER DATABASE National_Datamart ADD FILE ( NAME = tbl_MPW_POHeader_DF01, FILENAME = 'M:\tbl_MPW_POHeader_DF01.mdf', SIZE = 1024MB,MAXSIZE = UNLIMITED,FILEGROWTH = 500MB ) TO FILEGROUP tbl_MPW_POHeader_FG1 GO

Files for latest data (2013):


ALTER DATABASE National_Datamart ADD FILEGROUP tbl_MPW_POHeader_FG2 GO ALTER DATABASE National_Datamart ADD FILE ( NAME = tbl_MPW_POHeader_DF02, FILENAME = 'M:\tbl_MPW_POHeader_DF02.mdf', SIZE = 1024MB,MAXSIZE = UNLIMITED,FILEGROWTH = 500MB ) TO FILEGROUP tbl_MPW_POHeader_FG2 GO

Column need partitioning tbl_MPW_POHeader


Table Name Candidate column for Partitioning Filegroup
National_Group

DataFile tbl_MPW_POHeader_df

tbl_MPW_POHeader ReceivedDate

Data Analysis Pattern (2013) on tbl_MPW_POHeader


tbl_MPW_POHeader year Records 2013 108554

Partition Function and partition Scheme


CREATE PARTITION FUNCTION East_PF (datetime) AS RANGE left FOR VALUES ('20130101'); GO CREATE PARTITION SCHEME tbl_MPW_POHeader_PS AS PARTITION East_PF TO (tbl_MPW_POHeader_FG1, tbl_MPW_POHeader_FG2) GO

Indexes on Table (tbl_MPW_POHeader)


index_name idx_dateloaded idx_ReceivedDate idx_Vend idx_WhsePOTypeVrf yDt PK_tbl_MPW_POHe ader index_description nonclustered located on PRIMARY nonclustered located on PRIMARY nonclustered located on PRIMARY nonclustered located on PRIMARY clustered, unique, primary key located on PRIMARY index_keys DateLoaded ReceivedDate VendorAcctNumber WarehouseOfVendor, POType, VerifyDate PONumber

Partitioned Aligned Indexes:


All non-clustered indexes will be partitioned aligned as per clustered indexes . (required for sliding window operation) Clustered index will partition the already created table
Alter table Table_Name; drop constraint Constraint_Name;

Alter Table Add constraint using new file group.