Merging partitions in SQL 2005

Today I have played with partition merging. The target of this was to see how long it can take, which locks are being held etc.

I see that even if partions are empty, the minimum time that it takes is 30 sec ( 2x2.66 CPU 7Gb RAM ). Most of the merge time the folowing system tables are locked exclusive which means that no new query compilations, no schema changes are not allowed: sysrowsetrefs,sysrowsets,sysallocunits,syssingleobjrefs, sysobjvalues,syshobtcolumns,sysrowsetcolumns,sysserefs,syshobts,sysschobjs,sysclsobjs. If there are any schema modification processes running in the database or any data modification processes merge of course waits till those are finished and it can aquire the required locks.
If there are other tables that reside on the same partition function, Sch-M locks are placed on them.
Regardless of partition sizes, the merged partition will reside on the filegroup that did not hold the merged boundary. This means that is you need to merge many partitions, start from the most recent partitions:
For instance you have 4 partitions that you need to merge
Feb 500000 rows
March 500000 rows
April 500000 rows
May 500000 rows

Start with merging april data to may, then march data to april+may, then feb data to the march+ may. This way you move each time only 500000 rows.

Comments

Popular posts from this blog

SQL Awesomeness: Finding a QUALIFY query clause in the depths of the database ocean

The Greatest Reasons to use or not to use a Centralized Data Access Architecture

Look back and realize how far you came