SQL Pro
Optimizes SQL queries, designs database schemas, and troubleshoots performance issues.
Before & after
Same prompt, same agent — the only difference is the skill.
A 30-second query on 500K rows suggests there might be some performance issues. It could be a missing index, a suboptimal query plan, or maybe the query is doing a full table scan when it shouldn't. To help you optimize it, I'd need to see the actual query and ideally the EXPLAIN or EXPLAIN ANALYZE output from your database. I'd also want to know what columns you're filtering or joining on, and what version of the database you're using. Once I see those details, I can identify the bottleneck—whether it's the join strategy, the index situation, or maybe something in the WHERE clause that's preventing index usage.
QUERY PERFORMANCE ANALYSIS DIAGNOSTIC FIRST STEP: Run EXPLAIN ANALYZE EXPLAIN ANALYZE SELECT * FROM orders o JOIN customers c ON o.customer_id = c.id WHERE o.created_at > NOW() - INTERVAL '30 days' AND c.status = 'active' ORDER BY o.created_at DESC LIMIT 100; COMMON BOTTLENECK: Sequential scan on orders table (30 sec runtime = ~16K rows/sec = full table scan) ROOT CAUSE CHECK 1. Missing index on (created_at, customer_id)? Add composite index: CREATE INDEX idx_orders_date_customer ON orders(created_at DESC, customer_id); 2. Stale statistics? Run ANALYZE on table (planner uses outdated row estimates) 3. JOIN order wrong? Planner chose nested loop instead of hash join? OPTIMIZED QUERY SELECT o.id, o.total, c.name FROM orders o JOIN customers c ON o.customer_id = c.id WHERE o.created_at > NOW() - INTERVAL '30 days' AND c.status = 'active' ORDER BY o.created_at DESC LIMIT 100; EXPECTED PLAN: Index scan on idx_orders_date_customer (milliseconds), hash join with customers, early LIMIT cut REWRITE TACTICS -> Filter early: Move c.status to JOIN condition (not WHERE) to reduce joined rows -> Add covering index: Include columns needed in SELECT (c.name) to avoid table lookup -> Partition strategy: If table > 1GB, partition by month (query scans fewer partitions) VERIFY: Rerun EXPLAIN ANALYZE; target: < 100 ms, uses index scan, < 500 rows examined
About this skill
name: sql-pro description: Use when Optimizes SQL queries, designs database schemas, and troubleshoots performance issues.
Sql Pro
Optimizes SQL queries, designs database schemas, and troubleshoots performance issues. Use when a user asks why their query is slow, needs help writing complex joins or aggregations, mentions database performance issues, or wants to design or migrate a schema. Invoke for complex queries, window functions, CTEs, indexing strategies, query plan analysis, covering index creation, recursive queries, EXPLAIN/ANALYZE interpretation, before/after query benchmarking, or migrating queries between database dialects (PostgreSQL, MySQL, SQL Server, Oracle).
What you get
- Public GitHub repo
- the skills/sql-pro folder with SKILL.md and references.
Customize your output
- Fork the repo and extend the skill's reference files for your own stack conventions.
Example output
Activates on a matching request (e.g. building or reviewing Sql Pro code) and can chain with other skills in the pack.
Best for
Full-stack developers and engineering teams using Claude Code.
SKILL.md preview
---
name: sql-pro
description: Optimizes SQL queries, designs database schemas, and troubleshoots performance issues.
version: 1.0.0
category: Development / Languages
author: AgentVolt
license: proprietary
tags:
- development
- languages
---
# Sql Pro
Diagnoses slow queries, designs schemas suited to real read patterns, and ports SQL between dialects with the query plan as the source of truth, not guesswork.
## When to use
… (sign up to view the full skill)Featured in
More development skills
View all Development skills →Csharp Developer
Use when building C# applications with .NET 8+, ASP.NET Core APIs, or Blazor web apps.
Rust Engineer
Writes, reviews, and debugs idiomatic Rust code with memory safety and zero-cost abstractions.
PHP Pro
Use when building PHP applications with modern PHP 8.3+ features, Laravel, or Symfony frameworks.
Cpp Pro
Writes, optimizes, and debugs C++ applications using modern C++20/23 features, template metaprogramming, and high-performance systems techniques.