Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Managing Large Data Sets in SQL Server 2005 and 2008


Managing Large Data Sets in SQL Server 2005 and 2008

Author
Message
NewOzzie
NewOzzie
SSC Rookie
SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)

Group: General Forum Members
Points: 42 Visits: 197
Nice article. I've used this type of method often, and this article explains it very well.

Using RowNumber() could be avoided by adding an identity column on the new_purchase table and order the data on insert into new_purchase. This would obviously only work if you can order the data before or on insert into new_purchase.
moadh.bs
moadh.bs
SSC-Enthusiastic
SSC-Enthusiastic (101 reputation)SSC-Enthusiastic (101 reputation)SSC-Enthusiastic (101 reputation)SSC-Enthusiastic (101 reputation)SSC-Enthusiastic (101 reputation)SSC-Enthusiastic (101 reputation)SSC-Enthusiastic (101 reputation)SSC-Enthusiastic (101 reputation)

Group: General Forum Members
Points: 101 Visits: 140
Thanks Zach, Great Article,
But I wonder if selecting the hole "new_purchase" table each loop, would decrease the performance.
Am I wrong ?
Scott Abrants
Scott Abrants
Valued Member
Valued Member (67 reputation)Valued Member (67 reputation)Valued Member (67 reputation)Valued Member (67 reputation)Valued Member (67 reputation)Valued Member (67 reputation)Valued Member (67 reputation)Valued Member (67 reputation)

Group: General Forum Members
Points: 67 Visits: 405
Nice article with a nice complete example.
Good work and thank you for the ideas - keep them coming.
Br. Kenneth Igiri
Br. Kenneth Igiri
SSC-Enthusiastic
SSC-Enthusiastic (173 reputation)SSC-Enthusiastic (173 reputation)SSC-Enthusiastic (173 reputation)SSC-Enthusiastic (173 reputation)SSC-Enthusiastic (173 reputation)SSC-Enthusiastic (173 reputation)SSC-Enthusiastic (173 reputation)SSC-Enthusiastic (173 reputation)

Group: General Forum Members
Points: 173 Visits: 446
Nice article Zach. I think this will work for me. I have a very large table in my production database. The consultant has exonerated himself from any adverse outcome if we attempt partitioning. So I am lft with the 'safe' option of moving data to a separate instance.

I intend to replace the BEGIN TRANSACTION block in the SP with the columns in the large table. Thus the SP will move data into a replica table in another instance which will be used for long term reproting.

If you asked why not use replication or otherwise answer is we only need a fraction of the data in live fro day to day reporting while the offline instance will be like an archive.

If I do tis once, I can now schedule say a monthly movement of this data to manage the production able size.

What do you think?

Br. Kenneth Igiri
www.scribblingsage.com
www.igiribooks.com
"All nations come to my light, all kings to the brightness of my rising"Smooooth
zmided
zmided
Forum Newbie
Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)

Group: General Forum Members
Points: 6 Visits: 76
OK, so I think what you are saying is that you have a very large table that you need to report against, but you only need a relatively small amount of the data for your production environment.

If your challenge is supporting reports against this large data set, you might want to consider directly going against the production table while using the WITH (NOLOCK) statement to avoid locks that might tie things up. You can also use the OPTION (MAXDOP 1) statement for your report queries to limit the number of processors that are used for processing and thus leave the other processors available to handle production requests.

Another approach is as you suggested. You can set up a monthly routine that will copy groups of rows (10,000-400,00 at a time would be my recommendation) from production into your reporting instance and then in the same transaction, delete those rows from production. That should work just fine for you too.

I have used partitioning extensively, and it works absolutely great. It can improve performance to an amazing degree by flattening the indexes and leveraging multiple processors.

You can also use partitioning for an easier and more efficient solution for archiving data from production into a reporting instance. To do this you would create two separate tables, one for production and one for reporting. Partition each table by date (probably one month per partition). Have each table have identical partition file groups and indexes. Initially the production table would contain all of the data and the reporting table would be empty. You can then move a month at a time by using this command:
ALTER TABLE BigTableInProduction
SWITCH PARTITION <partition number of month to be moved> TO BigTableInReporting PARTITION <partition number of month to be moved>

