I received following question:
“How do we know how many pending IO requests are there for database files (.mdf, .ldf) individually?”
Very interesting question and indeed answer is very interesting as well.
Here is the quick script which I use to find the same. It has to be run in the context of the database for which you want to know pending IO statistics.
USE DATABASE
GO
SELECT vfs.database_id, df.name, df.physical_name
,vfs.FILE_ID, ior.io_pending
FROM sys.dm_io_pending_io_requests ior
INNER JOIN sys.dm_io_virtual_file_stats (DB_ID(), NULL) vfs
ON (vfs.file_handle = ior.io_handle)
INNER JOIN sys.database_files df ON (df.FILE_ID = vfs.FILE_ID)
I keep this script handy as it works like magic every time. If you use any other script please post here and I will post it with due credit.
Reference: Pinal Dave (http://blog.SQLAuthority.com)
Filed under: PostADay, SQL, SQL Authority, SQL DMV, SQL Query, SQL Server, SQL Tips and Tricks, T SQL, Technology