/polymath-database:db-performance-triagefrom polymath-database
Triage a slow or saturated database top-down (workload, waits, plans, IO, locks, pools) to ONE bottleneck. Engine-agnostic; not one query plan.
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.
Read when SKILL.md points to them.
Don't tune what you haven't measured. Find which resource the database is actually starved of — CPU, IO, locks, memory, or connections — then fix that, not the query you happened to look at.
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.
Not this when: you already have one slow query and its plan — that is polymath-data:sql-optimize. For Postgres-specific catalog queries and settings, continue with polymath-database:postgres-performance after this.
Read-only. Gather with SELECT/SHOW/metrics only. Never KILL, VACUUM FULL, ALTER SYSTEM, drop an index, or flush a cache on a live primary — recommend; the owner applies. EXPLAIN ANALYZE executes the query: use a replica or a rollback block.
Walk the layers in order (a USE-method pass — Utilization, Saturation, Errors — per resource). Stop at the first layer with decisive evidence, not the first plausible one.
max_connections/pool size. Many active sessions on few cores is saturation (latency grows with every extra concurrent query); a wall of idle-in-transaction holds locks and snapshots. Fix with a pooler and a lower concurrency cap before touching queries.pg_stat_activity.wait_event, MySQL performance_schema waits, SQL Server sys.dm_os_wait_stats, Oracle ASH). Classify: CPU, IO read, IO write/WAL/fsync, lock, latch/LWLock, client (app is slow, not the DB). The dominant class decides the next step.calls × mean), not worst single run: pg_stat_statements, MySQL events_statements_summary_by_digest, SQL Server Query Store. Top 3–5 usually carry most of the load. Note calls/sec — a 2 ms query called 20k/s (an N+1) beats a 3 s report.polymath-data:sql-optimize): rows scanned vs returned, estimate-vs-actual drift, sort/hash spills, nested-loop blowups, plan flips after stats change.polymath-database:index-strategy. Bloat and table width → polymath-database:db-io-tuning.polymath-database:db-scaling-strategy. If one fix would drop a resource below ~60–70% sustained, do that fix first.DB triage: orders-db (Postgres 16, db.r6g.2xlarge, 8 vCPU / 64 GB, gp3 6k IOPS) — checkout p99 0.4 s → 2.8 s since Tue 14:10
Symptom: POST /checkout p99 regression; started with deploy 2025.41 (adds order-history lookup).
Evidence by layer
host CPU 38% · IOPS 5.9k/6k (98% of provisioned, queue depth 14) · mem fine ← IO saturated
conns active 22 / 120, idle-in-tx 0 ← not it
waits 61% IO:DataFileRead, 22% CPU, 4% Lock ← read IO
workload #1 SELECT … FROM orders WHERE customer_id=$1 ORDER BY created_at DESC LIMIT 20
41% of total time · 18k calls/s · mean 3.1 ms · shared_blks_read 96/call
plan Seq Scan on orders (rows removed by filter 99.98%) — no index on customer_id
Dominant bottleneck: read IO from a missing index on orders(customer_id, created_at DESC) (introduced by the new query).
Not the cause (checked): connections, locks, checkpoints, replica lag.
First fix (one change): CREATE INDEX CONCURRENTLY orders_customer_created_idx ON orders (customer_id, created_at DESC) — plan it with polymath-backend:migration-plan.
Verify: IOPS < 60% of provisioned, query mean < 0.3 ms, shared_blks_read/call < 5, checkout p99 back under 0.5 s.
Unknowns: [VERIFY: whether read replicas can absorb the order-history reads — would remove the load from the primary entirely].
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-io-tuningCut database IO — cache and working set, read/write amplification, WAL/fsync, checkpoints, bloat, volume IOPS limits. Not plans or indexes./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