SQL Server Performance Tuning

Best Practices For Performance Counters In Microsoft SQL Server

Updated
5 min read
Written by
Mark Varnas

Why is this needed?

When users notice that web pages or other systems are running slow, they start complaining to System or database administrators.

How to know if your database is running fine and is not bottlenecked in this situation? Using a built-in Microsoft tool called Performance Monitor is one of many possible options to begin an investigation.

How to use PerfMon?

There are several ways to open the Performance Monitor window.

The easiest one is to click on the Start button on the taskbar (or push the Windows button on your keyboard), type in “Performance Monitor“ and hit Enter.

You should see the default graph of processor time. At this point, it is easy to right-click on this graph, choose Add Counters, select them and get instant results.

However, it is worth collecting performance counters data for a longer period and comparing non-peak time and days versus peak ones.

How to do this? Follow these simple steps:

Firstly, you have to create a Data Collector Set:

  1. On the Performance Monitor window already opened, expand Data Collector Sets.
  2. Right-click on User Defined, and choose New > Data Collector Set.
  1. On the new window, enter a name (example – “SQL Server performance metrics“), choose Create Manually (Advanced) and then Next.
  2. On the Create Data Logs radio button, tick a box on the Performance Counter and click Next.
  3. Click Add and select counters you are interested in, and click Add after each selected counter. You can also choose a local computer or remote machine to collect data from. The next paragraph will have a list of recommended counters for the SQL Server instance running on Microsoft Server.

    Figure 2 shows the example performance counter selected.

After all required performance counters were added, a sample interval can be chosen.

Remember that intervals that are too small may generate a huge amount of data that may be harder to render.

A large interval may not have enough data for investigation. The recommendation is to start the interval for 1 minute (if capture runs for a day) and later adjust by specific counters selected and personal requirements. Click Next.

  1. On the “Where would you like the data to be saved?“ window, we would recommend choosing the drive that will not be collecting data from (in case any disk counter is used). Click Next.
  2. Now Run As: User might be specified. Otherwise, leave <Default> value, choose Save and Close and click.
  3. When a new user-defined template is available, right-click on it and choose Start like it is shown in Figure 3.

Let them run for a while. It can also be scheduled, for example, to start daily. To do this, instead of Start, choose Properties and then Schedule tab.

Our recommendation is to keep collecting running no longer than one day (and then start again if needed) for possible overhead.

Top 12 SQL Server Performance Counters

The table below contains the recommended performance counter for SQL Server instances:

ObjectCounterDescription
SQLServer: SQL StatisticsRecompilations/secStatement recompiles per second count.
SQLServer: SQL StatisticsCompilations/secSQL compilations per second count.
SQLServer: SQL StatisticsBatch Requests/secT-SQL command batches received per second.
SQLServer: Memory ManagerMemory Grants PendingTotal number of processes waiting for a memory grant.
SQLServer: General StatisticsProcesses blockedCurrently blocked processes count.
SystemProcessor Queue LengthCollects number of threads waiting for processor time.
MemoryAvailable MBytesCollects memory available in Megabytes.
Physical DiskAvg. Disk sec/ReadAverage time in seconds of read data from the disk.
Physical DiskAvg. Disk sec/WriteAverage time in seconds of write data to the disk.
Physical DiskDisk Reads/secRate of read operations on the disk.
Physical DiskDisk Writes/secRate of write operations on the disk.
Processor% Processor TimePercentage of elapsed time the processor spends executing non-idle threads.

More details on performance counters can be found on Microsoft monitor resource usage page.

Analyzing results

When there is any result collected, on the Performance Monitor window expand Reports, User Defined, and open report under “ SQL Server performance metrics“ (or another name specified previously) like in Figure 4.

During the investigation, keep in mind that one counter can be closely related to another one.

For example, suppose SQL Server does not have enough memory dedicated.

In that case, it may start writing to disk instead and increase it‘s performance counters of disk activity (even if the root cause is different).

Article by
Mark Varnas
Founder | CEO | SQL Veteran
Hey, I'm Mark, one of the guys behind Red9. I make a living performance tuning SQL Servers and making them more stable.

Managed SQL Server services, consulting, and emergency support from expert DBAs to improve performance, predictability, and cost.

Get started with Red9 today.

Contact us

Discover More

SQL Server Health Check SQL Server Migrations & Upgrades SQL Server Performance Tuning SQL Server Security SQL Server Tips

Discover what clients are saying about Red9

Red9 has incredible expertise both in SQL migration and performance tuning.

The biggest benefit has been performance gains and tuning associated with migrating to AWS and a newer version of SQL Server with Always On clustering. Red9 was integral to this process. The deep knowledge of MSSQL and combined experience of Red9 have been a huge asset during a difficult migration. Red9 found inefficient indexes and performance bottlenecks that improved latency by over 400%.

Rich Staats 5 stars
Rich Staats
Cloud Engineer
MetalToad

Always willing to go an extra mile

Working with Red9 DBAs has been a pleasure. They are great team players and have an expert knowledge of SQL Server database administration. And are always willing to go the extra mile to get the project done.
5 stars
Evelyn A.
Sr. Database Administrator

Boosts server health and efficiency for enhanced customer satisfaction

Since adding Red9 to the reporting and DataWarehousing team, Red9 has done a good job coming up to speed on our environments and helping ensure we continue to meet our customer's needs. Red9 has taken ownership of our servers ensuring they remain healthy by monitoring and tuning inefficient queries.
5 stars
Andrew F.
Datawarehousing Manager
See more testimonials

Check Red9's SQL Server Services

SQL Server Consulting

Perfect for one-time projects like SQL migrations or upgrades, and short-term fixes such as performance issues or SQL remediation.

Discover More

SQL Server Managed Services

Continuous SQL support, proactive monitoring, and expert DBA help with one predictable monthly fee.

Discover More

Emergency SQL Support

Take the stress out of emergencies with immediate access to a SQL Server Sr. DBA 24x7x365

Discover More
Explore All Services