Sql-server – How to troubleshoot large transaction log file size

sql servertransaction-log

I'm following up on this Why is my SQL Log File Huge? article.

Looking at the disk usage report, the transaction log space use is practically zero. It shows 99.1% unused.

It is schedule to backup the log every hour for 24hours/day. Every hourly trn file is quite small but there is one backup at round 2AM that is close to the actual database data file size.

If I schedule the hourly log backup from 3AM to the next 1AM, then the next big trn file is 4AM.

If I scheduled the log backup from 4AM to 12AM then the next large trn file is 5AM.

If I schedule the hourly log backup from 12AM to 11:59:59PM then the next large trn file is 2AM.

The pattern seems to be that whatever the first of the next day backup, that trn file will be large.

The recovery mode is set to full. The log is set to 5MB autogrowth and max out at 2TB. I've also tried the Monitoring SQL Server database transaction log space to track the log space used at every hour. At every hour the log spaced used was never bigger than 99MB and most are .8MB in size.

Help is much appreciated!

Best Answer

It's probable that you had a long running query that caused a bunch of transactions. Something like a large batch of inserts/deletes/updates. You can track these down in the query store if you have a recent version of SQL Server, or you can query the plan cache for long running transactions.

Once you've found the query, you can figure out what it's doing and go from there. You may just be stuck with it, but finding out what's causing the large amount of transactions is your first step.

Also, you should be aware that an autogrowth of 5MB is extremely small, and can result in a lot of Virtual Log Files when it grows, which can hinder startup performance. I suggest looking into tuning the growth rate as well.

https://www.brentozar.com/blitz/high-virtual-log-file-vlf-count/