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


Table patitioning / partition switching


Table patitioning / partition switching

Author
Message
Bennett Scharf
Bennett Scharf
SSC Journeyman
SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)

Group: General Forum Members
Points: 95 Visits: 602
Hi,

I'm fairly certain that I know the answer to this question, but would like some validation nonetheless. A large table, with roughly 7 billion rows and 360GB of storage, receives daily updates via a MERGE statement. Some rows are updated, some are inserted, but none are currently deleted. In my mind, such a table is NOT a candidate for partition switching. Do you concur?

Thanks,
Bennett
Jim Foster 80123
Jim Foster 80123
SSC Journeyman
SSC Journeyman (93 reputation)SSC Journeyman (93 reputation)SSC Journeyman (93 reputation)SSC Journeyman (93 reputation)SSC Journeyman (93 reputation)SSC Journeyman (93 reputation)SSC Journeyman (93 reputation)SSC Journeyman (93 reputation)

Group: General Forum Members
Points: 93 Visits: 468
If you can't guarantee that the data to be merged is focused at the most recent data, you have to consider the following example:
Data2010
Data2011
Data2012
Data2013

What happens in your system if you now try to merge more 2010 data (for whatever reason)?

New rows would appear of course.

Keep in mind: these new rows would appear regardless of if the table is partitioned.

Partitioning might put them into the 2011 dataset (depending on how you set up your partition functions)

But with sizable data like you mention (360GB) - you will need a sufficient maintenance window to process logged deletes. If you don't have that window, partitioning will be your only way to "keep up" with rolling purging.

In the example above, it's really not that bad to "add" more 2010 data. It may hang around for a year, but it will eventually purge.

The merge issue you give would not stop me from partitioning this table if otherwise partitioning was a good fit.


Partitioning does add complexity to managing the system. But it's hard to beat for rolling purges of data if the table qualifies to be partitioned.

Are there other concerns?
Bennett Scharf
Bennett Scharf
SSC Journeyman
SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)

Group: General Forum Members
Points: 95 Visits: 602
Hi Jim,

Thank you for your reply. I have a fairly good understanding the process of switching in and switching out. I agree that partitioning would be useful for switching out the old data. What I cannot see is any way to switch in new data since we're bringing it in via a MERGE statement rather than an INSERT statement - or am I overlooking something?

Thanks,
Bennett
Jim Foster 80123
Jim Foster 80123
SSC Journeyman
SSC Journeyman (93 reputation)SSC Journeyman (93 reputation)SSC Journeyman (93 reputation)SSC Journeyman (93 reputation)SSC Journeyman (93 reputation)SSC Journeyman (93 reputation)SSC Journeyman (93 reputation)SSC Journeyman (93 reputation)

Group: General Forum Members
Points: 93 Visits: 468
Hey Bennett,

For switching-in partitions - you're dead on.
As soon as you're doing "Updates" (via the MERGE) partition switching won't help.

I you have a way to split the "new data" into two sets there may be value in...
Split 1: just yesterday's data enters the table via partition switching-in.
Split 2: data older than yesterday enters the table via MERGE (hopefully just a handful of rows)

But just doing the MERGE is a lot less complex. The added complexity of the above logic and adding partitioning would be weighted against the speed value provided. It may not be worth it.

-Jim
Jeff Moden
Jeff Moden
SSC Guru
SSC Guru (219K reputation)SSC Guru (219K reputation)SSC Guru (219K reputation)SSC Guru (219K reputation)SSC Guru (219K reputation)SSC Guru (219K reputation)SSC Guru (219K reputation)SSC Guru (219K reputation)

Group: General Forum Members
Points: 219046 Visits: 42002
SPAM reported.

--Jeff Moden

RBAR is pronounced ree-bar and is a Modenism for Row-By-Agonizing-Row.
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
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