Skip to content

Surface avg I/O size (KB) per file in sp_PressureDetector#773

Merged
erikdarlingdata merged 1 commit intodevfrom
feat/pressuredetector-avg-io-size
Apr 29, 2026
Merged

Surface avg I/O size (KB) per file in sp_PressureDetector#773
erikdarlingdata merged 1 commit intodevfrom
feat/pressuredetector-avg-io-size

Conversation

@erikdarlingdata
Copy link
Copy Markdown
Owner

Summary

Adds avg_read_kb and avg_write_kb to the file metrics result set (and the matching @log_to_table columns), computed from sys.dm_io_virtual_file_stats.num_of_bytes_read / num_of_reads and the write counterparts.

A high avg_read_stall_ms with a small avg_read_kb points at random small reads (index seeks, lookups). The same stall with a large avg_read_kb points at large sequential pulls (read-ahead, scans, restores). Different remediations, same wait — surfacing the size disambiguates.

Wired through:

  • snapshot temp table (@file_metrics)
  • @log_to_table permanent table
  • snapshot CTE (fm/f) and delta CTE (fm vs fm2) branches
  • "Nothing to see here" placeholder row keeps the column shape

Test plan

  • Installed on SQL2022 (CREATE OR ALTER).
  • EXEC dbo.sp_PressureDetector @minimum_disk_latency_ms = 0, @skip_queries = 1, @skip_waits = 1, @skip_perfmon = 1; — both columns populated with sensible values (e.g. 123.88 KB avg read on a hot data file, 26.69 KB avg write — consistent with 8K page bursts up to 128K read-ahead).
  • Run with @log_to_table = 1 to verify the persisted columns land cleanly on a fresh install.
  • Delta-snapshot path (two snapshots in the same session) — exercised by code review only, not yet runtime.

Adds avg_read_kb and avg_write_kb to the file metrics output, computed
from sys.dm_io_virtual_file_stats num_of_bytes_read / num_of_reads (and
the write counterparts). Values flow through the snapshot temp table,
the @log_to_table path, and both the snapshot and delta CTE branches.

Helps explain disk-latency findings: a high avg_read_stall_ms paired
with a small avg_read_kb says random small reads, while the same stall
with a large avg_read_kb says big sequential pulls. Two different
remediations.
@erikdarlingdata erikdarlingdata merged commit 9c55964 into dev Apr 29, 2026
5 checks passed
@erikdarlingdata erikdarlingdata deleted the feat/pressuredetector-avg-io-size branch April 29, 2026 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant