pg-io-deep-dive — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited pg-io-deep-dive (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
This skill guides a thorough investigation of PostgreSQL I/O performance using the full capabilities of the analyze_disk_io_patterns tool, correlating I/O data with query workload and configuration.
Use this skill when the user:
blks_read or low cache hit ratiostemp_blks_written in slow queries (work_mem too low)analyze_wait_eventspgtuner://health/cache -- Quick cache hit ratio check (lightweight, no full health scan)pgtuner://settings/memory -- Current memory configurationpgtuner://settings/checkpoint -- Current checkpoint configurationpgtuner://table/{schema}/{table_name}/stats -- Table-level I/O statisticsThis skill extends the I/O analysis portions of the `health_check` and `diagnose_slow_queries` MCP Prompts.
DATABASE_URIpg_stat_io metrics.Is the I/O problem...
|
+--> GENERAL (overall slow, high iowait)?
| --> Start with Step 1 (Buffer Pool) then Step 5 (Checkpoints)
|
+--> QUERY-SPECIFIC (one slow query with high blks_read)?
| --> Start with Step 2 (Table I/O) then Step 3 (Index I/O)
|
+--> TEMP-FILE RELATED (sort/hash spilling to disk)?
| --> Start with Step 4 (Temp Files)
|
+--> CHECKPOINT RELATED (log warnings about checkpoints)?
| --> Start with Step 5 (Checkpoints)
|
+--> UNKNOWN?
--> Start with Step 1 (Buffer Pool) for overall pictureTool: analyze_disk_io_patterns
Parameters:
analysis_type: "buffer_pool"
top_n: 20What this reveals:
Interpret results:
| Metric | Healthy | Warning | Critical |
|---|---|---|---|
| Cache hit ratio | > 99% | 95-99% | < 95% |
| Backend writes > 0 | Rare | Occasional | Frequent (checkpointer not keeping up) |
IF cache hit ratio < 99%:
Tool: review_settings
Parameters:
category: "memory"Check if shared_buffers is undersized for the working set.
IF backend writes > 0: Checkpointer/bgwriter is falling behind. Check bgwriter_lru_maxpages and checkpoint frequency.
Tool: analyze_disk_io_patterns
Parameters:
analysis_type: "tables"
schema_name: "public"
top_n: 20
min_size_gb: 0.01What this reveals:
heap_blks_hit vs heap_blks_readAgent reasoning:
heap_blks_read relative to heap_blks_hit: Data is not fitting in shared_buffersidx_blks_read: Index is too large for buffer cacheCross-reference with table stats: For the top I/O-heavy tables:
Tool: get_table_stats
Parameters:
table_name: "<hot_table>"
schema_name: "public"
include_indexes: true
order_by: "seq_scans"IF seq_scan count is very high AND the table is large, the table likely needs better indexes to avoid full scans.
Tool: analyze_disk_io_patterns
Parameters:
analysis_type: "indexes"
top_n: 20
min_size_gb: 0.01What this reveals:
Agent reasoning:
Tool: analyze_index_bloat
Parameters:
table_name: "<table_with_hot_index>"
schema_name: "public"
min_index_size_gb: 0.01
min_bloat_percent: 20find_unused_indexes.Tool: analyze_disk_io_patterns
Parameters:
analysis_type: "temp_files"
top_n: 20What this reveals:
Correlate with slow queries:
Tool: get_slow_queries
Parameters:
limit: 20
min_calls: 1
order_by: "mean_time"Look for queries with temp_blks_read > 0 or temp_blks_written > 0 in the results. These queries are the ones spilling to disk.
Then analyze the worst offender:
Tool: analyze_query
Parameters:
query: "<query_with_temp_blks>"
analyze: true
buffers: true
settings: true
format: "text"The settings: true parameter reveals if a session-level SET work_mem is in effect. The buffers: true shows temp buffer usage in the plan.
Look for in the plan:
Sort Method: external merge Disk: XXkB -> work_mem too low for this sortHash Batches: 16 -> Hash table spilling, increase work_memBuffers: temp read=XX written=XX -> Direct confirmation of temp file usageFix:
-- Session-level (test first):
SET work_mem = '256MB';
-- Then re-run the query to verify temp files are eliminated.
-- Global (if many queries affected):
ALTER SYSTEM SET work_mem = '128MB';
SELECT pg_reload_conf();Tool: analyze_disk_io_patterns
Parameters:
analysis_type: "checkpoints"
top_n: 10What this reveals:
Interpret:
| Metric | Healthy | Problem |
|---|---|---|
| Requested checkpoints | < 10% of total | > 20% (max_wal_size too small) |
| Checkpoint write time | < 30 seconds | > 60 seconds (disk too slow or too much dirty data) |
| Sync time | < 5 seconds | > 10 seconds (fsync bottleneck) |
IF requested checkpoints > 20%:
Tool: review_settings
Parameters:
category: "checkpoint"Recommend increasing max_wal_size (e.g., from 1GB to 4GB or 8GB).
The analyze_disk_io_patterns tool with analysis_type: "all" automatically includes pg_stat_io data when running on PostgreSQL 16+. This provides:
Agent decision: If the PostgreSQL version is < 16, the pg_stat_io section will show a message saying it's not available. Skip this section and rely on the other analysis types.
What to look for in pg_stat_io:
reads in bulkread context: Sequential scans pulling large data volumesextends on temp relations: Confirm temp file spill issues (Step 4)monitor_vacuum_progressBuffer Pool:
Table I/O Hotspots:
| Table | Size | Reads | Hits | Hit Ratio | Issue |
|---|---|---|---|---|---|
| orders | 12GB | 450K | 2.1M | 82.4% | Low hit ratio -- undersized shared_buffers or missing index |
Temp File Impact:
work_mem recommendationsCheckpoint Performance:
Action Items (prioritized):
After applying any I/O-related fix:
analysis_type: "buffer_pool".analyze_query (buffers: true) to confirm no more temp files.analysis_type: "checkpoints".pg-slow-query-diagnosis skill.work_mem globally is acceptable, or suggest session-level SET for that specific query.| Feature | Version | Notes |
|---|---|---|
pg_stat_io view | PG16+ | Detailed per-backend I/O statistics |
wal_compression = lz4 | PG15+ | Reduces WAL I/O |
BUFFERS in EXPLAIN | PG9.4+ | Universally available |
checkpoint_flush_after | PG9.6+ | Limit OS page cache dirty page accumulation |
analyze_disk_io_patterns calls are read-only. No data is modified.analyze_query with analyze: true executes the query. Use caution with write queries.review_settings is read-only.~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.