· Uwe Janke
Commands / Get-sqmFileLatencyReport

Get-sqmFileLatencyReport

PerformancesqmSQLTool v1.9.169+ · New🔓 VIEW SERVER STATE required
Reads sys.dm_io_virtual_file_stats together with sys.master_files and calculates the average read and write latency of every database file, plus MB read and written and the drive or mount point. A per-drive summary shows which volume is slow.

Cumulative (default): values since the last SQL Server start. Good for the overall picture, but a short slow phase disappears in a long uptime.
Sample (-SampleSeconds): two snapshots N seconds apart, the values are the difference. Shows what the storage delivers right now, for example during the nightly batch.

Rating: data files OK up to 20 ms, Warning up to 50 ms, above Critical. Log writes OK up to 5 ms, Warning up to 15 ms. Files with fewer than -MinIo I/Os are listed with n/a, because a handful of slow I/Os on an idle file says nothing. The latency SQL Server sees covers the whole path (driver, HBA, SAN, cache); compare with the Windows counters Avg. Disk sec/Read and sec/Write to locate the cause.

Parameters

ParameterTypeRequiredDefaultNotes
-SqlInstancestringOptional$env:COMPUTERNAMETarget SQL Server instance.
-SqlCredentialPSCredentialOptional, SQL or Windows credential.
-Databasestring[]Optionalall incl. tempdbOnly files of these databases (wildcards).
-SampleSecondsint (0-3600)Optional00 = cumulative since start, otherwise live sample over that many seconds.
-MinIolongOptional1000 / 10Minimum I/Os before a file is rated: 1000 cumulative, 10 in sample mode.
-OutputPathstringOptional<config>\FileLatencyReportDirectory for CSV and HTML.
-NoReportswitchSwitch$falseDo not write CSV/HTML, only return objects.
-NoOpenswitchSwitch$falseDo not open the HTML report after creation.
-EnableExceptionswitchSwitch$falseThrow exceptions immediately instead of Write-Error.

Execution Flow

START Snapshot of sys.dm_io_virtual_file_stats joined with sys.master_files for name, type and path -SampleSeconds? YES Wait N seconds, 2nd snapshot Values = difference NO Average latency per file and rating data: 20 / 50 ms, log write: 5 / 15 ms, fewer than -MinIo I/Os: n/a Summary per drive, worst first CSV + HTML report DONE

Return Value

PSCustomObject per file, worst first: DatabaseName, LogicalName, FileType, Drive, Reads, AvgReadMs, ReadRating, MBRead, Writes, AvgWriteMs, WriteRating, MBWritten, Rating, SizeMB, PhysicalName, Mode.

Examples

Latency since the last start
Get-sqmFileLatencyReport -SqlInstance "SQL01"
What does the storage deliver during the batch right now (60 s sample)
Get-sqmFileLatencyReport -SqlInstance "SQL01" -SampleSeconds 60
Only critical files
Get-sqmFileLatencyReport -SqlInstance "SQL01" -NoReport | Where-Object Rating -eq 'Critical'