Last updated on December 5th, 2020 at 07:27 pm
If you are an SQL Server database admin and get the alarming message that the SQL database is down, that must be a devastating moment for you. At that moment, you got a lot of responsibility bestowed upon you. Your first duty is to find out why the database is down and fix it at the earliest possible time.
One of the most common causes of the database is low disk space. If you wish to avoid database crashing or bottleneck conditions, you must always check how much database space is available for SQL users. And to do that, you have to know how to monitor SQL Server disk space.
This post will discuss how DBAs can keep track of the disk space availability. It will also cover what issues can occur if enough disk space is not available and how to avoid low disk space availability of SQL Server. Let’s not waste any more time and go straight into the main discussion.
Issues SQL Server May Face Due to Low Disk Space
These are the major problem SQL Server encounter when it does not have enough disk space available.
- SQL Job will Stop Initiating: Due to unavailability of the disk space, master database does not have space to proceed. Therefore, information and the SQL jobs fail to get logged and also fail to begin.
- Tasks Requiring tempdb will Fail: Certain operations and aggregates need to use tempdb heavily. If disk space is not available for the tempdb, these operations will be hampered.
- Database & Log file will Fill Up: both the database file and transaction Log file will fill up in absence of SQL Server disk space. This will result in failure of DML operations and the loss of point in time recovery.
- Database Applications will Stop Functioning: If a database is allowed to take up the entire disk space and grow in an uncontrollable manner, other database applications will fail.
How to Monitor SQL Server Disk Space
There are three main methods to know how the SQL Server is doing in terms of disk space. Now we will learn about those methods.
- Manual: Manual method to know the disk space is an easy one. Open Explorer and check the size of the disk drive where SQL Server is located. Note down every day’s reading in an Excel sheet and you will know how things are moving. This is a tiring and error-prone method and someone needs to do it every day as a routine work. That is why, most of the DBAs do not prefer this technique.
- Scripting: Admins can also check their SQL disk space by using various PowerShell scripts or VBScript. These scripts will not only allow users to monitor the disk space, but also email the report along with the information regarding disks with enough space. This system can be costly and many organizations use this method and SQL Monitor together.
- SQL Monitor: SQL Monitor, a default tool that comes with SQL Server is considered as the most cost-effective solution to track the SQL disk space. SQL database admins can set alarms whenever a configured threshold is reached. This alert can also be set for disk space which will warn the admins regarding SQL disk space unavailability in advance.
How to Keep the Usage of Disk Space in Control
After using these stated techniques, if you find out that your disk space is running low, you can take some measures to keep the size of database and log files in check. The most useful practice to control the size is to check the number of auto-growth.
- For SQL Database
It is highly recommended not to implement the automatic growth in percentage for database files. Rather, users should go for Growth in megabytes. While setting up the value, they need to keep in mind both the requirement and capability of their database. For example, small databases may set the auto growth rate to 1 GB, while for very large databases (VLDB), it could be 10 GB. If the growth is set in percent, it will become unnecessarily huge in case of VLDBs.
- For Transaction Log File
To keep the size of Log file in control, the first thing you can do is to shrink the file to the maximum level. After every 15-20 minutes, perform dumping. For one week, check out its growth rate and the maximum size it is reaching. Finally dump and shrink the log file in SQL Server to its minimum size; and then put the size back to its maximum size manually. Execution of these steps will prevent the existence of too many virtual logs in an SQL Server.
The amount of available disk space of SQL database plays an important role in the smooth and problem-free functioning SQL Server. In order to determine the available disk space, users need to know how to monitor SQL Server disk space. Here I have described some of the best ways to monitor SQL disk space and also mentioned how to keep the data file and log file size in control that users can follow without any trouble.