Returns I/O statistics for database files, including log files. In SQL Server, this information is also available from the sys.dm_io_virtual_file_stats dynamic management view.
Database timestamp at which the data was taken.
Number of reads issued on the file.
Number of bytes read issued on the file.
Total amount of time, in milliseconds, that users waited for the read I/Os to complete on the file.
Number of writes made on the file.
Number of bytes written made on the file.
Total amount of time, in milliseconds, that users waited for the write I/Os to complete on the file.
Sum of IoStallReadMS and IoStallWriteMS.
Value of the file handle.
Physical file size (count of bytes) on disk.
For database files, this is the same value as size in sys.database_files, but is expressed in bytes rather than pages.
For database snapshot sparse files, this is the space the operating system is using for the file.
fn_virtualfilestats is a system table-valued function that gives statistical information, such as the total number of I/Os performed on a file. You can use this function to help keep track of the length of time users have to wait to read or write to a file. The function also helps identify the files that encounter large numbers of I/O activity.
A. Displaying statistical information for a database
The following example displays statistical information for file ID 1 in the database with an ID of 1.
B. Displaying statistical information for a named database and file
The following example displays statistical information for the log file in the AdventureWorks sample database. The system function DB_ID is used to specify the database_id parameter.