Surface avg I/O size (KB) per file in sp_PressureDetector#773
Merged
erikdarlingdata merged 1 commit intodevfrom Apr 29, 2026
Merged
Surface avg I/O size (KB) per file in sp_PressureDetector#773erikdarlingdata merged 1 commit intodevfrom
erikdarlingdata merged 1 commit intodevfrom
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
avg_read_kbandavg_write_kbto the file metrics result set (and the matching@log_to_tablecolumns), computed fromsys.dm_io_virtual_file_stats.num_of_bytes_read / num_of_readsand the write counterparts.A high
avg_read_stall_mswith a smallavg_read_kbpoints at random small reads (index seeks, lookups). The same stall with a largeavg_read_kbpoints at large sequential pulls (read-ahead, scans, restores). Different remediations, same wait — surfacing the size disambiguates.Wired through:
@file_metrics)@log_to_tablepermanent tablefm/f) and delta CTE (fmvsfm2) branchesTest plan
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).@log_to_table = 1to verify the persisted columns land cleanly on a fresh install.