Skip to content

SQL Server Counters

0. Overview MetricsSQL Server

UID: sql_server_countersVersion: 1.3.1 Panels: ~72 Datasources: MSSQL, InfluxDB

Purpose

This dashboard allows reviewing the global status of SQL Server instances, including critical aspects such as:

  • Database size and log files
  • Memory usage and buffer pool status
  • Performance counters internal to SQL Server
  • Page Life Expectancy and Buffer Cache Hit Ratio
  • I/O metrics and disk latency
  • High availability status (Availability Groups)

Variables

VariableDescription
$InstanceSQL Server instance to monitor

Sections

Instance Info

General information about the selected instance, including uptime, memory configuration, and key counters.


Up Time stat

Time elapsed since the last SQL Server instance startup.

Importance: A recent restart may indicate planned maintenance, patch updates, or an unexpected problem such as a crash or out of memory.

Thresholds:

ValueColorStatus
< 1 dayMagentaReview - recent restart
>= 1 dayGreenNormal

Practical recommendation

After a restart, SQL Server needs time to "warm up" its cache. Buffer Cache Hit Ratio and PLE will be low initially. Monitor these values during the first hours to ensure they stabilize.


Max SQL Server Memory stat

Maximum amount of memory SQL Server can use (Target Server Memory).

Importance: According to official Microsoft documentation, correctly configuring maximum memory is critical to prevent SQL Server from consuming all the server's RAM, leaving the operating system without resources.

Formula recommended by Microsoft:

  • Dedicated servers: Total RAM - 4 GB (for the OS) - RAM for other services
  • Servers with 16+ GB: Leave 4 GB for the first 16 GB, plus 1 GB for each additional 8 GB

Best practice

Never leave this value at the default (2,147,483,647 MB). A server with 32 GB of RAM should have Max Server Memory configured at approximately 26-28 GB.


Used SQL Server Memory stat

Amount of memory SQL Server is currently using (Total Server Memory).

Importance: The difference between Target and Total Server Memory indicates if SQL Server is under memory pressure. If Total is significantly less than Target, it may indicate the system doesn't have enough load or there are configuration issues.


Free Space in Tempdb stat

Free space within tempdb files. Indicates the difference between allocated space and space used by objects.

Importance: TempDB is used by SQL Server for sorts, hash joins, temporary tables, row versioning (RCSI/Snapshot), and internal operations. It is one of the most critical databases for performance.

Thresholds:

ValueColorAction
< 512 MBRedCritical - free up space
512 MB - 1 GBMagentaReview
> 1 GBGreenNormal

TempDB Best Practices (Microsoft)

According to Microsoft recommendations:

  1. Multiple data files: Create one file per logical core (up to 8 files)
  2. Equal size: All files should have the same initial size and growth
  3. Dedicated disk: Place TempDB on fast disks (SSD/NVMe) separate from user data
  4. Pre-size: Configure an appropriate initial size to avoid frequent auto-growth

Page Life Expectancy (PLE) stat

Time in seconds that a data page remains in the buffer pool before being discarded. It is the most important indicator of memory pressure in SQL Server.

Importance: PLE is one of the most critical counters according to Microsoft documentation on Buffer Manager. A low PLE means pages are being evicted quickly from the buffer pool, forcing constant reads from disk.

Interpretation:

ValueStatusAction
< 300 secRed - CriticalInvestigate immediately
300 - 1000 secMagenta - ReviewMonitor trend
1000 - 3000 secYellowAcceptable but improvable
> 3000 secGreen - NormalHealthy system

Common causes of low PLE

  1. Insufficient memory: Max Server Memory configured too low
  2. Table scans: Queries scanning entire tables instead of using indexes
  3. Missing indexes: Lack of appropriate indexes for executed queries
  4. Queries with large results: SELECT * from large tables without filters
  5. Peak workload: Temporary increase in activity

Practical recommendation

Modern PLE formula: Microsoft no longer recommends a fixed value of 300. The updated formula is:

Minimum PLE = (Max Server Memory in GB / 4) x 300

Example: Server with 64 GB -> Minimum PLE = (64/4) x 300 = 4,800 seconds

Remediation actions:

  1. Review queries with high logical reads using sys.dm_exec_query_stats
  2. Identify missing indexes with sys.dm_db_missing_index_details
  3. Evaluate increasing Max Server Memory
  4. Analyze if there are unnecessary table scans

Buffer Cache Hit Ratio stat

Percentage of data pages found in memory cache without needing to read from disk.

Importance: This counter measures buffer pool efficiency. According to Microsoft, a high value indicates most data requests are satisfied from memory.

