Professional Documents
Culture Documents
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.
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.
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
Index Compression:
ALTER INDEX IX_TransactionHistory_ProductID ON Production.TransactionHistory REBUILD PARTITION = 1 WITH (DATA_COMPRESSION = PAGE); GO
TblOrders
Filegroup
East_Group
DataFile
TblOrders_df
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
Filegroup
East_Group
DataFile
TblLines_df
Filegroup
East_Group
DataFile
TblCredit_df
TblCredit
clustered, ignore duplicate keys, unique located on PRIMARY nonclustered located on PRIMARY
Filegroup
East_Group
DataFile
TblReceivedPOheader_df
Filegroup
East_Group
DataFile
TblReceivedPOline_df
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
Filegroup
East_Group
DataFile
tblInventoryHistory_df
Records 12453482
2013-Apr
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
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
Filegroup
East_Group
DataFile
tblAcctsRcvTxnHistory_df
Records 2098065
2013
Index Name Index Description ix_customer nonclustered located on PRIMARY tblAcctsRcvTxnHistory_Index_1 clustered located on PRIMARY
) TO FILEGROUP tblRebateHistory_FG2 GO
Filegroup
East_Group
DataFile
tblRebateHistory_df
Records 5638660
2013
Filegroup
East_Group
DataFile
tblMCB_History_df
Records 4707746
2013
Index Description
clustered located on PRIMARY nonclustered located on PRIMARY nonclustered located on PRIMARY
Index Keys
PeriodEnd, RemitNum InvoiceNumber ProductNumber
TblMCBOverpullResultsAuditByDivision
tblMCBOverpullResultsAuditByDivision
Year Records
tblMCBOverpullResultsAuditByDivisio
n 2013
9060267
DataFile tblMPWDailyOrderHeader_ df
DataFile tblMPWDailyOrderLines_d f
nonclustered located PRIMARY nonclustered located PRIMARY nonclustered located PRIMARY clustered, unique, primary located on PRIMARY
NAME = tblMPWDailyCreditHeader_DF02, FILENAME = 'M:\tblMPWDailyCreditHeader_DF02.mdf', SIZE = 1024MB,MAXSIZE = UNLIMITED,FILEGROWTH = 500MB ) TO FILEGROUP tblMPWDailyCreditHeader_FG2 GO
DataFile tblMPWDailyCreditHeader_ df
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;
tblMPWDailyCreditLines_d f
Filegroup
National_Gr oup
DataFile tbl_MPW_MCBLines_df
tbl_MPW_MCBLines Shipdate
TO FILEGROUP tbl_MPW_ProductCostPromoAllowances_FG1 GO
ix_ProdStart EndTypeRef
DataFile tbl_MPW_POHeader_df
tbl_MPW_POHeader ReceivedDate