- Check recovery model
- Full Recovery model keeps all log entries until a log backup occurs.
- If you don't take regular log backups, the log will just keep growing. If you don't need point-in-time recovery, consider switching to Simple Recovery Model.
ALTER DATABASE [YourDB] SET RECOVERY SIMPLE;
- Schedule regular log backups
- If you need Full Recovery, you must run transaction log backups frequently.
- This truncates inactive portions of the log and prevents growth. Example SQL Agent job:
BACKUP LOG [YourDB] TO DISK = 'E:\SQLBackups\YourDB_Log.trn' WITH INIT;
Schedule every 15 minutes (or based on workload).
- Monitor log reuse waits
Check why the log isn't being reused:
DBCC SQLPERF(LOGSPACE);
SELECT name, log_reuse_wait_desc
FROM sys.databases;
Common blockers:
-
LOG_BACKUP→ No log backup taken -
ACTIVE_TRANSACTION→ A long-running transaction is preventing truncation -
REPLICATION→ Replication not keeping up -
AVAILABILITY_REPLICA→ AG/replica sync issues
- Manage long-running transactions
- Open transactions (ETL, batch jobs, index rebuilds) keep log records until they finish.
- Identify them with:
DBCC OPENTRAN([YourDB]);
- Size and autogrowth settings
- Pre-size log file to expected needs rather than letting it grow in small increments.
- Avoid percentage autogrowth; use fixed MB growth (e.g., 512MB).
- Regular maintenance
- Ensure index maintenance and large updates are batched to avoid massive log usage.
- If rebuilding indexes, consider
ONLINE = ONandSORT_IN_TEMPDB = ONto reduce log impact.
If the above response helps answer your question, remember to "Accept Answer" so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.
hth
Marcin