fn_virtualfilestats

Transact-SQL Reference

Transact-SQL Reference

fn_virtualfilestats

Returns I/O statistics for database files, including log files.

Syntax

fn_virtualfilestats ( [@DatabaseID=] database_id
    , [ @FileID = ] file_id )

Arguments

[@DatabaseID=] database_id

Is the ID of the database. database_id is int, with no default.

[ @FileID = ] file_id

Is the ID of the file. file_id is int, with no default.

Tables Returned
Column Name Data type Description
DbId smallint Database ID
FileId smallint File ID
TimeStamp int Time at which the data was taken
NumberReads bigint Number of reads issued on the file
NumberWrites bigint Number of writes made on the file
BytesRead bigint Number of bytes read issued on the file
BytesWritten bigint Number of bytes written made on the file
IoStallMS bigint Total amount of time, in milliseconds, that users waited for the I/Os to complete on the file

Remarks

fn_virtualfilestats is a system table-valued function that gives statistical information, such as the total number of I/Os performed on a file. The function helps 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.

Examples
SELECT *
FROM :: fn_virtualfilestats(1, 1)