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


Question on doing a lot of deletes in one Agent job step, keeping the Trans Log from exploding...


Question on doing a lot of deletes in one Agent job step, keeping the Trans Log from exploding...

Author
Message
jasona.work
jasona.work
SSCrazy Eights
SSCrazy Eights (9.8K reputation)SSCrazy Eights (9.8K reputation)SSCrazy Eights (9.8K reputation)SSCrazy Eights (9.8K reputation)SSCrazy Eights (9.8K reputation)SSCrazy Eights (9.8K reputation)SSCrazy Eights (9.8K reputation)SSCrazy Eights (9.8K reputation)

Group: General Forum Members
Points: 9846 Visits: 12526
If I'm going to be doing a lot of large deletes from different tables, via an Agent job, and want to keep the Transaction log from exploding, would this work:

Wrap each delete statement in a begin Transaction / commit?
Similiar to this:
BEGIN TRANSACTION
DELETE TABLENAME WHERE ID NOT IN (SELECT ID FROM SOMEOTHERTABLE)
COMMIT



Yes, I know the not in is going to make these things take a long time each, the DB was here and poorly created well before I started.

The DB is in our QA, and we're clearing out a large chunk of the records so we can then shrink the QA DB down to free up some space in QA.

I could, but would rather not, put in a DBCC SHRINKFILE('DB_Log', 256) after each delete...
To give an idea: When I did just one delete, the log ballooned from ~700MB to ~25000MB. If it grows by almost that much for each delete, I'll run out of disk space for the logs really fast... Seeing as I've got ~40 tables in this one DB to delete from...

Thanks
Jason
GilaMonster
GilaMonster
SSC Guru
SSC Guru (216K reputation)SSC Guru (216K reputation)SSC Guru (216K reputation)SSC Guru (216K reputation)SSC Guru (216K reputation)SSC Guru (216K reputation)SSC Guru (216K reputation)SSC Guru (216K reputation)

Group: General Forum Members
Points: 216371 Visits: 46277
No, that's exactly the same as the delete without a transaction. It's a single statement, so it's implicitly in its own transaction.

Delete in batches, not in a transaction and have checkpoint between them (if the DB is in simple recovery)

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


jasona.work
jasona.work
SSCrazy Eights
SSCrazy Eights (9.8K reputation)SSCrazy Eights (9.8K reputation)SSCrazy Eights (9.8K reputation)SSCrazy Eights (9.8K reputation)SSCrazy Eights (9.8K reputation)SSCrazy Eights (9.8K reputation)SSCrazy Eights (9.8K reputation)SSCrazy Eights (9.8K reputation)

Group: General Forum Members
Points: 9846 Visits: 12526
Cool, thanks!

And yes, I should've mentioned the DB is in Simple recovery.
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