Virtual File Stats
Queries that report cumulative virtual file I/O statistics per file and per database.
The cumulative I/O story for every file on the server, straight from fn_virtualfilestats. The first query reports per-file bytes read and written, total and split I/O stall time in milliseconds, operation counts and file size in MB; the second rolls it up to one row per database. (These are cumulative since the last restart - pair with a delta approach for rate measurements.)
SELECT
DB_NAME(vfs.DbId) DatabaseName,
mf.name,
mf.physical_name,
vfs.BytesRead,
vfs.BytesWritten,
vfs.IoStallMS,
vfs.IoStallReadMS,
vfs.IoStallWriteMS,
vfs.NumberReads,
vfs.NumberWrites,
(size*8)/1024 Size_MB
FROM
fn_virtualfilestats(NULL,NULL) vfs
INNER JOIN sys.master_files mf
ON mf.database_id = vfs.DbId
AND mf.file_id = vfs.FileId
GO
SELECT
DB_NAME(vfs.DbId) DatabaseName,
SUM(vfs.BytesRead) as BytesRead,
SUM(vfs.BytesWritten) as BytesWritten,
SUM(vfs.IoStallMS) as IoStallMS,
SUM(vfs.IoStallReadMS) as IoStallReadMS,
SUM(vfs.IoStallWriteMS) as IoStallWriteMS,
SUM(vfs.NumberReads) as NumberReads,
SUM(vfs.NumberWrites) as NumberWrites
FROM
fn_virtualfilestats(NULL,NULL) vfs
GROUP BY
vfs.DbId
GO