Skip to content

SQL Server Counters for Monitoring SQL Server Performance

When a load test points to the database and the database is SQL Server, Windows performance counters are a quick, cheap first look. You can collect them with PerfMon, from LoadRunner monitors, or with your monitoring tool. This post lists the counters I check first during a test and how I read them.

SQL Server counters in three groups: memory (page life expectancy, buffer cache hit ratio, memory grants pending), workload (batch requests, compilations, recompilations per second) and contention (lock waits, blocked processes, user connections)Read SQL Server counters in groupsMemoryPage life expectancyBuffer cache hit ratioMemory Grants PendingWorkloadBatch Requests/secSQL Compilations/secRe-Compilations/secContentionLock Waits/secProcesses blockedUser Connections
Compare each counter with its own baseline under the same load.

Memory

  • Buffer Manager: Page life expectancy. How long, in seconds, data pages stay in memory. A value that keeps dropping during the test means SQL Server keeps reading from disk to refill the cache. Compare with your own baseline rather than a single magic number.
  • Buffer Manager: Buffer cache hit ratio. The share of page reads served from memory. On busy servers it is often very high even when there is memory pressure, so use it together with page life expectancy, not alone.
  • Memory Manager: Memory Grants Pending. Queries waiting for memory to run. Anything above zero during the test deserves a look.

Workload

  • SQL Statistics: Batch Requests/sec. How much work the server receives. It should rise with your load steps. If load goes up but batch requests flatten, the bottleneck may be in front of the database.
  • SQL Statistics: SQL Compilations/sec and SQL Re-Compilations/sec. Compiling query plans costs CPU. A common guideline is that compilations should be a small fraction of batch requests. High numbers often mean the application sends ad hoc SQL instead of parameterized queries. Treat the guideline as a hint, not a rule.

Contention

  • Locks: Lock Waits/sec and Average Wait Time. Sessions waiting for locks held by others. A rise that tracks your load points to contention between transactions.
  • General Statistics: Processes blocked. Sessions blocked right now. Even a few blocked sessions during a load test can explain slow transactions.
  • General Statistics: User Connections. Should match what the application's connection pools allow. A sudden jump can mean connections are leaking.

Do not forget the operating system

Also collect Processor % time, Memory Available MBytes, and disk latency (Avg. Disk sec/Read and sec/Write) on the database server. A slow disk makes every memory problem worse.

How to use them in a load test

  1. Collect the same counters in a quiet period, then during each load step.
  2. Look for counters that change with load, not for single high values.
  3. For the counters that move, go deeper with wait statistics and the top queries by total time.

Frequently asked questions

Are counters enough to find the slow query?
No. They tell you which kind of problem you have. Query-level views such as Query Store and the dynamic management views tell you which query.

Can LoadRunner collect these?
Yes, through its Windows resources and SQL Server monitors, or through SiteScope.

What is a good page life expectancy?
It depends on memory size and workload. Use the trend during your test and compare it with a normal day.

RG

Raviteja Gorentla

Performance engineer writing since 2010 about LoadRunner, JMeter, NeoLoad, APM tools and the real problems that show up in load tests. Every fix here was tested on a live project.

Page views