sql-query-optimizer

SkillDatabases & data

Analyzes SQL queries, execution plans, index usage, and lock contention to optimize database operations.

Use sql-query-optimizer in Claude, ChatGPT or Ahel Desktop

Free. Sign in, add sql-query-optimizer and connect your AI. About a minute.

Also: Claude Code · Cursor · Codex

Then ask your AI: use the sql-query-optimizer skill

Details

Instructions available. Your AI can read the instructions. Execution depends on the setup they require.

Add Ahel to your AI once: Claude, ChatGPT, Cursor, Claude Code or Codex. Then ask it to use this.

sql-query-optimizerStart free

What this skill tells your AI

The instructions your AI receives, as published by codebygarv/ai-skills in skills/development/sql-query-optimizer/SKILL.md and read by Ahel’s review.

Purpose

Analyze slow or resource-intensive SQL queries, interpret EXPLAIN / ANALYZE execution plans, and rewrite queries or recommend precise indexes to eliminate sequential scans and lock contention.

When to Use

  • A query causes high CPU, memory pressure, or connection saturation on the database.
  • Designing complex joins, aggregations, window functions, or subqueries.
  • Diagnosing deadlocks or table lock contention under concurrent writes.

What to Analyze

  1. Execution Plan: Inspect cost nodes, Seq Scans, Index Scans, Bitmap Index Scans, Nested Loops vs Hash Joins.
  2. Predicate SARGability: Identify functions on indexed columns (e.g. WHERE DATE(created_at) = ...) preventing index hits.
  3. Join & Subquery Efficiency: Convert correlated subqueries to CTEs, Window Functions, or Hash Joins.
  4. Indexing Strategy: Single-column, composite (ordering column matches query pattern), partial, or covering indexes.
  5. Pagination Mechanics: Replace large offset pagination (OFFSET 100000) with keyset/cursor pagination.

Output Format

  • Diagnosis: Why the query is slow (missing index, scan type, cardinality misestimate).
  • Optimized SQL: Clean rewritten query with explanation.
  • DDL Changes: Exact CREATE INDEX CONCURRENTLY statements needed.
  • Before vs After Metrics: Expected scan cost reduction and latency impact.

Avoid

  • Adding indexes on every column without considering write throughput degradation.
  • Omitting CONCURRENTLY on production index creation statements.

Signals

GitHub stars
26
Forks
1
Last commit
Aug 2026

Others that do the same job

Advanced
Item type
skill
Key
sql-query-optimizer-codebygarv
Source
github.com/codebygarv/ai-skills