SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Automate Sliding Window Partition Management: Part I


Automate Sliding Window Partition Management: Part I

Author
Message
willtwc
willtwc
Old Hand
Old Hand (375 reputation)Old Hand (375 reputation)Old Hand (375 reputation)Old Hand (375 reputation)Old Hand (375 reputation)Old Hand (375 reputation)Old Hand (375 reputation)Old Hand (375 reputation)

Group: General Forum Members
Points: 375 Visits: 384
I have implemented partitioning on a few larges tables. However, I switch over to single filegroup for ease of maintenance or lack of filegroup maintenance.

The underlying logical drives has 20 odd physical disks. Having each file in each filegroup does not make much difference in my setup.
Hugh Scott
Hugh Scott
SSChasing Mays
SSChasing Mays (658 reputation)SSChasing Mays (658 reputation)SSChasing Mays (658 reputation)SSChasing Mays (658 reputation)SSChasing Mays (658 reputation)SSChasing Mays (658 reputation)SSChasing Mays (658 reputation)SSChasing Mays (658 reputation)

Group: General Forum Members
Points: 658 Visits: 190
@Lamprey13,

In reviewing the other two parts, I don't think I specifically address the idea of avoiding data movement (data moving from one file or file group to another because of changes to partition boundaries). However, that was one of my primary goals in implementing partitioning.

In the context of the sample database and the partitions that are included in this series, the method to avoid unnecessary data movement is to schedule the scripts to run just prior to the end of the month (in our case, a couple of days before the end of the month).

- SplitPartition.ps1 (covered next week) will create a new "top end" partition. By running it just before the end of the month *before new records are inserted beyond the new boundary date*, you can avoid data movement.

- MergePartition.ps1 (covered on the 28th) will eliminate the lowest trailing edge partition. This can really be done any time (in accordance with business rules and retention policy). MergePartition.ps1 avoids data movement by "switching" the data into a staging table on the same file group as the data that is to be removed, then dropping the partition and finally dropping the staging tables. In addition, it cleans up the files and file groups that are associated with the dropped partition.

By scheduling both scripts to run at the same time, I have a single job to track.

I should really have added this into the introduction or the summary of the series, but I'm glad that you pointed it out.

Regards,

Hugh



bpportman 52825
bpportman 52825
SSC Veteran
SSC Veteran (266 reputation)SSC Veteran (266 reputation)SSC Veteran (266 reputation)SSC Veteran (266 reputation)SSC Veteran (266 reputation)SSC Veteran (266 reputation)SSC Veteran (266 reputation)SSC Veteran (266 reputation)

Group: General Forum Members
Points: 266 Visits: 400
Is there any performance gain when partitions are on the same set of spindles (can be same file group or different)?
amenjonathan
amenjonathan
SSC Eights!
SSC Eights! (826 reputation)SSC Eights! (826 reputation)SSC Eights! (826 reputation)SSC Eights! (826 reputation)SSC Eights! (826 reputation)SSC Eights! (826 reputation)SSC Eights! (826 reputation)SSC Eights! (826 reputation)

Group: General Forum Members
Points: 826 Visits: 434
Thanks merlin for your reply and Hugh for this article. Looking forward to the next two installments.

Anybody have any idea what happens when you do not add the partitioned column to an index? Does it still create an aligned index (by secretly adding it anyway)?

-------------------------------------------------------------------------------------------------
My SQL Server Blog
Hugh Scott
Hugh Scott
SSChasing Mays
SSChasing Mays (658 reputation)SSChasing Mays (658 reputation)SSChasing Mays (658 reputation)SSChasing Mays (658 reputation)SSChasing Mays (658 reputation)SSChasing Mays (658 reputation)SSChasing Mays (658 reputation)SSChasing Mays (658 reputation)

Group: General Forum Members
Points: 658 Visits: 190
amenjonathan (12/14/2010)
Thanks merlin for your reply and Hugh for this article. Looking forward to the next two installments.

Anybody have any idea what happens when you do not add the partitioned column to an index? Does it still create an aligned index (by secretly adding it anyway)?


Nope. The index gets created on the default file group. Not that I would know from experience!:-D

Regards,

Hugh



Hugh Scott
Hugh Scott
SSChasing Mays
SSChasing Mays (658 reputation)SSChasing Mays (658 reputation)SSChasing Mays (658 reputation)SSChasing Mays (658 reputation)SSChasing Mays (658 reputation)SSChasing Mays (658 reputation)SSChasing Mays (658 reputation)SSChasing Mays (658 reputation)

Group: General Forum Members
Points: 658 Visits: 190
bpportman 52825 (12/14/2010)
Is there any performance gain when partitions are on the same set of spindles (can be same file group or different)?


There's probably something to be gained from parallel query processing. I seem to recall that 2008 resolves some issues related to parallel query processing and partitions that were problematic in 2005.

However, performance for us was not the driving factor for partitioning the tables. I have had some very painful experiences dealing with poorly thought out purge strategies that kill performance, explode transaction logs and otherwise make a general mess of things. My primary goal was to create a fast, extensible process to purge lots of data very quickly each month with minimal impact to other processes.

Regards,

Hugh Scott



