sql-optimizer

Optimize slow SQL queries and schemas for PostgreSQL, MySQL, and SQLite.

Updated Sep 1, 2025
One-click install
npx skills add https://github.com/automacoescomerciaisintegradas/PAGIA --skill sql-optimizer-automacoescomerciaisintegradas
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sql-optimizer
Source: https://github.com/automacoescomerciaisintegradas/PAGIA/tree/main/.pagia/skills/sql-optimizer
Command: npx skills add https://github.com/automacoescomerciaisintegradas/PAGIA --skill sql-optimizer-automacoescomerciaisintegradas

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Este Skill oferece expertise em otimização de queries SQL, design de banco de dados e tuning de performance para PostgreSQL, MySQL e SQLite, permitindo identificar gargalos, sugerir índices eficientes, particionamento e técnicas de otimização.

Core Features & Use Cases

  • Otimização de consultas lentas: identifique problemas como full table scans, joins ineficientes e subqueries desnecessárias.
  • Design de schema e indexação: normalização, tipos de dados corretos, constraints e índices apropriados.
  • Análise de planos EXPLAIN e refatoração: interpretar planos, sugerir melhorias, aplicar particionamento e views materializadas.
  • Use Case: migrar/refatorar schemas para melhorar performance.

Quick Start

Diga ao assistente para otimizar uma consulta lenta em PostgreSQL e fornecer um conjunto recomendado de índices e mudanças de schema.

Frequently Asked Questions about sql-optimizer

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

FAQPage Schema
How do I optimize slow SQL queries in PostgreSQL?

To optimize slow SQL queries in PostgreSQL, you must identify performance bottlenecks like full table scans and inefficient joins. This involves analyzing EXPLAIN plans, rewriting subqueries, applying proper indexing, and checking schema normalization to tune performance.

What is the best way to design a database schema for performance?

Designing a database schema for performance requires applying correct data types, constraints, and appropriate indexes. Normalization checks and strategic partitioning or materialized views are also used to refactor schemas and eliminate bottlenecks in production environments.

Can I use this approach to tune MySQL and SQLite queries?

Yes, you can tune MySQL and SQLite queries using the same optimization techniques. The approach applies query rewriting, proper indexing, and schema normalization checks across PostgreSQL, MySQL, and SQLite to fix slow queries in development or production.

How do you analyze an EXPLAIN plan to fix query bottlenecks?

Analyzing an EXPLAIN plan involves interpreting the execution steps to identify unnecessary subqueries and full table scans. By examining these plans, you can suggest query refactoring, proper indexing, and partitioning to resolve the identified performance bottlenecks.

Why does my SQL query trigger a full table scan?

Your SQL query triggers a full table scan due to missing indexes, inefficient joins, or poorly written subqueries. Fixing this requires applying proper indexing, rewriting the query structure, and verifying schema normalization to optimize data retrieval.

When should I use materialized views for SQL optimization?

You should use materialized views for SQL optimization when refactoring schemas to improve performance on complex queries. They serve as a suggested improvement alongside partitioning and proper indexing to cache expensive query results and reduce execution time.