Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx skills add antonrisch/db-skills --skill debug-slow-queriesgit clone --depth 1 https://github.com/antonrisch/db-skillsWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/antonrisch/db-skills/debug-slow-queries)<a href="https://agentmods.dev/skills/antonrisch/db-skills/debug-slow-queries"><img src="https://agentmods.dev/badge/skills/antonrisch/db-skills/debug-slow-queries/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/antonrisch/db-skills/debug-slow-queries"><img src="https://agentmods.dev/badge/skills/antonrisch/db-skills/debug-slow-queries.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00046 | $0.01070 |
| Opus 5.5 | $0.00018 | $0.00428 |
| Sonnet 5.5 | $0.00009 | $0.00214 |
| Haiku 4.5 | $0.00005 | $0.00107 |
Grade A, and why
debug-slow-queries scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 192 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Debug Slow Queries
Quick Start
Goal: go from "slow" to a verified fix with minimal risk.
When to use this skill
- p95 latency spikes, timeouts, or sudden cpu growth tied to database load
- a deploy introduces query regression
- tables grow and plans flip (index → seq scan, join strategy changes)
inputs to collect (before changing anything)
- database engine + version
- query text + typical parameters (not placeholders only)
- runtime evidence: p50/p95, rows returned, timeouts, error logs
- table sizes / row counts (approx)
- relevant indexes + constraints
- environment: prod vs staging, read replica vs primary
Workflow (default)
- reproduce or capture
- reproduce in staging with production-like data, or capture the exact query + params from logs
- baseline
- record current p50/p95 and the explain plan
- read the plan
- identify where time is spent (scan, join, sort, aggregate)
- pick the cheapest safe fix
- rewrite query → add/adjust index → update stats → change schema
- verify
- re-run explain, compare timing, validate correctness
- roll out safely
- ship behind a flag if needed, monitor, keep rollback path
Explain plan patterns (what to look for)
scans
- sequential scan on large table
- likely missing selective predicate index, or predicate is not sargable
- index scan returning many rows
- index exists but selectivity is poor; may need different leading columns or a partial index
joins
- nested loop with huge inner iterations
- inner side needs an index on join key, or join order needs improvement
- hash join spilling
- work_mem/memory pressure or too many rows; reduce join input with earlier filters
sorts / aggregates
- sort on large result
- add index to match order by, or paginate differently
- group by on many rows
- pre-filter, pre-aggregate, or add covering index for grouping columns
Engine-specific commands
PostgreSQL
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 1mo ago First seen · 192 lines · 46 tokens per session scan A 753ccc235744
debug-slow-queries is a skill published in the GitHub repository antonrisch/db-skills (9 stars, last pushed 9mo ago), licensed MIT. It adds 46 tokens to every session and 1,070 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
Other skills, from other repositories
sql-optimizer
Analyzes SQL queries for missing indexes, N+1 patterns, suboptimal joins, and full table scans. Interprets EXPLAIN, detects anti-patterns, rewrites queries. Triggers on: "optimize this query", "slow query", "add indexes", "explain plan", "N+1 query", "why is this query slow".
tuning-oak-query-indexes
Use when a Jackrabbit Oak/AEM JCR query is slow, logs a traversal warning, or you're adding/changing a query and need to check or update its property/Lucene index definition so the query is answered by the index instead of in-memory filtering or sorting.
doris-debug-cloud
Use for Doris storage-compute separation (cloud mode) issues: meta-service latency, cache miss storms, object store throughput, and shared-nothing config conflicts in compute groups.
doris-debug-data-lake
Use for Doris external catalog issues: Hive/Iceberg/Paimon/Hudi query failures, metadata refresh, filesystem S3/HDFS connectivity, external MV rewrite misses.
doris-debug-deployment
Use for Doris FE/BE startup failures, port conflicts, prioritynetworks misrouting, metadir corruption, and ADD/DROP BACKEND issues.
doris-debug-materialized-view
Use for Doris sync MV (rollup) miss or async MTMV refresh/rewrite issues. Commands: SHOW ALTER TABLE MATERIALIZED VIEW, mvinfos(), EXPLAIN, REFRESH MATERIALIZED VIEW.