There are a number of uses for the DBCC SQLPERF command. I touched upon one of them in my last post on how you can use the command to obtain information about transaction log growth.
This handy little DBCC command has been around for a while now. So lets look at the others ways you use it….
- Viewing wait statistics data
- Clearing wait statistics data
- Clearing latch wait statistics data
- Obtaining log space size and used data
Syntax and examples for DBCC SQLPERF
--syntax DBCC SQLPERF(option) WITH NO_INFOMSGS
--example uses DBCC SQLPERF(waitstats) DBCC SQLPERF('sys.dm_os_latch_stats' , CLEAR) DBCC SQLPERF('sys.dm_os_wait_stats' , CLEAR) DBCC SQLPERF(logspace)
Looking at each use case for DBCC SQLPERF in turn….
There are newer ways to do this by reading from sys.dm_os_wait_stats but it can be used to obtain wait statistics from your SQL Server.
I wrote about waits stats and wait types in an earlier post so have a read of that if you want to know more about them.
DBCC SQLPERF(‘sys.dm_os_wait_stats’ , CLEAR)
This resets the wait statistics data that your SQL Server has collected since it was last restarted – very handy for performance tuning.
DBCC SQLPERF(‘sys.dm_os_latch_stats’ , CLEAR)
Latches are internal resource locks and wait data is recorded in a similar way to wait type data. To clear out the latch waits that your SQL Server has collected since it was last restarted then run this command.
Finally, in order to get log space data on how large your transaction logs are and what percentage of them is in use then execute this command. My last post was about this dbcc command, you can view that here.
Permissions needed for DBCC SQLPERF
In order to run this command, your user needs VIEW SERVER STATE permission on the server.