sql-optimizer

Detect PostgreSQL SQL anti-patterns and generate EXPLAIN ANALYZE-based optimization recommendations.

1|Updated Feb 19, 2026
One-click install
npx skills add https://github.com/moveonha/pixel-ai-studio --skill sql-optimizer-moveonha
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sql-optimizer
Source: https://github.com/moveonha/pixel-ai-studio/tree/main/.claude/skills/sql-optimizer
Command: npx skills add https://github.com/moveonha/pixel-ai-studio --skill sql-optimizer-moveonha

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

PostgreSQL performance can suffer due to ORM/RAW SQL anti-patterns, missing indexes, and poorly rewritten queries. The skill detects these issues, analyzes queries with EXPLAIN ANALYZE, and provides concrete optimization ideas and code rewrites to speed up workloads.

Core Features & Use Cases

  • Detects N+1 queries, SELECT * usage, Cartesian products, and inefficient JOIN patterns.
  • Analyzes queries with EXPLAIN ANALYZE and suggests index strategies (partial, covering, expression-based indexes) and query rewrites.
  • Outputs ready-to-apply remediation steps for ORM (Prisma, TypeORM, Drizzle) and raw SQL across full-project or targeted inputs.

Quick Start

Run the sql-optimizer against a repository or file to generate anti-pattern reports and optimized query/code suggestions

Frequently Asked Questions about sql-optimizer

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I find and fix N+1 queries and other PostgreSQL performance anti-patterns?

To fix PostgreSQL performance anti-patterns like N+1 queries or SELECT * usage, scan project files to detect inefficient ORM and raw SQL code. This generates a structured report with query rewrites and index suggestions to remediate the issues.

What is the best way to analyze and optimize slow PostgreSQL queries?

The best way to optimize slow PostgreSQL queries is by running EXPLAIN ANALYZE to evaluate execution plans. This identifies bottlenecks and suggests index strategies like partial, covering, or expression-based indexes, alongside actionable query rewrites.

Can I use this SQL optimizer with ORM frameworks like Prisma, TypeORM, or Drizzle?

Yes, the SQL optimizer works with ORM frameworks like Prisma, TypeORM, and Drizzle. It detects anti-patterns in ORM-generated code and provides ready-to-apply remediation steps and optimized snippets tailored for these environments.

How do I get index recommendations for my PostgreSQL database schema?

To get index recommendations for your PostgreSQL database schema, analyze your SQL queries to identify missing or inefficient indexes. The process outputs schema change suggestions including partial, covering, and expression-based indexes to speed up workloads.

Why does my PostgreSQL query have a Cartesian product and how can I rewrite it?

A Cartesian product in PostgreSQL usually occurs due to inefficient JOIN patterns. By analyzing the query, you can detect these anti-patterns and receive change-ready code snippets that rewrite the JOIN logic to speed up workloads.