Interpretation:

ValueStatusAction
< 95%RedCritical - serious memory problem
95% - 98%MagentaReview memory configuration
98% - 99%YellowAcceptable
> 99%GreenOptimal

Important note

For OLTP systems, this value should always be above 99%. Lower values are acceptable only for:

  • Data Warehouse systems with ad-hoc queries
  • Immediately after a restart (warm-up period)
  • Workloads reading rarely accessed historical data

Difference between PLE and Buffer Cache Hit Ratio:

  • Buffer Cache Hit Ratio: Measures hit percentage (instantaneous)
  • PLE: Measures how long pages remain (stability)

A system can have good Hit Ratio but poor PLE if pages are constantly rotating.


Backup/Restore Throughput stat

Speed of backup and restore operations in bytes per second.

Importance: Allows evaluating if backups are operating at optimal speed or if there are I/O bottlenecks.

Backup optimization

To improve backup throughput:

  1. Use backup compression (typical reduction of 60-80%)
  2. Perform backups to multiple files in parallel
  3. Configure appropriate BUFFERCOUNT and MAXTRANSFERSIZE
  4. Use fast storage for backup destination

CPU Count stat

Number of CPU cores available to SQL Server.

Importance: This value directly affects MAXDOP configuration and licensing. SQL Server Standard Edition is limited to 24 cores.


Memory Grants Pending stat

Number of processes waiting to be allocated workspace memory to execute operations.

Importance: According to Microsoft, this counter indicates if there are queries waiting for memory to perform sorts, hash joins, or other operations that require workspace memory.

Interpretation:

ValueStatusAction
0GreenNormal - no waits
1-5MagentaReview queries with high memory grants
> 5RedCritical - investigate immediately

Impact of Memory Grants Pending > 0

When there are queries waiting for memory grants:

  1. Queries queue up and wait, increasing latency
  2. Overall system performance degrades
  3. Users experience timeouts

The value should ALWAYS be zero on a healthy system.

Remediation actions:

  1. Identify queries with excessive memory grants using sys.dm_exec_query_memory_grants
  2. Review queries with incorrect cardinality estimates
  3. Update statistics with UPDATE STATISTICS
  4. Consider Resource Governor to limit memory grants per query

Active Temp Tables stat

