Logo 
Search:

SQL Server Articles

Submit Article
Home » Articles » SQL Server » System FunctionsRSS Feeds

fn_virtualfilestats Function

Posted By: Sarita Patel     Category: SQL Server     Views: 1478

This article explains about fn_virtualfilestats function in sql server with examples.

fn_virtualfilestats function returns I/O statistics and log files for database files. 

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.


Syntax of fn_virtualfilestats Function :

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

[@DatabaseID =] database_id is a database id. It is of type integer.

[@FileID =] file_id is a file id. It is of type integer. 

It returns information about specified column name field value.

ColumnName

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

























Examples of fn_virtualfilestats Function :

Example 1 : Use of fn_virtualfilestats function in select clause 

SELECT  NumberReads, NumberWrites, BytesRead, BytesWritten 
FROM     ::fn_virtualfilestats(1,2)

Output
NumberReads    NumberWrites   BytesRead   BytesWritten
9                        100                   405504        425984

Above example returns information for specified column values of file id 2 of database id 1. 

  
Share: 


Didn't find what you were looking for? Find more on fn_virtualfilestats Function Or get search suggestion and latest updates.

Sarita Patel
Sarita Patel author of fn_virtualfilestats Function is from United States.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!