SQL Server Script: Get Database Growth Events

In SQL Server, database growth events occur when the database files automatically expand to accommodate more data. These events are essential to monitor because frequent auto-growth can impact performance, causing fragmentation and increased disk I/O during expansions. Proper configuration of file growth settings is crucial to maintaining optimal performance.

Some DBAs opt for custom SQL Agent jobs to manage file growth in a controlled manner and avoid performance issues during peak times. Enabling Instant File Initialization for data files (but not for log files) can also speed up growth by bypassing the zeroing process, reducing delays during file expansion.

Another critical aspect is monitoring Virtual Log Files (VLFs), as poor log file growth management can lead to performance degradation, especially during backups and recovery processes.


The SQL Script Below:
This script helps you track the most recent database growth events, allowing you to identify which database has recently grown and potentially caused disk space issues. It’s useful for troubleshooting, but ideally, you’d set up ongoing monitoring for proactive management.


SQL Script to Show Database Growth Events

The following script retrieves recent growth events in your SQL Server since the last restart:

SQL Server Growth Events

If you have many growth events, exporting the results to Excel for filtering can help. Alternatively, you could save the results to a table and aggregate the total growth per database. For regular monitoring, consider setting up more structured tracking rather than relying on ad-hoc queries.

Tracking SQL Server growth events allows you to quickly identify when database files expand, which can help prevent disk space issues. However, setting up ongoing monitoring and alerting is recommended for long-term performance and disk management.

For more information on SQL Server database growth events check out my previous blog post: Database Growth Events in SQL Sever, this post shows how to change your growth event settings for a database too.


Comments

Leave a Reply

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

Recent Posts
Categories
Tags

Always On Availability Groups (AAG) (4) AWS (4) AWS Redshift (6) Database Admin (72) Database Backups & Recovery (14) Database Mirroring (2) Error Messages (5) Failover Cluster Instances (FCI) (1) Git Commands (6) Importing & Exporting Data (2) Linked Servers (3) Linux Administration (2) Logging & Monitoring (1) Microsoft Patching (2) MySQL (4) Postgres (6) PowerShell Scripts (2) SQL Certificates & Encryption (3) SQL Server Agent (5) SQL Server CDC (2) SQL Server Data Types (2) SQL Server Management Studio (SSMS) (16) SQL Server Networking (3) SQL Server on Linux (1) SQL Server Patching (2) SQL Server Performance Tuning (6) SQL Server Processes (SPIDs) (7) SQL Server Replication (2) SQL Server Scripts (13) SQL Server Security (4) SQL Server Storage (10) Windows Admin (21) Windows Authentication (2) Windows Automation (1) Windows Events (2) Windows Firewall (4) Windows Subsystem for Linux (WSL) (18)