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
[sourcecode language=’sql’]
–syntax
DBCC SQLPERF(option)
WITH NO_INFOMSGS
[/sourcecode]
[sourcecode language=’sql’]
–example uses
DBCC SQLPERF(waitstats)
DBCC SQLPERF(‘sys.dm_os_latch_stats’ , CLEAR)
DBCC SQLPERF(‘sys.dm_os_wait_stats’ , CLEAR)
DBCC SQLPERF(logspace)
[/sourcecode]
Looking at each use case for DBCC SQLPERF in turn….
DBCC SQLPERF(waitstats)
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.
DBCC SQLPERF(logspace)
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.
Jonathan R says
Thanks, this is a good article. I just spotted a typo, the is the line “DBCC SQLPERF(‘sys.dm_os_wait_stats’ , CLEAR)” twice in the main text. I think the second one should be “DBCC SQLPERF(‘sys.dm_os_wait_stats’ , CLEAR)”
Andy Hayes says
Thanks Jonathan. I have amended and I’m glad you liked the article 🙂
Johnson says
great, article. This is so chock full of users information and the resources you provided was helpful to me. There I found one more informative articles like yours discussing about DBCC Log Info In DBCC LOG. You may also have a Look:
http://www.sqlmvp.org/dbcc-log-command-in-sql-server/