Table partitioning automatic procs

  • 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

  • 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.
  • 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.

  • 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?

  • Do you have the solution i am looking for something similar....

    @JayMunnangi

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply