sql-query-optimizer

Analyze SQL EXPLAIN plans and propose indexes and rewrites to optimize slow queries.

5|Updated Dec 31, 2025
One-click install
npx skills add https://github.com/patricio0312rev/skillset --skill sql-query-optimizer-patricio0312rev
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sql-query-optimizer
Source: https://github.com/patricio0312rev/skillset/tree/main/templates/db-management/sql-query-optimizer
Command: npx skills add https://github.com/patricio0312rev/skillset --skill sql-query-optimizer-patricio0312rev

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @prisma/client.

What problem does it solve?

Identifies and fixes slow SQL queries by analyzing execution plans, proposing indexes, rewriting queries, and benchmarking performance.

Core Features & Use Cases

  • EXPLAIN Analysis: generates and interprets explain plans to locate bottlenecks.
  • Index Recommendations: suggests single- and multi-column indexes to speed up filters and joins.
  • Query Rewrites: replaces inefficient patterns with faster alternatives.
  • Performance Benchmarking: measures before/after performance to quantify improvements.

Quick Start

Run a slow SQL query through the optimizer to receive an explained plan, index recommendations, and a rewritten, faster version plus a benchmarking comparison.

Frequently Asked Questions about sql-query-optimizer

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

FAQPage Schema
How do I optimize slow SQL queries with EXPLAIN plans and indexes?

To optimize slow SQL queries, you analyze EXPLAIN plans to locate bottlenecks, propose single- and multi-column indexes for filters and joins, and rewrite inefficient patterns. Benchmarking measures before and after performance to verify improvements.

Does this SQL query optimizer work with PostgreSQL and MySQL?

Yes, this SQL query optimizer works with PostgreSQL, MySQL, and other relational engines. It applies indexing strategies and query rewrites to OLTP and analytical workloads containing complex joins and large tables.

How do I benchmark SQL performance before and after query rewrites?

You benchmark SQL performance by running controlled tests that measure execution times before and after applying query rewrites. This process requires access to an SQL database to apply benchmarks and verify performance gains.

Why does my SQL query ignore indexes during a complex join?

A SQL query may ignore indexes during a complex join due to inefficient query patterns or missing multi-column indexes. Analyzing the EXPLAIN plan identifies bottlenecks, allowing you to add proper indexes and rewrite the query.

What is the best way to speed up analytical SQL queries on large tables?

The best way to speed up analytical SQL queries on large tables is generating an EXPLAIN plan to locate bottlenecks, applying multi-column indexing strategies, and replacing inefficient patterns with faster query rewrites.

Do I need Prisma client to run SQL query optimization benchmarks?

Yes, you need Prisma client and access to an SQL database to generate EXPLAIN plans, apply benchmarks, and verify performance gains through controlled tests during the SQL query optimization process.