• Skip to main content
  • Skip to primary sidebar

DBA Diaries

Thoughts and experiences of a DBA working with SQL Server and MySQL

Using DBCC SQLPERF

October 19, 2013 by Andy Hayes 3 Comments

dbcc sqlperfThere 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….

  1. Viewing wait statistics data
  2. Clearing wait statistics data
  3. Clearing latch wait statistics data
  4. 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.

Related Posts:

  • sql grouping sets
    Using SQL GROUPING SETS for Multiple GROUP BY…
  • How to fix "conversion failed when converting date and/or time from character string"
    How to fix "conversion failed when converting date…

Filed Under: All Articles, SQL Server Administration Tagged With: dbcc, sql server

About Andy Hayes

Andy Hayes is a DBA working with SQL Server since version 7.0. He has a wonderful wife and two beautiful children. He loves database technology, playing cricket, and blogging. He is passionate about sharing his experiences as a DBA and learning more to further his understanding and knowledge. You can follow me on Twitter, check out my Facebook page or follow me on Google+

Reader Interactions

Comments

  1. Jonathan R says

    July 21, 2015 at 9:29 am

    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)”

    Reply
    • Andy Hayes says

      July 21, 2015 at 6:07 pm

      Thanks Jonathan. I have amended and I’m glad you liked the article 🙂

      Reply
  2. Johnson says

    January 13, 2017 at 12:34 pm

    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/

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Categories

  • All Articles (84)
  • Career Development (8)
  • MySQL Administration (18)
  • MySQL Performance (2)
  • SQL Server Administration (24)
  • SQL Server News (3)
  • SQL Server Performance (14)
  • SQL Server Security (3)
  • SQL Tips and Tricks (21)

Top 10 Popular Posts

  • Using sp_change_users_login to fix SQL Server orphaned users
  • MySQL SHOW USERS? – How to List All MySQL Users and Privileges
  • How to shrink tempdb
  • How to Transfer Logins to Another SQL Server or Instance
  • How to Delete Millions of Rows using T-SQL with Reduced Impact
  • T-SQL – How to Select Top N Rows for Each Group Using ROW_NUMBER()
  • New T-SQL features in SQL Server 2012 – OFFSET and FETCH
  • How to Kill All MySQL Processes For a Specific User
  • Using exec sp_who2 to help with SQL Server troubleshooting
  • How to fix “conversion failed when converting date and/or time from character string”

Recent Posts

  • How to fix “conversion failed when converting date and/or time from character string”
  • Using SQL GROUPING SETS for Multiple GROUP BY Queries in a Single Query
  • How to Setup MySQL Master Master Replication
  • How To Use SQL to Convert a STRING to an INT
  • How to set up MySQL Replication Tutorial

Search

Connect

  • Twitter
  • Facebook
  • RSS

About

  • Cookie Policy
  • Disclaimer
  • About
Copyright ©