Chris Hamam
Chris Hamam
SSC Veteran
SSC Veteran (214 reputation)SSC Veteran (214 reputation)SSC Veteran (214 reputation)SSC Veteran (214 reputation)SSC Veteran (214 reputation)SSC Veteran (214 reputation)SSC Veteran (214 reputation)SSC Veteran (214 reputation)

Group: General Forum Members
Points: 214 Visits: 553
Hugh Scott (12/14/2010)
amenjonathan (12/14/2010)
Thanks merlin for your reply and Hugh for this article. Looking forward to the next two installments.

Anybody have any idea what happens when you do not add the partitioned column to an index? Does it still create an aligned index (by secretly adding it anyway)?


Nope. The index gets created on the default file group. Not that I would know from experience!:-D

Regards,

Hugh



From vague memory and recollections of BoL, the partitioned column is added (as an included column) to a non-clustered index only if there is no clustered index... although please don't quote me on this!

--Chris Hamam

Life's a beach, then you DIE (Do It Eternally)
jimmy.kooruvelil
jimmy.kooruvelil
Forum Newbie
Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)

Group: General Forum Members
Points: 7 Visits: 150
Thanks Hugh for the article which came on the right time for me.

I am about start working on a partitioning a "continuous loading" event table. The requiremnt is to have 12 months of data online and the data aged "gracefully".
I will have 12 data partitions + the lower partition. Each partiton will have its own file group, to ensure the most important aspect of recoverability. In case of DR, I can restore the filegroup which contains the current partion and the system is ready to go. It is about 10GB data in each partition, so no need to wait for 120 GB data to be restored to have the system available. IMHO partition/filegroup alignment is very important from point of system availability.

Sliding window will be implemented to switch in and switch out partitions.

Few thoughts/questions below.

1. Rather than sliding the window that moves forward in time by creating new partitions, can we use a "rotating window" which uses partitions in a ring structure? In this scenario we have a partition scheme with fixed names for each month. The script identities the new month and decides which partition will be used within the "ring". Then switches out data using a temp table on that filegroup to archive, truncate the table and switch back in for the new month. The advantage is that the partition number could be easily identified with current month. Any thoughts on this ?

2. I would love to to keep current quarter data on a filegroup on faster (RAID 10) disk (which handles the loading and most 80 percent of user queries) and previous quarters on slower disks until it get archived to very very slow disk. This means I have to switch out data between quarters which involves data movement. This would have ensured that the data is "aged gracefully". Any thoughts on this ?

Regards

Jimmy
amenjonathan
amenjonathan
SSC Eights!
SSC Eights! (826 reputation)SSC Eights! (826 reputation)SSC Eights! (826 reputation)SSC Eights! (826 reputation)SSC Eights! (826 reputation)SSC Eights! (826 reputation)SSC Eights! (826 reputation)SSC Eights! (826 reputation)

Group: General Forum Members
Points: 826 Visits: 434
Chris Hamam (12/15/2010)
Hugh Scott (12/14/2010)
amenjonathan (12/14/2010)
Thanks merlin for your reply and Hugh for this article. Looking forward to the next two installments.

Anybody have any idea what happens when you do not add the partitioned column to an index? Does it still create an aligned index (by secretly adding it anyway)?


Nope. The index gets created on the default file group. Not that I would know from experience!:-D

Regards,

Hugh



From vague memory and recollections of BoL, the partitioned column is added (as an included column) to a non-clustered index only if there is no clustered index... although please don't quote me on this!


I think this is impossible actually. You must have a clustered index on the partitioned column in order to create a partitioned table. But in the same thread, every non-clustered index contains the clustered index as a reference, unless I'm remembering incorrectly. A non-clustered index on a heap table...not sure what the heck is going on in that scenario. haha!

-------------------------------------------------------------------------------------------------
My SQL Server Blog
willtwc
willtwc
Old Hand
Old Hand (375 reputation)Old Hand (375 reputation)Old Hand (375 reputation)Old Hand (375 reputation)Old Hand (375 reputation)Old Hand (375 reputation)Old Hand (375 reputation)Old Hand (375 reputation)

Group: General Forum Members
Points: 375 Visits: 384
1. Rather than sliding the window that moves forward in time by creating new partitions, can we use a "rotating window" which uses partitions in a ring structure? In this scenario we have a partition scheme with fixed names for each month. The script identities the new month and decides which partition will be used within the "ring". Then switches out data using a temp table on that filegroup to archive, truncate the table and switch back in for the new month. The advantage is that the partition number could be easily identified with current month. Any thoughts on this ?


the problem is your oldest partition is most likely be partition no 2. you will need swap in the latest data into whole new partition because you need to insert a new boundary into the partition scheme.

ALTER PARTITION FUNCTION ' @partitionscheme' () SPLIT RANGE

To remove the boundary of the oldest partition, you issue the MERGE command.

2. I would love to to keep current quarter data on a filegroup on faster (RAID 10) disk (which handles the loading and most 80 percent of user queries) and previous quarters on slower disks until it get archived to very very slow disk. This means I have to switch out data between quarters which involves data movement. This would have ensured that the data is "aged gracefully". Any thoughts on this ?


This will not work because in order for you to switch in and out of partitions, you need to be in the same filegroup.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search