I had to delete around 600K
records daily from a table. The problem I am facing is that whenever delete happens, the log database size increases to 1 GB
. Even after the delete operation has been done, log database size doesn't shrink to its normal size. This is a problem as log DB size is increasing to 1 GB
every day.
I cannot use truncate
as table to be deleted is being referenced by other tables.
Best Answer
When you perform a transaction - like deleting 600K records all at once - SQL Server has to log what it's doing in the transaction log file as it works.
Say the process takes 5 minutes, and 4 minutes into it, the server reboots for some reason. SQL Server starts up, opens the log file, and then needs to undo all that work (because the transaction never committed.
To avoid having a log file that large, you can: