📊 Data Awaiting Security Review

SQL Query Optimizer

Analyze and optimize slow SQL queries. Reads EXPLAIN plans, suggests index strategies, rewrites subqueries as JOINs, and identifies N+1 patterns. Supports PostgreSQL, MySQL, and SQLite.

This skill takes slow queries and makes them fast. It reads EXPLAIN ANALYZE output, identifies missing indexes, suggests query rewrites, and helps you understand execution plans. Works with PostgreSQL, MySQL, and SQLite with dialect-specific optimizations.

sql optimization postgresql performance database

When to use

Use when queries are slow, you need to understand an EXPLAIN plan, optimize a report query, or identify why your ORM is generating inefficient SQL.

Examples

Optimize slow query

Rewrite a query that takes 30 seconds to run

This query takes 30s on 10M rows — here's the EXPLAIN ANALYZE output. How can I make it faster?

Index strategy

Design indexes for a set of common queries

Here are my 5 most frequent queries — suggest the optimal index strategy for PostgreSQL