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

delete large chunk of data on replicated DB Expand / Collapse
Author
Message
Posted Wednesday, July 16, 2014 9:22 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, September 3, 2014 3:48 PM
Points: 130, Visits: 289
Hi,

I have 4 SQL Servers 2008 with a merge replication. Replication runs every 10 minutes.

Now, my client asked me to delete a large amount of data (almost 2 years of data). What's the best practice? Deleting the data on the published DB and wait for the replication to do its job (which can take a while...), stopping the replication and launch the delete script on the 4 servers simultaneously and setup the replication once it's finished?

any advice would be really appreciate.

thanks a lot for your time and help
Post #1593129
Posted Wednesday, July 16, 2014 9:38 AM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Yesterday @ 2:50 PM
Points: 21,744, Visits: 15,435
What is the size of the database?

What is the speed of the connection between servers?

What is the record count to be deleted?

Those answers will help to understand a better approach.




Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Posting Data Etiquette - Jeff Moden
Hidden RBAR - Jeff Moden
VLFs and the Tran Log - Kimberly Tripp
Post #1593138
Posted Wednesday, July 16, 2014 10:51 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, September 3, 2014 3:48 PM
Points: 130, Visits: 289
SQLRNNR (7/16/2014)
What is the size of the database?

database is about 3 gig

What is the speed of the connection between servers?

one of the server is far away and connection is not that fast (Fair, according to the replication monitor)

What is the record count to be deleted?

don't know, but in the millions, dispersed in several tables

Those answers will help to understand a better approach.


thanks for your help
Post #1593186
Posted Wednesday, July 16, 2014 5:00 PM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 9:56 PM
Points: 2,084, Visits: 3,128
What percentage of the data does the part to be deleted represent? For example, if the database has 100 years of history, then 2 years is a relative pittance. If the db has three years of data total, then 2 years is huge.

SQL DBA,SQL Server MVP('07, '08, '09)

"While in these days of quiet desperation /
As I wander through the world in which I live /
I search everywhere for some new inspiration /
But it's more than cold reality can give /
If I need a cause for celebration /
Or a comfort I can use to ease my mind /
I rely on my imagination /
And I dream of an imaginary time" : the inimitable Mr. Billy Joel
Post #1593324
Posted Thursday, July 17, 2014 7:23 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, September 3, 2014 3:48 PM
Points: 130, Visits: 289
ScottPletcher (7/16/2014)
What percentage of the data does the part to be deleted represent? For example, if the database has 100 years of history, then 2 years is a relative pittance. If the db has three years of data total, then 2 years is huge.


right now, it represents about 50% of the database
Post #1593583
Posted Thursday, July 17, 2014 7:45 AM This worked for the OP Answer marked as solution


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Yesterday @ 2:50 PM
Points: 21,744, Visits: 15,435
So a total database size of 3gb is fairly small.

With the affected rows to be roughly half of the database, that is about 1.5GB which is still pretty small.

Take into account a slower link to one of the replication partners and not wanting to overwhelm that pipe, I would batch process it from a server that is deemed to be the central/master server.


I would create a process that would delete 50k-100k records at a time. Put that in a sql agent job and then have it run once every 15minutes (in this case due to the slower wan link). This should be done relatively quickly, but the delay in between runs is just to give time to let the system process everything, clear buffers and breath.

You can tinker with the timings of the run since the 15min is just a starting point.




Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Posting Data Etiquette - Jeff Moden
Hidden RBAR - Jeff Moden
VLFs and the Tran Log - Kimberly Tripp
Post #1593590
Posted Thursday, July 17, 2014 9:08 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 9:56 PM
Points: 2,084, Visits: 3,128
You could go the redo route if you could afford some brief downtime. Stop replication, delete the data and rebuild indexes, then re-initialize the replication with a fresh snapshot.

SQL DBA,SQL Server MVP('07, '08, '09)

"While in these days of quiet desperation /
As I wander through the world in which I live /
I search everywhere for some new inspiration /
But it's more than cold reality can give /
If I need a cause for celebration /
Or a comfort I can use to ease my mind /
I rely on my imagination /
And I dream of an imaginary time" : the inimitable Mr. Billy Joel
Post #1593670
Posted Sunday, July 20, 2014 8:55 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, September 3, 2014 3:48 PM
Points: 130, Visits: 289
thanks a lot for the suggestions, I'll go that way!

Post #1594400
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse