database-optimizer

Diagnose slow queries and optimize indexes for PostgreSQL and MySQL.

10.9k|1.0k|Updated Oct 20, 2025
One-click install
npx skills add https://github.com/Jeffallan/claude-skills --skill database-optimizer
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: database-optimizer
Source: https://github.com/Jeffallan/claude-skills/tree/main/skills/database-optimizer
Command: npx skills add https://github.com/Jeffallan/claude-skills --skill database-optimizer

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps diagnose slow queries and optimize database performance across PostgreSQL and MySQL.

Core Features & Use Cases

  • Query Analysis: Execution plans, slow queries, and index strategy.
  • Index Strategies: Covering/index optimization and partial indexes.
  • Tuning & Monitoring: PostgreSQL/MySQL tuning and monitoring patterns.
  • Validation: Before/after performance checks.

Quick Start

Analyze a slow query, generate an EXPLAIN ANALYZE plan, and propose an index improvement.

Frequently Asked Questions about database-optimizer

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

FAQPage Schema
How do I optimize slow database queries in PostgreSQL or MySQL?

Slow query optimization starts with analyzing EXPLAIN ANALYZE execution plans to identify bottlenecks, then creating strategic indexes and rewriting queries to reduce full table scans. Test changes in non-production, measure performance before and after, and monitor write performance to catch replication lag or lock contention in production replicas.

What's the best way to design indexes for better database performance?

Index design balances read speed with write overhead. Use covering indexes to serve queries entirely from the index, partial indexes for filtered datasets, and multi-column indexes for compound WHERE clauses. Avoid over-indexing writes; validate each index reduces query time measurably before deploying to production.

Can I diagnose database lock contention in high-traffic replicated environments?

Lock contention diagnosis involves analyzing slow query logs, execution plans, and replication lag metrics across replicas. Tuning configuration settings, rewriting queries to reduce lock scope, and partitioning strategies can resolve contention while accounting for delays in replicated writes.

How do I measure if a database optimization actually improved performance?

Measure performance by running EXPLAIN ANALYZE on the original and optimized query, comparing execution time and resource usage metrics. Document changes, test in staging first, and monitor production metrics post-deployment to confirm the improvement persists under real traffic.

Do I need to understand execution plans to optimize my database?

Yes. Execution plans from EXPLAIN ANALYZE reveal which operations consume the most time and resources—sequential scans, missing indexes, or inefficient joins. Reading plans is essential to target optimization efforts and validate that changes actually eliminate bottlenecks.

What precautions should I take before tuning database queries in production?

Always test optimizations in non-production environments first. Validate that new indexes don't degrade write performance or replication lag. Document all changes, monitor lock contention and query times post-deployment, and have a rollback plan in case performance degrades under real load.