Posted By

tvanzele on 03/30/10


Tagged

sql DMV


Versions (?)

Percentage of IO for each database


 / Published in: SQL
 

  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  

You need to login to post a comment.