Database Performance Counters
Most DBAs and developers probably use Profiler, trace, review query plans, run sp_who2, run DBCCs, etc... to capture data to figure out what is currently running on the database server. These tools are great, but don't give you the entire picture in an easy to use way.
Another tool that all DBAs and developers should use is Performance Monitor. This OS level tool provides great insight into Windows counters, but also into specific SQL Server counters. There are hundreds of counters that are exposed within this tool and there are several that are specific to SQL Server.
To launch Performance Monitor, click Start, Run... and type in "perfmon" and the following should open. This application can also be found under the Administrative Tools.
To add a counter, click on the + icon or use Ctrl + I and the following will open.
Most of the counters are server specific and do not give you insight into each individual database, but the following list of counters are at the database level, so this means you can collect this data for each database that is on the server as well as an overall count for all databases.
If you navigate to the "Databases" performance objects you can see the counters that are specific to SQL Server databases which are also listed below.
|Active Transactions||Number of active update transactions for the database.|
|Backup/Restore Throughput per/sec||Read/write throughput for backup/restore of a database.|
|Bulk Copy Rows/sec||Number of rows bulk copied.|
|Bulk Copy Throughput/sec||KiloBytes bulk copied.|
|Data File(s) Size (KB)||The cumulative size of all the data files in the database.|
|DBCC Logical Scan Bytes/sec||Logical read scan rate for DBCC commands|
|Log Bytes Flushed/sec||Total number of log bytes flushed.|
|Log Cache Hit Ratio||Percentage of log cache reads that were satisfied from the log cache.|
|Log Cache Reads/sec||Reads performed through the log manager cache.|
|Log File(s) Size (KB)||The cumulative size of all the log files in the database.|
|Log File(s) Used Size (KB)||The cumulative used size of all the log files in the database.|
|Log Flush Wait Time||Total wait time (milliseconds).|
|Log Flush Waits/sec||Number of commits waiting on log flush.|
|Log Flushes/sec||Number of log flushes.|
|Log Growths||Total number of log growths for this database.|
|Log Shrinks||Total number of log shrinks for this database.|
|Log Truncations||Total number of log truncations for this database.|
|Percent Log Used||The percent of space in the log that is in use.|
|Repl Pending Xacts||Number of pending replication transactions in the database.|
|Repl Trans Rate||Replication transaction rate (replicated transactions/sec.).|
|Shrink Data Movement Bytes/sec||The rate data is being moved by Autoshrink, DBCC SHRINKDATABASE or SHRINKFILE.|
|Transactions/sec||Number of transactions started for the database.|
Why is this helpfulDepending on your database server, most SQL Servers host multiple databases and applications. Some of these databases are quite busy and others are not used at all. When deciding to consolidate servers, move databases to another server or moving databases to different physical disks these counters can show you where the bottlenecks may be and also which databases are more busy than others.
Some of the useful database counters to collect are:
- Log Cache Hit Ratio
- Log Cache Reads/sec
- Log Bytes Flushed/sec
- Log Flush Wait Time
- Log Flush Waits/sec
- Log Flushes/sec
- Percent Log Used
By collecting this data for all of your databases you can see where the most activity is occurring. Also, by using Performance Monitor you can easily graph out and trend these various counters for each of your databases. Whether you get this information from running DBCC commands, using the DMVs in SQL 2005 or by using Performance Monitor it doesn't really matter, but these are things that should be reviewed and trended to ensure your databases are running as optimally as possible.