sql-query-optimization

aj-geddes/useful-ai-prompts · updated Apr 8, 2026

$npx skills add https://github.com/aj-geddes/useful-ai-prompts --skill sql-query-optimization
0 commentsdiscussion
summary

Analyze SQL queries to identify performance bottlenecks and implement optimization techniques. Includes query analysis, indexing strategies, and rewriting patterns for improved performance.

skill.md

SQL Query Optimization

Table of Contents

Overview

Analyze SQL queries to identify performance bottlenecks and implement optimization techniques. Includes query analysis, indexing strategies, and rewriting patterns for improved performance.

When to Use

  • Slow query analysis and tuning
  • Query rewriting and refactoring
  • Index utilization verification
  • Join optimization
  • Subquery optimization
  • Query plan analysis (EXPLAIN)
  • Performance baseline establishment

Quick Start

PostgreSQL:

-- Analyze query plan with execution time
EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON)
SELECT u.id, u.email, COUNT(o.id) as order_count
FROM users u
LEFT JOIN orders o ON u.id = o.user_id
WHERE u.created_at > NOW() - INTERVAL '1 year'
GROUP BY u.id, u.email;

-- Check table statistics
SELECT * FROM pg_stats
WHERE tablename = 'users' AND attname = 'created_at';

Reference Guides

Detailed implementations in the references/ directory:

Guide Contents
Analyze Current Performance Analyze Current Performance
Common Optimization Patterns Common Optimization Patterns
Query Rewriting Techniques Query Rewriting Techniques
Batch Operations Batch Operations

Best Practices

✅ DO

  • Follow established patterns and conventions
  • Write clean, maintainable code
  • Add appropriate documentation
  • Test thoroughly before deploying

❌ DON'T

  • Skip testing or validation
  • Ignore error handling
  • Hard-code configuration values

Discussion

Product Hunt–style comments (not star reviews)
  • No comments yet — start the thread.
general reviews

Ratings

4.471 reviews
  • Meera Iyer· Dec 28, 2024

    Keeps context tight: sql-query-optimization is the kind of skill you can hand to a new teammate without a long onboarding doc.

  • Camila Jackson· Dec 24, 2024

    sql-query-optimization is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.

  • Naina Verma· Dec 8, 2024

    We added sql-query-optimization from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.

  • Mei Chen· Dec 8, 2024

    Solid pick for teams standardizing on skills: sql-query-optimization is focused, and the summary matches what you get after install.

  • Arjun Tandon· Dec 8, 2024

    sql-query-optimization fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.

  • Michael Shah· Dec 4, 2024

    Useful defaults in sql-query-optimization — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.

  • Aisha Liu· Dec 4, 2024

    We added sql-query-optimization from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.

  • Meera Garcia· Nov 27, 2024

    sql-query-optimization has been reliable in day-to-day use. Documentation quality is above average for community skills.

  • Mia Ramirez· Nov 27, 2024

    I recommend sql-query-optimization for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.

  • Arjun Abbas· Nov 23, 2024

    sql-query-optimization is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.

showing 1-10 of 71

1 / 8