Command Palette

Search for a command to run...

UnylyUnyly
Back to skills

sql-query-optimization

FreeRuns bundled scriptsNot checked

Analyze and optimize SQL queries for performance. Use when improving slow queries, reducing execution time, or analyzing query performance in PostgreSQL and…

aj-geddesby aj-geddes★ 398 GitHub stars21 installs in other catalogs

About this skill

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

Install sql-query-optimization in Claude Code & Claude Desktop

Sign up to install this skill

Create a free account to reveal the install command and save the skill to your library.

  • Reveal the one-line install command
  • Save skills to your synced library
  • Get notified when skills update
Sign up freeI already have an account

Allowed tools

Tools this skill is permitted to call.

No restriction — this skill can use any tool.

Bundled files

references/analyze-current-performance.mdreferences/batch-operations.mdreferences/common-optimization-patterns.mdreferences/query-rewriting-techniques.mdscripts/validate-schema.shtemplates/migration-template.sql

FAQ

What does the sql-query-optimization skill do?

Analyze and optimize SQL queries for performance. Use when improving slow queries, reducing execution time, or analyzing query performance in PostgreSQL and MySQL.

How do I install the sql-query-optimization skill?

Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.

Does the sql-query-optimization skill run scripts?

Yes, this skill bundles executable scripts. Review the source before installing.

Related skills

Compare sql-query-optimization with