Why Transaction Log is
Growing!!!
Reasons for Trnsaction Log
Growth
Following
are the basic reasons for Transaction log growth:
- When we do bulk insert/update operation.
- Your database is in Full Recovery model and you are doing Index rebuild operation. Or your database is involved in Mirroring/Log shipping and you are doing Index rebuild operation.
- If you have Replication implemented in your environment and something is failing in that, you may see transaction log growing unexpectedly.
- Check the Auto growth value. I have see most of the times high percentage of this causes transaction log growth.
How to Troubleshoot
- Backup the transaction log if you have enough disk space and your database is not in SIMPLE recovery model.
- We can user DBCC SQLPERF (LOGSPACE) to find out the current used percentage of the transaction log for the specified database.
- There could be some transaction running on the server that could be recovered later. Kill those transactions. We can use the command DBCC OPENTRAN.
- We can try shrinking log file by using command DBCC SHRINKFILE. We may need to user BACKUP LOG with TRUNCATE_ONLY. This is what I use in my QA environment if I face any issues with transaction log growth.
USE <Your DB
Name>
GO
CHECKPOINT
GO
BACKUP LOG
<Your DB Name>
TO <Backup Device Name>
WITH NOFORMAT, INIT, NAME = N'<Your DB
Name>-Transaction Log Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10
GO
DBCC SHRINKFILE(<Name
of the log file>, 1)
GO
No comments:
Post a Comment