Thanks for the question, Somadatta.
Asked: April 18, 2016 - 7:25 pm UTC
Last updated: April 19, 2016 - 12:54 am UTC
Version: sql Server 2008 R2
Viewed 1000+ times
You Asked
Dear All,
I am using Sql Server 2008 R2. we are keeping 60 days worth of data and older than 60 days, we are purging. however, due to some constraint, we did not delete old data. Hence we have 200days extra data not. now the database size is 1TB and 85% has occupied and per day 25 lacs records inserting into the table. Also, data inserting into the table in every millisecond. I would like to know 2 things.
1. why we should delete old data first(example 2013 years data)?
2. what would be best practice chunk size to delete 1 days older data(25 lacs)?
Could you please kindly advice on this?
Regards,
Som
and Connor said...
1) Is your question, "should we delete it?" or "should we delete the oldest stuff first?"
a) "should we delete it" ?
For me, I generally dont like deleting stuff ever, unless there is a reason that *forces* me to, eg, backups take too long, impact on queries, or storage etc. But if I took the effort the store the data in the first place, I'll resist deleting it unless I have to.
b) "should we delete oldest first" ?
I can't speak for SQL Server, but in Oracle, it generally wont make any difference to us, we'll re-use that space over time for new records
2) What would be best practice ?
In a word, use a partitioning strategy. Deleting data is one of the most expensive operations in most databases, because they are typically optimized to store and read it. Dropping a partition is a trivial operation. Deleting millions of rows in that same partition is massively expensive.
But if you're stuck with deleting, then (in the Oracle world), generally you delete in nice big chunks, the limiting factors being:
- how long you're prepared to take locks for
- available undo space
- impact on resources (sometimes its more practical to have 10 small performance spikes during the day, rather than 1 big spike etc)
Hope this helps.
Rating
(1 rating)
Is this answer out of date? If it is, please let us know via a Comment