Regardless of how much data is in the table, the statement should just take a second or two to run -- seriously, it goes that fast. The downside is that managing the partitions does require some additional DBA effort.

Let me know if you have any more questions.

Zach Mided
www.AllianceGlobalServices.com
Br. Kenneth Igiri
Br. Kenneth Igiri
SSC-Enthusiastic
SSC-Enthusiastic (173 reputation)SSC-Enthusiastic (173 reputation)SSC-Enthusiastic (173 reputation)SSC-Enthusiastic (173 reputation)SSC-Enthusiastic (173 reputation)SSC-Enthusiastic (173 reputation)SSC-Enthusiastic (173 reputation)SSC-Enthusiastic (173 reputation)

Group: General Forum Members
Points: 173 Visits: 446
Thanks very much Zack.

You mean SWITCH really works that fast? That will be great.

The table I am refering to is mostly used for reporting anyway, we just need to manage the size to improve performance. Another scenario, what if I want the history table in another instance on another host. That is, I do not want to create a new table on the live instance. Is it feasible to use maybe linked servers to acheive this. What other options?

In addtion, the SWITCH command assumes my production table is partitioned, right? I may not be allowed (by the consultant) to partition this table and thats the big challenge.

Br. Kenneth Igiri
www.scribblingsage.com
www.igiribooks.com
"All nations come to my light, all kings to the brightness of my rising"Smooooth
zmided
zmided
Forum Newbie
Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)

Group: General Forum Members
Points: 6 Visits: 76
Yes, the SWITCH requires partitioning.

Linked Servers do allow separate db servers to connect to one another. Other approaches such as replication and log shipping are used to keep the data the same in both tables which is not what you are trying to do, so linked servers is probably the best approach for you.

Zach Mided
www.AllianceGlobalServices.com
Br. Kenneth Igiri
Br. Kenneth Igiri
SSC-Enthusiastic
SSC-Enthusiastic (173 reputation)SSC-Enthusiastic (173 reputation)SSC-Enthusiastic (173 reputation)SSC-Enthusiastic (173 reputation)SSC-Enthusiastic (173 reputation)SSC-Enthusiastic (173 reputation)SSC-Enthusiastic (173 reputation)SSC-Enthusiastic (173 reputation)

Group: General Forum Members
Points: 173 Visits: 446
Thanks so much Zach.

Finally (hopefully :-)), did you use separate disks for your partitions? How bad can putting all your file group on the same disk/spindle be? (due to cost issues for example).

Also my table is already almost 180 GB. How long do you think it will take to create partitions it?

Br. Kenneth Igiri
www.scribblingsage.com
www.igiribooks.com
"All nations come to my light, all kings to the brightness of my rising"Smooooth
zmided
zmided
Forum Newbie
Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)

Group: General Forum Members
Points: 6 Visits: 76
I used separate disks in order to partition my tables (the largest was 400GB). You will still get some gains even if your file groups are on the same disk, so I would not let that deter you.

The initial creation of the partitions can definitely take a while. I would recommend creating just one partition and doing it at the beginning of off-hours. Surround the SQL partitioning call with SELECT getdate() so you can get a good measurement of how long it takes to create one partition. That will help you plan for creating the additional partitions.

Zach Mided
www.AllianceGlobalServices.com
Br. Kenneth Igiri
Br. Kenneth Igiri
SSC-Enthusiastic
SSC-Enthusiastic (173 reputation)SSC-Enthusiastic (173 reputation)SSC-Enthusiastic (173 reputation)SSC-Enthusiastic (173 reputation)SSC-Enthusiastic (173 reputation)SSC-Enthusiastic (173 reputation)SSC-Enthusiastic (173 reputation)SSC-Enthusiastic (173 reputation)

Group: General Forum Members
Points: 173 Visits: 446
Thank you so much Zach.

Br. Kenneth Igiri
www.scribblingsage.com
www.igiribooks.com
"All nations come to my light, all kings to the brightness of my rising"Smooooth
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