Sql Query Clinic
by TopAgent
Diagnose slow or broken SQL: explain plans, index advice, rewrites, and correctness checks.
Secure checkout via Stripe
Works with the AI tools you already use
See it in action
You say
Optimize this Postgres query: SELECT * FROM orders WHERE customer_id = 502 AND status = 'pending' ORDER BY created_at DESC; EXPLAIN shows a Seq Scan on 2M rows.
Your agent does
Diagnosis: Seq Scan is occurring because there is no index covering the predicate. Recommendation: Create a composite index on (customer_id, status, created_at DESC). Result: This turns a 2M-row scan into a direct B-tree probe, eliminating the separate sort step.
What you get
About this skill
The problem
Slow production queries cause CPU spikes, timeouts, and buffer churn. Relying on generic database optimization advice often leads to redundant indexes or rewrites that don't actually fix the execution plan.
What it does
- Analyzes
EXPLAIN ANALYZEoutput to identifySeqScanbottlenecks and row estimate divergences. - Designs optimal composite indexes based on predicate selectivity and
ORDER BYrequirements. - Rewrites inefficient patterns like correlated subqueries,
NOT IN, andORfilters into performant joins and unions. - Identifies when stale statistics require an
ANALYZEorOPTIMIZErather than a code change.
Frameworks & tools
PostgreSQL and MySQL production environments.
Why this beats prompting it yourself
Generic prompts often suggest simple indexes that ignore column cardinality or multi-column sort orders. This skill follows a structured diagnosis loop that validates row count reductions and eliminates temp files, ensuring the fix actually changes the plan operators.
Use cases
- Eliminating full table scans on high-traffic reporting dashboards.
- Reducing latency by converting correlated subqueries into set-based joins.
- Optimizing composite indexes to remove expensive sort steps in
GROUP BYoperations. - Troubleshooting execution plan regressions after large schema migrations.
Known limitations
Focuses on relational databases only. Does not support NoSQL tuning, data warehouse modeling, or initial schema design from scratch.
How to install
Drop the file into your AI Agent. Works with Claude, Cursor, ChatGPT, and 20+ more.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill passes our trust checks below.
Security scanned
Passed our 8-point scan before listing
Fresh listing
Recently published to Agensi
30-day refund
Not a fit? Get your money back
Trust & safety
Security scanned
Verified clean today
- 30-day refund guarantee
- One-time purchase, yours forever
- Secure checkout via Stripe
Creator
13 skills on Agensi
Frequently Asked Questions
Popular in Data Engineering

Ceramic Compose Db
Ceramic Compose Db - A Premium AI Agent Skill

SQL Report Builder for Non-Technical Managers
Turns plain-English business questions into safe read-only SQL reporting plans, required table/field maps, readable SQL drafts, validation checks, and manager-friendly summaries.

Database Schema & Query Review Gate
Review a database schema, queries, or migration for the mistakes that get expensive in production — bad table design, missing or wrong indexes, slow and N+1 queries, SQL injection, and migrations that lock or break prod. Engine-aware (PostgreSQL, MySQL, SQLite, SQL Server), it runs an ordered review and returns a PASS/REVIEW/BLOCK verdict with prioritized fixes. Schema mistakes are the most expensive kind — this catches them before they ship.
Data Analysis Decision Engine
Data analysis engine with 4D decision matrix, 15-min quick analysis template, statistics reference, A/B testing playbook, user behavior analysis, SQL templates.