Data SQL Optimization

Optimize SQL query performance using EXPLAIN analysis, indexing strategies, and common anti-pattern fixes. Use this skill when the user needs to speed up slow queries, design indexes, fix N+1 problems, or optimize database performance — even if they say 'this query is slow', 'optimize our database', 'which indexes do we need', or 'our dashboard takes 30 seconds to load'.

248 stars 30 forksDatabases

Install

skills CLI (Claude Code, Cursor, Codex and more)
npx skills add asgard-ai-platform/skills --skill data-sql-optimization
Manual install
git clone --depth 1 https://github.com/asgard-ai-platform/skills.git /tmp/skills
mkdir -p ~/.claude/skills
cp -r /tmp/skills/data-sql-optimization ~/.claude/skills/data-sql-optimization

Personal skills live in ~/.claude/skills. Use .claude/skills in a project folder to share a skill with your team.

From the SKILL.md

# SQL Query Optimization

## Framework

```
IRON LAW: Measure Before Optimizing

NEVER guess which query is slow or why. Use EXPLAIN (EXPLAIN ANALYZE in
PostgreSQL) to see the actual execution plan. The database's plan often
differs from what you expect — a query you think is efficient may do
a full table scan, and a complex-looking query may use an index perfectly.

Measure → identify bottleneck → fix → measure again.
```

### EXPLAIN Output Reading

Key metrics in EXPLAIN ANALYZE (PostgreSQL):
| Metric | What It Means | Red Flag |
|--------|-------------|----------|
| **Seq Scan** | Full table scan | On large tables (>100K rows) |
| **Index Scan** | Using an index | Expected for filtered queries |
| **Nested Loop** | Join method (row-by-row) | On large tables without index |
| **Hash Join** | Join method (hash table) | Normal for larger tables |
| **Sort** | Sorting results | Without index support on large sets |
| **Actual Time** | Milliseconds for this step | Compare to identify bottleneck |
| **Rows** | Actual rows processed vs estimated | Large mismatch = stale statistics |

### Indexing Strategy

| When to Index | Index Type | Example |
|--------------|-----------|---------|
| WHERE clause column | B-Tree (default) | `CREATE INDEX idx_user_email ON users(email)` |
| JOIN column | B-Tree | `CREATE INDEX idx_order_user ON orders(user_id)` |
| Composite filter | Composite index | `CREATE INDEX idx_order_status_date ON orders(status, created_at)` |
Read the full skill on GitHub

Details

Skill name
data-sql-optimization
Path
data-sql-optimization/SKILL.md
License
MIT
Repo updated
6 June 2026

FAQ

What does the Data SQL Optimization skill do?

Optimize SQL query performance using EXPLAIN analysis, indexing strategies, and common anti-pattern fixes. Use this skill when the user needs to speed up slow queries, design indexes, fix N+1 problems, or optimize database performance — even if they say 'this query is slow', 'optimize our database', 'which indexes do we need', or 'our dashboard takes 30 seconds to load'.

How do I install the Data SQL Optimization skill?

skills CLI (Claude Code, Cursor, Codex and more): npx skills add asgard-ai-platform/skills --skill data-sql-optimization. Skills go in ~/.claude/skills (personal) or .claude/skills (project), and Claude loads them automatically when a task matches the description.

Is Data SQL Optimization popular?

It lives in asgard-ai-platform/skills, which has 248 GitHub stars and 30 forks.

Related skills

Algo Ad Bidding

248

asgard-ai-platform/skills

Implement and select ad bidding strategies from manual CPC to automated target-CPA and target-ROAS. Use this skill when the user needs to choose a bidding strategy, set up automated bidding, or optimize bid parameters — even if they say 'what bidding strategy should I use', 'target CPA setup', or 'smart bidding configuration'.

Marketing, Sales & Business30

Algo Ad Budget

248

asgard-ai-platform/skills

Optimize advertising budget allocation across campaigns using marginal returns analysis. Use this skill when the user needs to distribute budget across multiple campaigns, optimize spend pacing, or maximize overall ROAS under budget constraints — even if they say 'how to split my ad budget', 'campaign budget optimization', or 'diminishing returns on ad spend'.

Marketing, Sales & Business30

Algo Ad Ctr

248

asgard-ai-platform/skills

Build CTR prediction models for estimating ad click-through rates from features. Use this skill when the user needs to predict click probability, build an ad ranking model, or evaluate ad creative performance — even if they say 'predict click rate', 'ad relevance scoring', or 'which ad will get more clicks'.

Marketing, Sales & Business30

Grad Systematic Review

248

asgard-ai-platform/skills

Conduct a systematic literature review following the PRISMA framework with explicit search strategy, inclusion and exclusion criteria, quality assessment, and transparent synthesis. Use this skill when the user needs to design a reproducible literature search, apply PRISMA flow documentation, develop inclusion and exclusion criteria, assess study quality, or when they ask 'how do I do a systematic review', 'what is PRISMA', or 'how do I make my literature review reproducible'.

Databases30

Supabase Admin

272

curiositech/some_claude_skills

Supabase administration, RLS policies, migrations, and schema design. Use for database architecture, Row Level Security, performance tuning, auth integration. Activate on "Supabase", "RLS", "migration", "policy", "schema", "auth.uid()". NOT for Supabase Auth UI configuration (use dashboard), edge functions (use cloudflare-worker-dev), or general SQL without Supabase context.

Databases46

Consultant Database Refresh

110

microsoft/cat-agent-skills

Refresh a recurring consultant questionnaire from approved content and a prior submission, showing prior versus proposed answers and aging-figure flags. Use for "refresh our eVestment profile", "update the Mercer questionnaire", "what changed since our Callan submission", "redline this manager profile", or "roll forward last year's answers". Do NOT use without a prior submission — use rfp-ddq-response-draft instead; for client mandate reviews, use institutional-client-review-prep instead; for investment commentary, use investment-commentary-draft instead; for fund comparisons, use peer-product

Databases122

Browse the most popular Claude skills, all databases skills, or write your own with the skills generator.