/polymath-database:db-io-tuningfrom polymath-database
Cut database IO — cache and working set, read/write amplification, WAL/fsync, checkpoints, bloat, volume IOPS limits. Not plans or indexes.
Ships in polymath-database. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
The database is usually IO-bound before it is CPU-bound. Cut the bytes you read and write first; buy faster disks second.
Mode: analytical — judgment inside a fixed frame. Keep the output shape; every verdict cites its evidence; unknowns are marked [TBD] or [VERIFY], never filled in.
DataFileRead / WALWrite / log file sync, volume IOPS or throughput is near its ceiling, or latency tracks storage metrics.Not this when: the cause hasn't been located yet — start with polymath-database:db-performance-triage. Plan reading is polymath-data:sql-optimize; index choice is polymath-database:index-strategy.
blks_read/temp volume from the statements view.synchronous_commit, innodb_flush_log_at_trx_commit).Read-only. Measure; never change fsync, flush settings, or storage on a live system from this skill — recommend, owner applies.
blks_read means the working set outgrew RAM or a scan is evicting it. Fix order: stop the scan (index, predicate, partition pruning), then shrink the data (narrower rows, drop dead indexes, compress, archive cold rows — polymath-database:data-retention-archiving), then add memory.SELECT * pulling wide/TOASTed columns that are discarded. Narrow the projection, add covering columns for hot reads, cluster/partition by the common filter.pgstattuple, pg_stat_user_tables.n_dead_tup); fix the cause (autovacuum lag, long transactions pinning the horizon, update-heavy rows) before pg_repack or rebuilds.fillfactor headroom), and not rewriting unchanged values all cut it.synchronous_commit = off, innodb_flush_log_at_trx_commit = 2) trades up to a few hundred ms of recent commits on crash for latency — a business decision, never a default; never fsync = off.max_wal_size / redo log) cause write bursts and full-page-image storms; too-rare ones lengthen crash recovery. Check requested-vs-timed checkpoints, spread writes (checkpoint_completion_target), and size WAL/redo to the write rate.COPY / multi-row inserts / LOAD DATA, drop or defer secondary indexes for the load when feasible, load in sort order, and avoid per-row round trips.work_mem (Postgres temp_blks_written, MySQL Created_tmp_disk_tables) are avoidable IO — fix the query or raise the per-session limit for that job, not the global default.DB IO review: events-db (Postgres 15, 16 vCPU / 128 GB, gp3 12k IOPS / 500 MB/s)
Evidence
reads 9.8k IOPS avg, 11.7k peak (98% of 12k) · cache hit 91% (was 99.4% last month) · working set ≈ 190 GB vs 96 GB shared_buffers + page cache
writes 2.1k IOPS · WAL 38 MB/s · 74% of checkpoints requested (max_wal_size 4 GB) · commit p99 18 ms
bloat events_raw 41% dead/free space (long-running report held xmin 6 h)
Findings (ranked by bytes saved ÷ risk)
1. Seq scan from nightly export reads 140 GB and evicts the hot set → add created_at partition pruning (see partitioning-sharding); run on a replica.
2. events_raw bloat inflates every scan ~1.7× → fix the 6 h report transaction first, then pg_repack off-peak.
3. Checkpoints requested 74% → raise max_wal_size to 32 GB; expect fewer full-page images (verify pg_stat_wal.wal_fpi).
4. 7 indexes on a 2.1k writes/s table; 2 unused → each removed index cuts heap+WAL writes (see index-strategy).
Not changed: synchronous_commit stays on (payments data — durability is a business requirement).
Verify after each change: IOPS vs ceiling, cache hit, wal_fpi/s, checkpoint ratio, commit p99.
Unknowns: [TBD: whether the volume has burst credits — IOPS held at 12k for 6 h suggests provisioned, confirm in the volume metrics].
fsync / full_page_writes, or setting relaxed commit globally, to win a benchmark.VACUUM FULL or an unthrottled rebuild on a hot table during peak.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub mohammadbafkar/polymath --plugin polymath-database8 skills in this plugin
/data-retention-archivingDesign retention and archiving — tiers, partition-drop purges, legal hold, deletion requests, restore tests — for DBs, event logs, lakes./db-performance-triageTriage a slow or saturated database top-down (workload, waits, plans, IO, locks, pools) to ONE bottleneck. Engine-agnostic; not one query plan./db-scaling-strategyChoose how to scale a database, cheapest first — tune, cache, replicas, partition, shard, CQRS. Not shard-key design.Other plugins' skills for the same job