database-optimizer

Optimize slow PostgreSQL and MySQL queries with execution plan analysis and validation.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/kamelmh/opencode-config --skill database-optimizer-kamelmh
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: database-optimizer
Source: https://github.com/kamelmh/opencode-config/tree/main/skills/database-optimizer
Command: npx skills add https://github.com/kamelmh/opencode-config --skill database-optimizer-kamelmh

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps diagnose and fix database performance issues such as slow queries, inefficient execution plans, missing indexes, lock contention, and poor configuration choices across PostgreSQL and MySQL.

Core Features & Use Cases

  • Execution Plan Analysis: Review query plans to find sequential scans, bad join choices, stale statistics, and buffer or disk pressure.
  • Index and Query Optimization: Recommend index designs, query rewrites, covering indexes, partitioning strategies, and safer deployment approaches.
  • Performance Tuning and Monitoring: Adjust database settings, validate changes with before and after metrics, and track ongoing health with usage and wait statistics.
  • Use Case: A team sees a dashboard query slowing down during peak traffic, and this Skill can identify the bottleneck, propose a targeted fix, and verify that the change improves latency without harming writes.

Quick Start

Ask the assistant to analyze the slow query, inspect the execution plan, recommend the safest optimization path, and validate the result with before and after performance metrics.

Frequently Asked Questions about database-optimizer

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

FAQPage Schema
How do I fix slow PostgreSQL queries during peak traffic?

Fix slow PostgreSQL queries by capturing measured baselines, reviewing EXPLAIN ANALYZE execution plans for sequential scans, and applying targeted index tuning or query rewrites to reduce latency. Validate incremental changes with before and after metrics to prevent regressions.

What is the best way to analyze MySQL execution plans for bad join choices?

Analyzing MySQL execution plans requires reviewing query plans to detect bad join choices, stale statistics, and buffer pressure. Identify bottlenecks in the execution plan, then apply index design or query rewrites to optimize performance safely.

How do I identify and resolve database lock contention issues?

Database lock contention troubleshooting involves inspecting wait statistics and execution plans to find blocking queries. Resolve contention by rewriting queries, adjusting index designs, or applying partitioning strategies to minimize locking scope.

Can I tune PostgreSQL configuration to improve slow dashboard queries without harming writes?

PostgreSQL configuration tuning adjusts database settings to improve slow dashboard queries while validating changes with before and after metrics. Incremental adjustments ensure performance gains do not harm write latency or introduce regressions.

When should I use table partitioning for database optimization?

Table partitioning for database optimization is used when execution plan analysis shows sequential scans or disk pressure on large relational workloads. Apply partitioning strategies to isolate hot data, reduce lock contention, and improve query latency.

Why do I need measured baselines before optimizing slow database queries?

Measured baselines are required before optimizing slow database queries to establish current performance and validate post-change gains. Comparing EXPLAIN ANALYZE results and wait statistics before and after tuning prevents regressions and confirms improvements.