top of page

Find Your SQL Server Database IO stats by Data and Log Files

-- I/O Statistics by file for the current database

SELECT DB_NAME(DB_ID()) AS [Database Name],a.[file_id],b.name as [File_Name], num_of_reads, num_of_writes,

io_stall_read_ms, io_stall_write_ms,

CAST(100. * io_stall_read_ms/(io_stall_read_ms + io_stall_write_ms) AS DECIMAL(10,1)) AS [IO Stall Reads Pct],

CAST(100. * io_stall_write_ms/(io_stall_write_ms + io_stall_read_ms) AS DECIMAL(10,1)) AS [IO Stall Writes Pct],

(num_of_reads + num_of_writes) AS [Writes + Reads], num_of_bytes_read, num_of_bytes_written,

CAST(100. * num_of_reads/(num_of_reads + num_of_writes) AS DECIMAL(10,1)) AS [# Reads Pct],

CAST(100. * num_of_writes/(num_of_reads + num_of_writes) AS DECIMAL(10,1)) AS [# Write Pct],

CAST(100. * num_of_bytes_read/(num_of_bytes_read + num_of_bytes_written) AS DECIMAL(10,1)) AS [Read Bytes Pct],

CAST(100. * num_of_bytes_written/(num_of_bytes_read + num_of_bytes_written) AS DECIMAL(10,1)) AS [Written Bytes Pct]

FROM sys.dm_io_virtual_file_stats(DB_ID(), NULL) a

join sys.database_files b

on a.file_id=b.file_id

OPTION (RECOMPILE);


-- This helps you characterize your workload better from an I/O perspective

6 views0 comments

Comentarios


bottom of page