database-optimizer

Analyze slow PostgreSQL and MySQL queries and optimize execution plans.

Updated Mar 17, 2026
One-click install
npx skills add https://github.com/Estom/aiflex --skill database-optimizer-estom
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: database-optimizer
Source: https://github.com/Estom/aiflex/tree/main/skills-repo/Jeffallan-skills/database-optimizer
Command: npx skills add https://github.com/Estom/aiflex --skill database-optimizer-estom

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Helps teams identify and resolve slow queries, inefficient execution plans, and configuration issues that cause high latency and poor database performance.

Core Features & Use Cases

  • Execution Plan Analysis: Interpret EXPLAIN / EXPLAIN ANALYZE output to find cardinality estimation errors, expensive joins, and I/O hotspots.
  • Index & Schema Strategy: Recommend B-tree, partial, covering, GIN/GiST, and expression indexes, including ordering and include-column guidance.
  • Tuning & Maintenance: Advise PostgreSQL and MySQL configuration changes, autovacuum/vacuum strategies, partitioning, and index maintenance.
  • Use Case: Triage a production slow query by analyzing pg_stat_statements or slow query logs, designing targeted indexes, and validating improvements with before/after metrics.

Quick Start

Analyze the provided EXPLAIN ANALYZE output and recommend specific index changes, query rewrites, and validation queries to measure improvement.

Frequently Asked Questions about database-optimizer

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

FAQPage Schema
How do I analyze EXPLAIN ANALYZE output to fix slow PostgreSQL queries?

To analyze EXPLAIN ANALYZE output for slow PostgreSQL queries, review the execution plan to identify cardinality estimation errors, expensive joins, and I/O hotspots. This process isolates inefficient operations so you can apply targeted index changes and query rewrites to improve latency.

What's the best way to design indexes for MySQL performance tuning?

The best way to design indexes for MySQL performance tuning is to evaluate B-tree, partial, covering, and expression indexes based on your query patterns. Proper index design targets expensive joins and I/O hotspots identified in the execution plan to reduce query latency.

Can I use query optimization to resolve lock contention in PostgreSQL?

Yes, you can use query optimization to resolve lock contention in PostgreSQL by analyzing execution plans and performance metrics. Triage identifies blocking queries and expensive operations, allowing you to apply query rewrites, configuration tuning, and targeted indexes to reduce contention.

Does this approach work for both PostgreSQL and MySQL environments?

Yes, this query optimization approach works for both PostgreSQL and MySQL environments. It supports index design, execution plan review, configuration tuning, and partitioning across both database systems to resolve high latency and poor performance.

How do I triage a production slow query using pg_stat_statements?

To triage a production slow query using pg_stat_statements, analyze the collected performance metrics and slow query logs to locate high-latency operations. Review the EXPLAIN ANALYZE output, design targeted indexes, and validate improvements with before and after metrics.

When should I use partitioning instead of adding indexes for database performance?

You should use partitioning instead of adding indexes when index maintenance and configuration tuning are insufficient to manage large datasets and I/O hotspots. Partitioning distributes data to reduce scan times, complementing B-tree or covering indexes for complex query optimization.