Category Archives: Diagnostic Queries

How to: Get I/O Utilization by Database

This cool scripts obtain from Glenn Berry’s SQL Server Performance Scripts library to help you to find out the I/O utilization for each databases in your SQL Server instance. If you are looking for a script to shows you which database are the busiest one, like I do, in our database instance, this will the right script you need to grab and put in your toolbox.

-- Get I/O utilization by database (IO Usage By Database)
-- Helps determine which database is using the most I/O resources on the instance
-- Scripts adopted from SQL Server 2008 R2 Diagnostic Information Queries (February 2013).sql

	DB_NAME(database_id) AS [Database Name],
	CAST(SUM(num_of_bytes_read + num_of_bytes_written)/1048576 AS DECIMAL(12, 2)) AS io_in_mb
	sys.dm_io_virtual_file_stats(NULL, NULL) AS [DM_IO_STATS]
GROUP BY database_id;