slow-query-optimize

slow-query-optimize is a skill for Claude Code, Codex from DeepSQLAI/deepsql. It costs 28 tokens per session (502 once invoked), scanned A, original, Apache-2.0.

A procedure for investigating one slow database query and suggesting a rewritten version. It uses the query plan, which describes how the database intends to run the statement.

In plain words
What is it for?
Use it to inspect a query plan, find performance problems, obtain an AI rewrite, or trace a slow live query from its fingerprint and samples.
Why use it?
It helps identify why a specific query is taking too long without guessing from the SQL text alone.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to inspect a query plan, find performance problems, obtain an AI rewrite, or trace a slow live query from its fingerprint and samples.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/deepsqlai/deepsql/slow-query-optimize
Install

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.

Any agent
npx skills add DeepSQLAI/deepsql --skill slow-query-optimize
Clone the repo
git clone --depth 1 https://github.com/DeepSQLAI/deepsql

Made for: Claude Code, Codex.

Wrote 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.

agentmods badge for slow-query-optimize

README.md
[![agentmods](https://agentmods.dev/badge/skills/deepsqlai/deepsql/slow-query-optimize/github.svg)](https://agentmods.dev/skills/deepsqlai/deepsql/slow-query-optimize)
Your own site
<a href="https://agentmods.dev/skills/deepsqlai/deepsql/slow-query-optimize"><img src="https://agentmods.dev/badge/skills/deepsqlai/deepsql/slow-query-optimize/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.

agentmods 80×15 button for slow-query-optimize

Your own site · 80×15
<a href="https://agentmods.dev/skills/deepsqlai/deepsql/slow-query-optimize"><img src="https://agentmods.dev/badge/skills/deepsqlai/deepsql/slow-query-optimize.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 28 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 502 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

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.

ModelPer sessionOnce invoked
Fable 5.1 $0.00028 $0.00502
Opus 5.5 $0.00011 $0.00201
Sonnet 5.5 $0.00006 $0.00100
Haiku 4.5 $0.00003 $0.00050

Measured 1mo ago against content hash 2bff054cb253, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

slow-query-optimize 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.

agent/skills/slow-query-optimize/SKILL.md · 32 lines

What it actually says

Slow Query Optimize

Use when the user points at a specific query and asks "why is this slow?" or "make this faster." For workload-level "what's slow overall?" use workload-analysis instead.

Procedure

  1. Resolve the connection (list_connections → UUID).

  2. Analyze the plan. analyze_query_plan(connectionId, sql) returns the parsed plan tree, performance issues, missing-index hints, and a written summary that already accounts for the connection's schema and business rules. Use useAnalyze: false by default — useAnalyze: true actually executes the query (and for a mutation, triggers the same admin + confirm gate as execute_sql).

  3. Get an AI rewrite for a specific statement with optimize_slow_query(connectionId, sql, avgExecutionTimeMs=…). Pass the average execution time to anchor the impact estimate. Note: this is single-query scoped and does NOT recommend indexes — route index questions to the index-advisor skill.

  4. If the query came from the live workload, identify it by fingerprint first: analyze_slow_queries (recent slow queries with fingerprints) → get_query_samples(fingerprint) for a real statement with bind values to plan against → get_slow_query_timeline(queryId) to confirm whether it's actually getting slower.

  5. Report: the root cause (slow node, bad estimate, missing index, plan drift), the proposed rewrite, and the expected improvement. If the real fix is an index, say so and hand off to index-advisor.

Guardrails

  • Don't run a mutation just to time it. useAnalyze: true on an UPDATE/DELETE executes it — only do that with admin role and explicit confirmation.
  • A rewrite that changes result semantics is a bug, not an optimization. Preserve the business rules (filters, soft-deletes) the original query respected.
Changes

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.

  1. 1mo ago First seen · 32 lines · 28 tokens per session scan A 2bff054cb253

Subscribe to this mod's changes

slow-query-optimize is a skill published in the GitHub repository DeepSQLAI/deepsql (39 stars, last pushed 5d ago), licensed Apache-2.0. It adds 28 tokens to every session and 502 once invoked, about $0.0001 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-30.

Related

Other skills, from other repositories

reproduce-bug

Reproduce a reported bug in googleapis/mcp-toolbox and decide whether it is real, delivering an evidence-backed verdict: confirmed, already fixed, misconfiguration, client-side, works as intended, not reproducible, or blocked. Use whenever a maintainer asks you to reproduce, verify, confirm, or investigate a bug…

googleapis/mcp-toolbox · 130 tokens

fix-failing-tests

Diagnose a failing test in the googleapis/mcp-toolbox repo and land a fix by reasoning from the actual error: read the failure, reproduce it, shrink it until the cause is forced into the open, then fix the cause. Use this whenever a test or CI job is red, a build breaks after a change, many packages fail at once, or a…

googleapis/mcp-toolbox · 87 tokens

triage-issues

Triage GitHub issues in the googleapis/mcp-toolbox repo: propose the correct labels (type / priority / product / status), check for duplicates, verify a bug has enough info to act on, and draft a triage comment. Use whenever a maintainer asks you to triage, label, categorize, prioritize, or "look at" an issue (or a…

googleapis/mcp-toolbox · 164 tokens

graphjin-eval

Create, extend, run, baseline, and diagnose GraphJin agent evaluations through the graphjin eval CLI.

dosco/graphjin · 27 tokens

triage

Diagnose and fix broken MCP servers in mcptoon — doctor, health, per-server probes, and the common failure playbook.

activeing123/mcptoon · 30 tokens

solr-query

To build and debug Solr queries: eDisMax, block join, JSON facets, kNN, explain.

griddynamics/rosetta · 27 tokens