Lesson Learned #412:PerfStat: Performance Stats Collection for SQL Server (OnPrem) Using DiagManager

Posted by

This post has been republished via RSS; it originally appeared at: Microsoft Tech Community - Latest Blogs - .

Efficient performance monitoring and tuning are critical aspects of ensuring optimal operation for database systems. As a pioneer in database technologies, Microsoft offers tools and solutions that empower database administrators and operations teams to manage and optimize their environments. One such tool is PerfStat, a script that is an integral part of DiagManager, designed to gather performance statistics in SQL Server (OnPremise) environments.

Introducing PerfStat


PerfStat stands as an indispensable component within Microsoft's GitHub repository, DiagManager. This repository houses a collection of scripts and tools tailored for diagnosing, monitoring, and resolving issues within SQL Server environments. PerfStat is particularly focused on performance statistics collection, equipping database administrators with an intricate view of system behavior and utilization patterns.


Key Features and Benefits


Comprehensive Data Collection


PerfStat provides an array of critical metrics and statistics to evaluate SQL Server performance, including:

  • CPU utilization
  • System memory
  • Disk I/O
  • Query statistics
  • Locking and blocking
  • Cache statistics

By collating data across these vital areas, PerfStat presents a holistic image of how SQL Server interacts with hardware and the operating system.


Analysis and Optimization

Data gathered by PerfStat serves as the foundation for performance analysis and optimization. Administrators can leverage these statistics to pinpoint bottlenecks, usage trends, and potential performance issues. By comprehending SQL Server's behavior under different scenarios, operations teams can make informed decisions regarding configuration adjustments, hardware enhancements, and query optimizations.


Customization and Flexibility


PerfStat offers high configurability, adapting seamlessly to the distinct requirements of each environment. Administrators can fine-tune data collection parameters based on the metrics most pertinent to their situation. This precision targeting ensures a focused approach to critical performance areas, while also minimizing unnecessary data collection.


Utilizing PerfStat


Leveraging PerfStat is a streamlined and efficient process:

  1. Download and Configuration: Obtain the DiagManager repository from https://github.com/microsoft/DiagManager and navigate to the "DiagManager/CustomDiagnostics/SQL Server Perf Stats" folder. Inside, locate the PerfStat.sql script. Open the script in your SQL Server Management Studio environment.

  2. Script Execution: Execute the PerfStat.sql script on your SQL Server instance. This action triggers the collection of performance statistics.

  3. Collection and Analysis: Once PerfStat has been operational for an appropriate duration, review the collected data. Employ visualization and analysis tools to examine statistics, extracting valuable insights into SQL Server performance.




PerfStat stands as an essential tool for any database administrator seeking to optimize and enhance the performance of their SQL Server systems. By furnishing detailed collection of key statistics, PerfStat empowers operations teams to make informed, strategic decisions, ensuring optimal database performance.


Explore Microsoft's DiagManager repository and harness the power of PerfStat to elevate the efficiency and reliability of your SQL Server environments.




Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.