Skip to content

Latest commit

 

History

History
130 lines (93 loc) · 6.52 KB

dbcc-sqlperf-transact-sql.md

File metadata and controls

130 lines (93 loc) · 6.52 KB
title description author ms.author ms.date ms.service ms.subservice ms.topic f1_keywords helpviewer_keywords dev_langs
DBCC SQLPERF (Transact-SQL)
DBCC SQLPERF provides transaction log space usage statistics for all databases.
rwestMSFT
randolphwest
12/05/2022
sql
t-sql
language-reference
SQLPERF
DBCC_SQLPERF_TSQL
SQLPERF_TSQL
DBCC SQLPERF
statistical information [SQL Server], transaction logs
transaction logs [SQL Server], space usage
space [SQL Server], transaction logs
DBCC SQLPERF statement
TSQL

DBCC SQLPERF (Transact-SQL)

[!INCLUDE SQL Server SQL Database Azure SQL Managed Instance]

Provides transaction log space usage statistics for all databases. In [!INCLUDEssNoVersion], it can also be used to reset wait and latch statistics.

Applies to: [!INCLUDEsql2008-md] and later versions, and [!INCLUDEsssds] (Preview in some regions)

:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: Transact-SQL syntax conventions

Syntax

DBCC SQLPERF
(
     [ LOGSPACE ]
     | [ "sys.dm_os_latch_stats" , CLEAR ]
     | [ "sys.dm_os_wait_stats" , CLEAR ]
)
     [ WITH NO_INFOMSGS ]

[!INCLUDEsql-server-tsql-previous-offline-documentation]

Arguments

LOGSPACE

Returns the current size of the transaction log and the percentage of log space used for each database. Use this information to monitor the amount of space used in a transaction log.

Important

For more information about space usage information for the transaction log starting with [!INCLUDEssSQL11], see the Remarks section in this topic.

"sys.dm_os_latch_stats", CLEAR

Resets the latch statistics. For more information, see sys.dm_os_latch_stats (Transact-SQL). This option isn't available in [!INCLUDEssSDS].

"sys.dm_os_wait_stats", CLEAR

Resets the wait statistics. For more information, see sys.dm_os_wait_stats (Transact-SQL). This option isn't available in [!INCLUDEssSDS].

WITH NO_INFOMSGS

Suppresses all informational messages that have severity levels from 0 through 10.

Result sets

The following table describes the columns in the result set.

Column name Definition
Database Name Name of the database for the log statistics displayed.
Log Size (MB) Current size allocated to the log. This value is always smaller than the amount originally allocated for log space because the [!INCLUDEssDE] reserves a small amount of disk space for internal header information.
Log Space Used (%) Percentage of the log file currently in use to store transaction log information.
Status Status of the log file. Always 0.

Remarks

Starting with [!INCLUDEssSQL11], use the sys.dm_db_log_space_usage DMV instead of DBCC SQLPERF(LOGSPACE), to return space usage information for the transaction log per database.

The transaction log records each transaction made in a database. For more information, see The Transaction Log (SQL Server) and SQL Server Transaction Log Architecture and Management Guide.

Permissions

[!INCLUDEssNoVersion] requires VIEW SERVER STATE permission on the server to run DBCC SQLPERF(LOGSPACE). To reset wait and latch statistics requires ALTER SERVER STATE permission on the server.

[!INCLUDEssSDS] Premium and Business Critical tiers require the VIEW DATABASE STATE permission in the database. [!INCLUDEssSDS] Standard, Basic, and General Purpose tiers require the [!INCLUDEssSDS] admin account. Reset wait and latch statistics aren't supported.

Examples

A. Display log space information for all databases

The following example displays LOGSPACE information for all databases contained in the instance of [!INCLUDEssNoVersion].

DBCC SQLPERF (LOGSPACE);
GO

[!INCLUDEssResult]

Database Name Log Size (MB) Log Space Used (%) Status
------------- ------------- ------------------ -----------
master         3.99219      14.3469            0
tempdb         1.99219      1.64216            0
model          1.0          12.7953            0
msdb           3.99219      17.0132            0
AdventureWorks 19.554688    17.748701          0

B. Reset wait statistics

The following example resets the wait statistics for the instance of [!INCLUDEssNoVersion].

DBCC SQLPERF ("sys.dm_os_wait_stats", CLEAR);

See also