How to Check Transaction Log Usage on RDS for SQL Server
Published 2026-08-13 · Updated 2026-08-13 · Last Verified 2026-08-13
Answer
To check transaction log usage, use `DBCC SQLPERF(LOGSPACE)` for the whole instance, or `sys.dm_db_log_space_usage` (SQL Server 2012 and later) for a specific database. If usage does not go down, check `log_reuse_wait_desc` in `sys.databases` — the reason the log cannot be reused appears in this single column. All the check SQL here is read-only and can also be run on Amazon RDS.
Applicability of This Document
| Product | SQL Server / Amazon RDS for SQL Server / Azure SQL Managed Instance |
|---|---|
| Verified Versions | SQL Server 2008 and later (`sys.dm_db_log_space_usage` requires SQL Server 2012 or later) |
| Environment | On-premises, EC2, Amazon RDS, Azure |
| Required Permissions | `DBCC SQLPERF(LOGSPACE)` and `sys.dm_db_log_space_usage` require VIEW SERVER STATE. `sys.databases` follows metadata visibility rules |
| Execution Impact | Read-only (does not change data, settings, or log contents) |
| Restart | Not required |
| Last Verified | 2026-08-13 |
Ready-to-Run Commands
- 対象
- SQL Server 2008 and later / Amazon RDS for SQL Server
- 権限
- VIEW SERVER STATE
- 変更作業
- None (read-only)
- Production実行
- Safe to run
-- 対象: SQL Server 2008 以降 / Amazon RDS for SQL Server
-- 権限: VIEW SERVER STATE
-- 変更作業: なし(参照のみ)
-- Production 実行: 可能
DBCC SQLPERF(LOGSPACE);Returns one row per database on the instance, showing the current log file size (MB) and usage (%). Use this first to identify which database's log is filling up.
- 対象
- SQL Server 2012 and later / Amazon RDS for SQL Server
- 権限
- VIEW SERVER STATE
- 変更作業
- None (read-only)
- Production実行
- Safe to run
-- 対象: SQL Server 2012 以降 / Amazon RDS for SQL Server
-- 権限: VIEW SERVER STATE
-- 変更作業: なし(参照のみ)
-- Production 実行: 可能
USE [SampleDB];
GO
SELECT
DB_NAME(database_id) AS database_name,
total_log_size_in_bytes / 1024 / 1024 AS total_log_size_mb,
used_log_space_in_bytes / 1024 / 1024 AS used_log_space_mb,
used_log_space_in_percent AS used_log_space_pct,
log_space_in_bytes_since_last_backup / 1024 / 1024 AS log_since_last_backup_mb
FROM sys.dm_db_log_space_usage;This dynamic management view returns only the one currently connected database. To check multiple databases, switch with `USE`, or get the overall picture first with `DBCC SQLPERF(LOGSPACE)`. `log_space_in_bytes_since_last_backup` is the amount of log generated since the last log backup.
- 対象
- SQL Server 2008 and later / Amazon RDS for SQL Server
- 権限
- Metadata visibility on `sys.databases` (equivalent to VIEW ANY DATABASE)
- 変更作業
- None (read-only)
- Production実行
- Safe to run
-- 対象: SQL Server 2008 以降 / Amazon RDS for SQL Server
-- 権限: sys.databases のメタデータ可視性
-- 変更作業: なし(参照のみ)
-- Production 実行: 可能
SELECT
d.name AS database_name,
d.state_desc AS database_state,
d.recovery_model_desc AS recovery_model,
d.log_reuse_wait AS log_reuse_wait_id,
d.log_reuse_wait_desc AS log_reuse_wait_desc,
d.is_cdc_enabled AS is_cdc_enabled,
d.is_published AS is_published,
d.is_subscribed AS is_subscribed
FROM sys.databases AS d
WHERE d.database_id > 4 -- システムデータベースを除外
ORDER BY d.name;This is the most important column in this article. The main values mean: NOTHING = nothing is blocking reuse. CHECKPOINT = checkpoint not yet complete (usually temporary). LOG_BACKUP = waiting for a log backup under the full/bulk-logged recovery model. ACTIVE_TRANSACTION = an open transaction exists. REPLICATION = transactional replication or CDC is holding unread log. AVAILABILITY_REPLICA = synchronization to an availability group secondary is lagging. DATABASE_MIRRORING = mirroring is suspended or lagging. ACTIVE_BACKUP_OR_RESTORE = a backup or restore is in progress. You may also see DATABASE_SNAPSHOT_CREATION, LOG_SCAN, OLDEST_PAGE, XTP_CHECKPOINT, and others.
- 対象
- SQL Server 2008 and later / Amazon RDS for SQL Server
- 権限
- Connection permission to the target DB
- 変更作業
- None (read-only)
- Production実行
- Safe to run
-- 対象: SQL Server 2008 以降 / Amazon RDS for SQL Server
-- 権限: 対象DBへの接続権限
-- 変更作業: なし(参照のみ)
-- Production 実行: 可能
USE [SampleDB];
GO
SELECT
DB_NAME() AS database_name,
f.file_id,
f.name AS logical_name,
f.type_desc,
f.size * 8 / 1024 AS current_size_mb,
CASE
WHEN f.max_size IN (-1, 268435456) THEN NULL -- 無制限扱い
ELSE f.max_size * 8 / 1024
END AS max_size_mb,
CASE
WHEN f.is_percent_growth = 1 THEN CAST(f.growth AS varchar(10)) + ' %'
ELSE CAST(f.growth * 8 / 1024 AS varchar(10)) + ' MB'
END AS autogrowth,
(f.size - CAST(FILEPROPERTY(f.name, 'SpaceUsed') AS bigint)) * 8 / 1024 AS free_space_mb
FROM sys.database_files AS f
WHERE f.type_desc = 'LOG';If `max_size` on a log file is -1 (or 268435456), it is treated as unlimited. When autogrowth is set as a "%", the growth increment balloons as the file gets larger, so a fixed MB value is easier to manage.
How to Read the Results
| Column | Meaning | What to Check |
|---|---|---|
| Database Name | The database name returned by `DBCC SQLPERF(LOGSPACE)` | Identify which database's log is filling up |
| Log Size (MB) | Current size of the log file | If larger than expected, autogrowth has likely fired repeatedly in the past |
| Log Space Used (%) | Log usage percentage | If it stays high or does not drop, check `log_reuse_wait_desc` |
| used_log_space_in_percent | Usage percentage returned by `sys.dm_db_log_space_usage` | Sample every few minutes and watch whether it drops; if it does not, release is being blocked |
| log_space_in_bytes_since_last_backup | Amount of log generated since the last log backup | If it keeps growing, a log backup may not be happening |
| recovery_model_desc | Recovery model (FULL / BULK_LOGGED / SIMPLE) | If FULL but there is no log backup, the log will not be released |
| log_reuse_wait_desc | Reason the log cannot be reused | A value other than NOTHING that persists points to the root cause |
| is_cdc_enabled / is_published | Whether CDC / replication is enabled | When `log_reuse_wait_desc = REPLICATION`, use this to tell which one is responsible |
When to Use This
- Only the log file keeps growing, and storage free space keeps shrinking
- Writes fail with error 9002, "The transaction log for the database is full"
- Shrinking the log only causes it to grow back to its original size almost immediately
- Log usage does not drop even though automated backups are configured on Amazon RDS
Possible Causes (Most Likely First)
01
Recovery model is FULL but no log backups are being taken (LOG_BACKUP)
Under the full recovery model, log space is not reused until a log backup is taken. The most common cause of this symptom is setting the recovery model to FULL without ever setting up a log backup routine.
02
A transaction has been open for a long time (ACTIVE_TRANSACTION)
Log records after the oldest uncommitted transaction cannot be truncated. This happens when an application leaves a `BEGIN TRAN` open, or a batch job has crashed and is mid-rollback.
03
Replication or CDC is holding unread log (REPLICATION)
If the Log Reader Agent for transactional replication, or the CDC capture job, has stopped, log that has not yet been read stays unreleased.
04
Availability group / mirroring synchronization lag (AVAILABILITY_REPLICA / DATABASE_MIRRORING)
Log is retained until it has been sent to and applied on the secondary. A stopped secondary or network lag causes log to accumulate.
05
A long-running backup or restore is in progress (ACTIVE_BACKUP_OR_RESTORE)
The log cannot be truncated while a large database backup is running. Check whether the issue resolves once the backup completes.
06
A large update within a single transaction
Running a bulk delete or update of tens of millions of rows as one transaction requires log space for the whole operation until it commits. Log size depends on how transactions are scoped.
Diagnostic Steps
- 1
Get log usage for all databases
Read-onlyRun `DBCC SQLPERF(LOGSPACE)` to identify databases with high usage.
- 2
Check `log_reuse_wait_desc`
Read-onlyQuery `sys.databases` and see whether the value persists as something other than NOTHING. This largely determines the category of the cause.
- 3
Cross-check the recovery model against log backup history
Read-onlyIf `recovery_model_desc` is FULL, filter `msdb.dbo.backupset` on `type = 'L'` (log backup) to check the time of the most recent log backup.
- 4
Find any open transactions
Read-onlyIf `log_reuse_wait_desc = ACTIVE_TRANSACTION`, identify the oldest transaction using `sys.dm_tran_active_transactions` or similar.
- 5
Check the state of CDC / replication
Read-onlyIf `log_reuse_wait_desc = REPLICATION`, check whether the CDC capture job and the Log Reader Agent are running.
- 6
Re-sample every few minutes and watch the trend
Read-onlyA transient CHECKPOINT or LOG_SCAN value will return to NOTHING on the next sample. Do not judge based on a single reading.
Solutions
Low-risk action that can be done immediately
Resolve the underlying cause first
LowResolving whatever `log_reuse_wait_desc` points to — an open transaction, a stopped CDC job, a lagging secondary — lets usage drop on the next log truncation. Do this before touching the file itself.
Check whether log backups are actually happening
Read-onlyOn-premises or on EC2, check whether the log backup job is succeeding. On Amazon RDS, backups are managed by RDS itself, so check that the backup retention setting is consistent with the recovery model.
Free up space temporarily
MediumIn an emergency where writes have stopped, check the log file's autogrowth ceiling and available disk space, and if necessary revisit the log file's max size and growth settings. Changing these settings affects file size.
Change requiring advance review
Split large updates into batches
LowSplit bulk deletes/updates into transactions of a few thousand to tens of thousands of rows and commit frequently. This caps the amount of log a single transaction holds.
Revisit autogrowth settings
MediumChange a "%" growth setting to a fixed MB value, and set an initial size large enough to absorb the expected peak. Fewer growth events also reduces virtual log file (VLF) fragmentation.
Align the recovery model with business requirements
HighIf point-in-time recovery is not needed, SIMPLE is an option. However, SIMPLE rules out point-in-time recovery, so business sign-off is required. On Amazon RDS, also confirm consistency with automated backups.
Continuously monitor log usage
Read-onlyPeriodically sample usage and `log_reuse_wait_desc`, and set up an alert for when a value other than NOTHING persists for a set duration.
Change involving a restart or service impact
Shrink the log file
HighDo this only after resolving the cause, solely to reclaim space that ballooned. Shrinking while the cause remains just leads to re-growth, and each growth event stalls writes. See the related article for the procedure and cautions.
Forcibly terminate an open session
High`KILL` rolls back an uncommitted transaction. The rollback itself needs time and log space, so confirm the scope of impact and get business sign-off first.
!Warnings
- On Amazon RDS for SQL Server, backups are managed by RDS. Running `BACKUP LOG` directly is not a supported operational pattern, so check log backup status by confirming that the backup retention setting matches the recovery model. Availability and behavior vary by engine version and option, so always verify on the target environment.
- Even when `log_reuse_wait_desc` is not NOTHING, values like CHECKPOINT or LOG_SCAN are transient. Do not conclude there is a problem from a single reading.
- Changing the recovery model from FULL to SIMPLE breaks the log chain, ruling out point-in-time recovery. Reverting requires taking a fresh full backup.
- Shrinking a file to free up space does not help if the underlying cause remains — it will simply grow again. Shrinking is not a substitute for resolving the cause.
- While error 9002 is occurring, write transactions are failing. Communicate the business impact in parallel with investigating the cause, not after.
Differences by Version and Environment
If This Doesn't Resolve It
Start time of the oldest transaction
If ACTIVE_TRANSACTION persists, identify which session has had a transaction open, and since when.
Status of the CDC capture job and Log Reader Agent
If REPLICATION persists, check whether the capture side has stopped, or whether data is backing up on the distribution database side.
Number of virtual log files (VLFs)
Check the VLF count with `DBCC LOGINFO` (or `sys.dm_db_log_info` depending on version). An extremely high count slows down recovery and log processing.
Free space and IOPS on the storage side
When log growth is failing, the cause may lie with storage rather than the database itself.
Basis and Limitations of This Document
Explanation based on official product documentation
A general procedure based on the public specifications of SQL Server's `DBCC SQLPERF(LOGSPACE)`, `sys.dm_db_log_space_usage`, `sys.databases` (`log_reuse_wait_desc`), and `sys.database_files`. Amazon RDS-specific behavior can vary by environment and engine version, so this assumes verification on the target environment.
FAQ
Can this be run in production?
All four SQL statements in this article are read-only and change neither data nor settings. They can be run as-is in production. Shrinking the log file or changing the recovery model are separate actions that require checking their impact beforehand.
Does this work on AWS RDS?
Yes. `DBCC SQLPERF(LOGSPACE)`, `sys.dm_db_log_space_usage`, and `sys.databases` can all be queried on Amazon RDS for SQL Server. However, since running `BACKUP LOG` directly is not a supported pattern on RDS, check log backup status through the backup retention setting instead.
What permissions are required?
`DBCC SQLPERF(LOGSPACE)` and `sys.dm_db_log_space_usage` require VIEW SERVER STATE. `sys.databases` follows metadata visibility rules, so databases you lack permission on will not appear in the results.
Does shrinking the log solve the problem?
No. Shrinking only reduces the size; it does not address why the log is not being released. Unless you resolve whatever `log_reuse_wait_desc` points to, the log will grow again after shrinking.
Should I choose FULL or SIMPLE?
It depends on business requirements. If you need to recover to an arbitrary point in time during an incident, FULL combined with a log backup routine is required. If recovering to the most recent daily backup is sufficient, SIMPLE is an option, but business sign-off is needed since point-in-time recovery becomes impossible.
How should I interpret the results?
High usage by itself is not abnormal. Treat it as worth investigating when usage does not drop across repeated samples a few minutes apart, and `log_reuse_wait_desc` stays fixed at something other than NOTHING — investigate whatever that value indicates.
Questions This Document Covers
- I want to know why my SQL Server transaction log is not shrinking
- I want to look up the meaning of log_reuse_wait_desc values
- How do log backups work on RDS for SQL Server
What the Risk Labels Mean
- Read-onlyDoes not change data or settings.
- LowImpact is limited, but permissions and load should be checked.
- MediumMay affect performance, locking, or cost.
- HighMay cause an outage, data loss, or require recovery work.
- Expert Review RequiredRequires a separate review before applying to production.
GIIP's Scope of Support
Checking log usage itself is done the moment you run the SQL above once. The hard part is doing this continuously across multiple instances and catching the exact moment `log_reuse_wait_desc` changes to something other than NOTHING. At GIIP, AI agents periodically pull state from multiple databases on AWS and Azure, escalating only threshold-crossing changes to a human. For events like log bloat — where "by the time you notice, writes have already stopped" — detecting the change matters more than the value itself for response time.
Author & Technical Review
GIIP Production Operations Team
About 30 years of experience in designing, migrating, and operating large-scale web services, SQL Server, Oracle, AWS, and Azure. Experience includes 12 sets of x12large-class AWS RDS for SQL Server environments, an Oracle environment with roughly 120,000 tables, and migrating roughly 3TB from TiDB to Aurora MySQL. AI agents and human experts currently continue to monitor and operate multiple cloud databases and about 30 web services.
The Difference Between DBCC SHRINKDATABASE and DBCC SHRINKFILE, and What to Check Before Running Them
Organizes the difference between SHRINKDATABASE, which targets the whole database, and SHRINKFILE, which targets a single file; when to use TRUNCATEONLY; and what to check before running either.
sql-serverSQL to Check for Long-Running Open Transactions in SQL Server
A procedure using the sys.dm_tran_active_transactions family of DMVs to identify abandoned transactions, including start time, session, and the last SQL statement executed.
sql-serverHow to Check Whether CDC Log Scanning Has Stopped in SQL Server
A procedure for checking whether CDC's log scan is progressing, using sys.dm_cdc_log_scan_sessions, cdc.lsn_time_mapping, and the state of the capture job.
sql-serverWhy MSrepl_commands Keeps Growing in SQL Server, and How to Check for Replication Lag
A procedure for isolating a backlog of commands in the distribution database from two angles: the state of the distribution agent, and the cleanup job / retention period.
Related Services
Request emergency response for log bloat
If you need to repeat the same checks across multiple environments, we can discuss your entire operations setup.
Request emergency response for log bloat