Percentage of IO for each database


/ Published in: SQL
Save to your folder(s)



Copy this code and paste it in your HTML
  1. WITH Agg_IO_Stats
  2. AS
  3. (
  4. SELECT
  5. DB_NAME(database_id) AS database_name,
  6. CAST(SUM(num_of_bytes_read + num_of_bytes_written) / 1048576 AS DECIMAL(12,2)) AS io_in_mb
  7. FROM sys.dm_io_virtual_file_stats(NULL, NULL) AS DM_IO_Stats
  8. GROUP BY database_id
  9. )
  10. SELECT
  11. ROW_NUMBER() OVER(ORDER BY io_in_mb DESC) AS row_num,
  12. database_name,
  13. io_in_mb,
  14. CAST(io_in_mb / SUM(io_in_mb) OVER() * 100 AS DECIMAL(5,2)) AS pct
  15. FROM Agg_IO_Stats
  16. ORDER BY row_num;

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.