Number of temporary tables (#temp) currently existing on the server.

Importance: A very high number may indicate applications are creating many temporary tables without releasing them, or that there are long-running sessions accumulating temporary objects.


Version Store Size stat

Size of the version store in TempDB used for Snapshot Isolation and RCSI.

Importance: The Version Store is used by:

  • Read Committed Snapshot Isolation (RCSI): Allows consistent reads without locks
  • Snapshot Isolation: Transaction-level isolation
  • Online Index Operations: Index rebuilds without blocking reads
  • Always On Readable Secondaries: Reads on secondary replicas

According to Microsoft

A very large Version Store may indicate:

  • Long-running transactions maintaining old versions
  • High write load with RCSI enabled
  • Long-running queries on Always On secondary replicas

Monitor with: sys.dm_tran_version_store_space_usage


Checkpoint pages/sec stat

Modified pages (dirty pages) written to disk during checkpoint operations.

Importance: Checkpoints write modified pages from the buffer pool to disk to guarantee transaction durability. A sustained very high value may indicate:

  • High write load
  • Very frequent checkpoints
  • Possible I/O bottleneck

Indirect Checkpoints (SQL Server 2016+)

Microsoft recommends using Indirect Checkpoints with TARGET_RECOVERY_TIME set to 60 seconds. This provides more predictable recovery times and reduces I/O spikes.


Page lookups/sec stat

Number of requests per second to locate a page in the buffer pool.

Importance: Indicates the level of logical read activity. Very high values may indicate inefficient queries reading many pages.


Average User Connections stat

Average simultaneous user connections. SQL Server supports a maximum of 32,767 connections.

Thresholds:

ValueStatusAction
< 25,000GreenNormal
>= 25,000MagentaReview - near limit

Connection Pooling

A very high number of connections may indicate connection pooling problems in applications. Each connection consumes memory (~1.5 MB per connection). Verify:

  1. That applications use connection pooling
  2. That connections are closed correctly
  3. That there are no orphaned connections

Databases Info

Status and health of databases in the instance.


Databases Health stat

Aggregated health indicator. Sum of databases in problematic states.

Interpretation:

ValueTextStatus
0HEALTHYGreen - all databases operational
>= 1NOT HEALTHYMagenta - investigate immediately

Database States stat

Individual counters by database state.

Database states according to Microsoft:

StateDescriptionAction
ONLINEDatabase accessibleNormal state
OFFLINEManually disconnectedVerify if intentional
SUSPECTPossible corruption detectedRun DBCC CHECKDB, restore if necessary
RECOVERINGIn recovery processWait for completion
PENDINGResource error during recoveryReview error logs
RESTORINGRestore in progressNormal transient state

SUSPECT State

A SUSPECT database indicates the primary filegroup may be damaged. Immediate actions:

  1. Review the SQL Server Error Log
  2. Run DBCC CHECKDB('database_name') WITH NO_INFOMSGS
  3. If corruption exists, evaluate repair or restore options
  4. Never use DBCC CHECKDB WITH REPAIR_ALLOW_DATA_LOSS without understanding the consequences

Database Size

Visualization of individual database sizes and temporal evolution.


Data File Size / Log File Size piechart

Visual distribution of data and log file sizes by database.

File management best practices

  1. Pre-size files: Avoid frequent auto-growth
  2. Growth in MB, not %: Use fixed increments (512 MB - 1 GB)
  3. Separate data and log: Place on different disks if possible
  4. Monitor growth: Detect abnormal growth early

Performance Counters

Temporal evolution charts of the main performance counters.


SQL Stats timeseries

SQL activity metrics: batch requests, compilations, logins, and blocks.

Included metrics and their meaning:

MetricDescriptionIdeal Value
Batch Requests/secNumber of SQL batches receivedDepends on workload
SQL Compilations/secNew execution plans created< 10% of Batch Requests
SQL Re-Compilations/secPlans recompiled< 1% of Compilations
Processes blockedProcesses waiting for locks0

Compilation Ratio

If SQL Compilations/sec is high relative to Batch Requests/sec, it indicates plans are not being reused. Common causes:

  • Ad-hoc queries without parameterization
  • Excessive use of dynamic SQL
  • Unnecessary OPTION (RECOMPILE)
  • Outdated statistics

Solution: Enable "Optimize for Ad Hoc Workloads" and parameterize queries.


Access Methods timeseries

Counters showing how SQL Server accesses data: scans, seeks, lookups.

Key Access Methods metrics:

MetricMeaningTarget
Index Searches/secIndex search operations (seeks)High = good
Full Scans/secFull table/index scansLow = good
Range Scans/secRange scans on indexesDepends
Page Splits/secPage splits from insertionsLow = good

Scans vs Seeks Ratio

A high ratio of Full Scans/sec relative to Index Searches/sec indicates possible missing indexes or poorly optimized queries. Investigate with the DMV sys.dm_db_missing_index_details.


Interpretation Guide

Critical Indicators

MetricCritical ValueImpactRecommended Action
Page Life Expectancy< 300 secDegraded performanceIncrease memory, optimize queries
Buffer Cache Hit Ratio< 95%Excessive disk readsIncrease RAM, review indexes
Memory Grants Pending> 0Queries in queueUpdate statistics, review queries
Databases SUSPECT>= 1Possible data lossDBCC CHECKDB, restore if necessary

Metric Correlation

To diagnose performance problems, correlate these metrics:

SymptomMetrics to ReviewProbable Cause
Slow queriesPLE, Buffer Cache, Memory GrantsMemory pressure
TimeoutsProcesses Blocked, User ConnectionsBlocks or connection limit
High I/OCheckpoint pages/sec, Full Scans/secMissing indexes or checkpoints
High CPUBatch Requests, CompilationsHigh load or recompilations

Review Frequency

TaskFrequencyTool
Review PLE and Buffer CacheDailyThis dashboard
Verify database statusDailyThis dashboard
Analyze growth trendsWeeklyDatabase Growth dashboard
Review Memory Grants and blocksWeeklyProcess Status dashboard
Full performance auditMonthlyAll dashboards

Microsoft References

TopicLink
Buffer Manager Objectlearn.microsoft.com
Memory Manager Objectlearn.microsoft.com
Server Memory Optionslearn.microsoft.com
TempDB Best Practiceslearn.microsoft.com
Database Stateslearn.microsoft.com
Database Checkpointslearn.microsoft.com

Stored Procedures Used

This dashboard uses stored procedures from the [Counters] schema:

ProcedureDescription
spUpTimeDatabaseCalculates uptime
spLastPerformanceCountersGets the last value of a counter
spAVGPerformanceCountersGroupByIntervalCounter average grouped by interval
spMaxPerformanceCountersGroupByIntervalCounter maximum grouped by interval

Views Used

ViewDescription
[Counters].[vwDatabaseStatus]Database status by server