Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Table partitioning automatic procs Expand / Collapse
Author
Message
Posted Monday, June 21, 2010 9:03 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Monday, April 14, 2014 1:41 PM
Points: 57, Visits: 239
Hi,
I am in the process of partitioning a very large database and using the sliding window technique to archive the oldest
partitioned data and move it into an archive table. The tables are partitioned on a date column.
So far I have successfully been able to partition the main table and the archive table and have successfully been able to
switch the oldest partition out of the main table and into the new partition created in the archive table. After many repeated trial it seems to work.
But now I would like to automate the procedure by writing some stored procedures and functions that would automatically switch out the old partition out at the beginning of every month. These stored procedures would be
initiated by a SQL Server Agent job at the beginning of every month.

My question is
1. Is there a better way to work this problem other then stored procedures and jobs.
2. Are there are scripts or white papers out there that have tried to automate the sliding window proc
3. And finally, what the advantages and disadvantages of using this technique?

Thank you in advance for your help. It is very much appreciated.

Jay





Post #940387
Posted Monday, June 21, 2010 5:23 PM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Tuesday, January 28, 2014 8:15 AM
Points: 3,068, Visits: 4,639
jaiki987 (6/21/2010)1. Is there a better way to work this problem other then stored procedures and jobs.
2. Are there are scripts or white papers out there that have tried to automate the sliding window proc
3. And finally, what the advantages and disadvantages of using this technique?

1- I do like automatic processes.
2- Tons. like http://weblogs.sqlteam.com/dang/archive/2008/09/17/Automating-RANGE-RIGHT-Sliding-Window-Maintenance.aspx
3- If properly tested, monitored and documented nothing will beat it; if poorly tested, monitored and documented it may be the reason you get fired.


_____________________________________
Pablo (Paul) Berzukov

Author of Understanding Database Administration available at Amazon and other bookstores.

Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
Post #940697
Posted Tuesday, June 22, 2010 11:09 AM


Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Friday, December 20, 2013 8:21 AM
Points: 61, Visits: 699
2) My favourite is Kim Tripp's WP: http://msdn2.microsoft.com/en-us/library/ms345146.aspx
Ron Talmage has made an update for SQL 2008 here http://msdn.microsoft.com/en-us/library/dd578580.aspx

David B.


David B.
Post #941234
Posted Thursday, June 24, 2010 9:51 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Monday, April 14, 2014 1:41 PM
Points: 57, Visits: 239
Thanks everyone for the replies. Greatly appreciated
I have a couple of more questions on partitioning:

This is the system that I have developed and been testing.

SPLIT -- SWITCH -- MERGE

SPLIT - Create a stored procedure that selects the split date = to the first day of the month
and splits the archive table at that date.

SWITCH - Create a stored procedure to switch the oldest partition with the empty new partition that was created
using the previous procedure

MERGE - Create a stored procedure to merge the empty in the original table so as to remove that partition and

So basically a new empty partition will be created in the archive table. And the oldest partition in the live table will be switched out with the empty partition in the archive table. Then the oldest partition in the live table will be removed by MERGE(ing) the boundary.
I have done several tests and it seems to work.

Question:
1. I see alot of case studies using staging tables, but I will not be using that. The oldest data is being switched out
with a new empty partition created in the archive table
Both the archive and live table have the same table structured, indexes etc
Is a staging table necessary?


Post #942547
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse