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.
SELECT vfs.database_id, df.name, df.physical_name
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 (