eG Monitoring
 

Measures reported by MsSqlSpaceTest

Typically, SQL Server databases have three types of files, as shown in the following table.

Primary The primary data file contains the startup information for the database and points to the other files in the database. User data and objects can be stored in this file or in secondary data files. Every database has one primary data file. The recommended file name extension for primary data files is .mdf.
Secondary Secondary data files are optional, are user-defined, and store user data. Secondary files can be used to spread data across multiple disks by putting each file on a different disk drive. Additionally, if a database exceeds the maximum size for a single Windows file, you can use secondary data files so the database can continue to grow.

The recommended file name extension for secondary data files is .ndf.
Transaction Log The transaction log files hold the log information that is used to recover the database. There must be at least one log file for each database. The recommended file name extension for transaction logs is .ldf.

All data files are stored in the filegroups listed in the following table.

Primary The filegroup that contains the primary file. All system tables are allocated to the primary filegroup.
User-defined Any filegroup that is specifically created by the user when the user first creates or later modifies the database.

If even a single file group in a database runs out of free space, serious performance degradations will be noticed in applications that depend on that file group for their data needs. To avoid this, administrators must track space usage both at the database-level and at the individual file group-level and proactively identify those file groups that are over-utilized. The MsSqlSpaceTest test provides administrators with both these usage insights. By monitoring the space usage in each SQL database, the test points administrators to those databases that are consuming too much space and reveals the type of data that is hogging space - data in tables? Or indexes? Alongside, the test also reports usage metrics for each file group in every SQL database, and accurately pinpoints those file groups that may soon fill up the disk! This way, the test turns the spotlight on databases and file groups that may have to be resized to ensure peak application performance.

Note:

This test will report metrics for file groups only if Microsoft SQL Server 2008 R2 (and above) is monitored.

Outputs of the test : One set of results for every file group in Microsoft database server.

The measures made by this test are as follows:

Measurement Description Measurement Unit Interpretation
Total_size Indicates the space allocated to a database MB The Total size does not include the size of the database log files.

This measure is reported only for a database.
Pct_reserved Indicates the percentage of space reserved for tables and indexes of a database Percent If the value of this measure reaches 100%, it indicates that the total space in the database has been completely allocated. New tables/indexes can be added to the database, only if its total size is increased.

This measure is reported only for a database.
Reserved_space Indcates the amount of space allocated to the tables and indexes created on a database. MB If the value of this measure becomes equal to that of the Total_size measure, new tables/indexes can no longer be created on the database. To create new tables, you must increase the database size.

This measure is reported only for a database.
Data_space Indicates the amount of space used by data. MB The total allocated space that is in use in a database is the sum of the value of the Data_space and Index_space measures.

This measure is reported only for a database.
Index_space Indicates the amount of space used by indexes. MB
Unused_space Indicates the amount of free space available in the database. MB This is the difference between the Total_size and Reserved_space.

This measure is reported only for a database.
Is_growth_enabled Indicates whether/not auto-growth is enabled for this file group. Boolean This measure is reported only for file groups. Auto-growth is the process by which the SQL Server engine expands the size of a database file when it runs out of space. The amount by which a database file grows is based on the settings that you have for the file growth options for the data file.

If this setting is enabled for even one file in a file group, this measure will report the value Yes. If this setting is not enabled for any of the database files in a file group, then this measure will report the value No.

The numeric values that correspond to the above-mentioned measure values are listed in the table below:

Measure Value Numeric Value
Yes 100
No 0

Note:

Typically, this measure reports the Measure Values listed in the table above as the status of the Autogrowth setting. In the graph of this measure however, the status will be represented using the numeric values - i.e., 100 and 0.

Max_file_size Indicates the maximum size upto which the database files in this file group can grow. MB This measure is reported only for file groups. Each database file that is associated with your database has an auto-growth setting. There are three different settings you can use to identify how your database files will grow. They can grow by a specific size, a percentage of the current size, or not grow at all. Additionally you can set your files to unrestricted growth, which means they will keep growing as they need more space or you run out of disk space. Or you can restrict the growth of a database file to grow no larger than a specified size. Each one of these different auto-grow settings have defaults, or you can set them for each database file.

If the auto-growth setting is not enabled at all for a file in a file group, then the amount of space that was originally allocated to that file will be regarded as the Max file size of that file.

On the other hand, if the Auto-growth setting is enabled for a file in the file group, then the Max file size of that file will be one of the following:

  • If a specific size limit is explicitly set for the file, then this will be considered as the Max file size of that file.

  • If no size limit is set for the file, then the total capacity of the disk drive in which that file resides will be considered as the Max file size of that file.

So, if a file group consists of a few data files for which auto-growth is enabled and a few others for which it is disabled, then the Max file size of that file group will be a sum total of the following:

  • The sum of the space allocated to each of the files for which auto-growth is not enabled;

  • The sum of the maximum size limits, if defined, for each file for which auto-growth is disabled;

  • The sum of the total capacity of the disks containing the auto-growth-enabled files for which no size limit is defined. 

Free_disk_space Indicates the amount of disk space that is currently available for use for this file group. MB This measure is reported only for file groups. A high value implies that the database files in the file group have adequate disk space for growth. If the value of this measure is low, then you may have to fine-tune your auto-growth settings accordingly.
Available_space Indicates the percentage of Max file size that is currently available for use for this file group. Percent This measure is reported only for file groups.

This measure reports the Free disk space value as a percentage of Max file size. In other words:

Free disk space/Max file size * 100

If many files in a file group are set to auto-grow till disk capacity is reached, then, a high value of this measure indicates that there is enough space for the files to grow. A low value indicates that there is very little room for file growth.

 

Workaround:

Issue the following command:

DBCC UPDATEUSAGE (db_name)

NOTE: DBCC UPDATEUSAGE may take a long time to run because this command updates the dpages value in sysindexes for all the tables in the database, not just the dpages value for syslogs.

After issuing this statement, space reporting should be accurate. If it is not, try issuing the CHECKPOINT command to flush changes in the cache to disk so that they can be read in and calculated correctly.