feat(pg_top_queries): add io_read_time_ms / io_write_time_ms for pg_stat_statements >= 1.10#16
feat(pg_top_queries): add io_read_time_ms / io_write_time_ms for pg_stat_statements >= 1.10#16HighviewOne wants to merge 4 commits into
Conversation
…TESTS=1 The _warnings-path test for pg_replication_status forces a permission error by revoking PUBLIC EXECUTE on pg_catalog.pg_current_wal_lsn(). A hard process kill between REVOKE and GRANT leaves the cluster broken for every non-superuser session until manually repaired. Add a destructiveTestsEnabled() helper in fixtures.ts and skip the risky describe block unless POSTGRES_MCP_DESTRUCTIVE_TESTS=1 is set. The test still runs on disposable CI clusters that opt in; local and shared clusters skip it safely. Closes #9.
|
Review punch list for this PR. Item 1 is a blocker -- as written the feature breaks
🤖 Generated with Claude Code |
- scripts/wsl-test-matrix.sh: add POSTGRES_MCP_DESTRUCTIVE_TESTS=1 so
the _warnings-under-restricted-role block doesn't silently drop out
of the PG matrix once the gate merges
- README.md: extend integration-test example with the new var and a
note that it's safe only on a disposable cluster
- admin.integration.test.ts: replace bare { skip: bool } with a string
reason so operators see how to opt in ("set POSTGRES_MCP_DESTRUCTIVE_TESTS=1
(disposable cluster only)")
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…tat_statements >= 1.10 pg_stat_statements 1.10 (Postgres 16) added shared_blk_read_time and shared_blk_write_time, which separate IO-bound wait from CPU time. This lets you distinguish "slow because disk" from "slow because CPU" -- the classic gap in pg_stat_statements output before 1.10. The columns are gated on a version check using the same compareVersions() already used for the 1.8 column-rename detection. NULLIF(x, 0) converts zero (meaning track_io_timing=off) to null so callers can tell "IO timing disabled" from "query did no IO". Enabling track_io_timing in postgresql.conf is documented in the tool description. Adds an integration test that verifies the columns are present (null or number) on installations with pg_stat_statements >= 1.10, and skips the assertion on older versions without failing. Closes #11.
…I, NULLIF comment Blocker fix: - shared_blk_read_time / shared_blk_write_time were selected for pg_stat_statements >= 1.10, but those column names only exist in 1.11 (PG 17). On 1.10 (PG 15) the correct names are blk_read_time / blk_write_time (unchanged semantics). Added hasSharedBlkCols gate at 1.11; 1.10 clusters now get blk_read_time / blk_write_time instead of a hard "column does not exist" error. Additional fixes: - NULLIF comment corrected: NULLIF(x, 0) maps both "track_io_timing off" and "no IO recorded" to null -- the two cases are indistinguishable without querying current_setting(), not told apart by null vs 0 - description: replaced unicode >= and em-dash with ASCII; corrected "1.10 (Postgres 16)" to "1.10 (Postgres 15+)" - integration test comments updated to describe the 1.10/1.11 branch and correct null semantics; gate and assertions unchanged (>= 1.10 is still the right cutoff for the feature being present) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
d482fb1 to
1080dd2
Compare
|
Addressed all review points. Blocker and branch hygiene resolved:
|
Closes #11.
What
pg_top_queriespreviously had no way to tell whether a slow query was CPU-bound or IO-bound.pg_stat_statements1.10 (Postgres 16) addedshared_blk_read_timeandshared_blk_write_timewhich answer exactly that question.How
compareVersions(extVersion, "1.10") >= 0— same pattern already used for the 1.8 column-rename detectionNULLIF(shared_blk_read_time, 0)converts zero (meaningtrack_io_timing = off) tonullso callers can distinguish "timing disabled" from "query did no IO"pg_stat_statements < 1.10, the columns are absent from the result entirely (not null, not zero — just not there)track_io_timingTest
Added an integration test that:
io_read_time_msandio_write_time_msare present as keys on every rownullor a JSnumber(not a string)Tested locally against pg_stat_statements 1.12 on Postgres 18. All 87 integration tests pass.
🤖 Generated with Claude Code