Link to home
Start Free TrialLog in
Avatar of tiras gans
tiras gansFlag for United States of America

asked on

MS SQL 2005 purging old data question

I have two question regarding this process:

1 - My vcenter db is 20GB and I am currently deleting data older than 20 days.  Previosly 180 days.  It's going on for 4 hours already.  If not going to complete by the end of busienss tonight.  Can I stop it?  What's the ramification for stopping and restarting again? How can I shorten this process?

2 - I see the log is rasing to 67% of log space used.   What will happen when it'll hit 100%?  Will it crash?  Can I clean it somehow?
vcdb      912.4922       67.37798       0

Thanks in advance!!
ASKER CERTIFIED SOLUTION
Avatar of knightEknight
knightEknight
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
2b ... and if the log file cannot grow, then the delete will roll back.
Actually, in the future if you only want to keep 20 days of data, you may consider first copying the data  you want to keep to a new table for holding, then truncating the original table, then copying the data back from the holding table into the original table.  This will be faster and far less resource intensive than deleting the rows.
-- example:

select *
into my_holding_table
from my_table (nolock)
where mydate > '2010-09-01'
go

-- verify the data in the new table is correct, then do this:

truncate my_table
go

insert into my_table
select * from my_holding_table (nolock)

-- done
Avatar of mmr159
mmr159

Are any of the server resources pegged (CPU/RAM/DISK)?

The ramification for stopping should be nothing other than lost time... assuming no transactions have been committed.  Restarting will probably not help you much.

When your log hits 100%, it will either
- grow if it is set to grow
- error if it is not
- error regardless of grow/no grow and you are out of physical disk space

Often is the case that you can do large operations in several smaller steps faster than in one big step.

You went from pruning > 180 days to > 20... 160 days could be a big difference from the norm (if you run it once per day... you're used to seeing 1 day of deletion)

I recommend you try an dividing up the delete job.
DANG, knightEknight....

I should have posted my answer in batches!! :)
Great minds think alike!  

(and so do ours)

:)
Avatar of tiras gans

ASKER

Yes the RAM pegged by sqlsvr.exe process because the db size is 20GB.  That's why I'm trying to shrink it.  

So if I stop the purge process all the deleted filed will roll back like nothing happened at all?

Thank you for recommendation in batches!  Now I know.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
!
How did it go?  Much better broken down?
Nope.  Truncating and then shriking worked.  Purging did not help and never finished..