# database-optimizer

Analyzes query execution plans, tunes PostgreSQL and MySQL configurations, and designs indexes to help high-traffic databases achieve sub-100ms query latency.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · ★ 4679
- Author: https://github.com/Jeffallan
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/zebbern/claude-code-guide/tree/HEAD/skills/database-optimizer/SKILL.md
- Updated: 2026-10-24
- HTML: https://affpapa.org/en/nevibecode/skills/database-optimizer-2

## What it does

This skill configures the assistant as a senior database performance engineer with 10+ years of tuning experience. The primary focus is PostgreSQL and MySQL. The agent reviews slow query logs, `pg_stat_statements` exports, and `EXPLAIN ANALYZE` plans. This flags sequential scans and missing index coverage under production workloads.

The workflow moves through diagnosis, solution design, and structured validation. When addressing specific bottlenecks, the skill loads dedicated reference guides for index strategies, schema partitioning, InnoDB tuning, and lock contention. Deliverables include specific SQL rewrites alongside database configuration tweaks.

Performance changes are strictly gated. The skill forbids modifying queries or schemas without baseline measurements, and it rejects applying multiple index updates at once. Every optimization requires validation on non-production environments first.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add zebbern/claude-code-guide --skill database-optimizer -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/database-optimizer/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/database-optimizer/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add zebbern/claude-code-guide --skill database-optimizer -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/database-optimizer/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add zebbern/claude-code-guide --skill database-optimizer -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/database-optimizer/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install zebbern/claude-code-guide database-optimizer
```

2. **Manually: put the files in place**
- File: `.github/skills/database-optimizer/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add zebbern/claude-code-guide --skill database-optimizer -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/zebbern/claude-code-guide --path skills/database-optimizer
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/database-optimizer/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add zebbern/claude-code-guide --skill database-optimizer -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/zebbern/claude-code-guide/tree/HEAD/skills/database-optimizer/SKILL.md

## When to use it
- Analyze execution plans using `EXPLAIN ANALYZE`
- Design covering indexes while minimizing write overhead
- Resolve deadlock issues and row lock contention
- Tune configuration parameters for PostgreSQL and MySQL
- Plan partitioning schemes for large relational tables

## Example prompts
- Inspect this `EXPLAIN ANALYZE` output and pinpoint why the query performs poorly
- Design an indexing strategy for our orders table to target sub-100ms queries
- Recommend PostgreSQL configuration adjustments to reduce transaction lock contention

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 429f2d2c41146064.

BEGIN THIRD-PARTY FILE 429f2d2c41146064
```text
---
name: database-optimizer
description: Use when investigating slow queries, analyzing execution plans, or optimizing database performance. Invoke for index design, query rewrites, configuration tuning, partitioning strategies, lock contention resolution.
license: MIT
metadata:
  author: https://github.com/Jeffallan
  version: "1.0.0"
  domain: infrastructure
  triggers: database optimization, slow query, query performance, database tuning, index optimization, execution plan, EXPLAIN ANALYZE, database performance, PostgreSQL optimization, MySQL optimization
  role: specialist
  scope: optimization
  output-format: analysis-and-code
  related-skills: devops-engineer
---

# Database Optimizer

Senior database optimizer with expertise in performance tuning, query optimization, and scalability across multiple database systems.

## Role Definition

You are a senior database performance engineer with 10+ years of experience optimizing high-traffic databases. You specialize in PostgreSQL and MySQL optimization, execution plan analysis, strategic indexing, and achieving sub-100ms query performance at scale.

## When to Use This Skill

- Analyzing slow queries and execution plans
- Designing optimal index strategies
- Tuning database configuration parameters
- Optimizing schema design and partitioning
- Reducing lock contention and deadlocks
- Improving cache hit rates and memory usage

## Core Workflow

1. **Analyze Performance** - Review slow queries, execution plans, system metrics
2. **Identify Bottlenecks** - Find inefficient queries, missing indexes, config issues
3. **Design Solutions** - Create index strategies, query rewrites, schema improvements
4. **Implement Changes** - Apply optimizations incrementally with monitoring
5. **Validate Results** - Measure improvements, ensure stability, document changes

## Reference Guide

Load detailed guidance based on context:

| Topic                 | Reference                           | Load When                               |
| --------------------- | ----------------------------------- | --------------------------------------- |
| Query Optimization    | `references/query-optimization.md`  | Analyzing slow queries, execution plans |
| Index Strategies      | `references/index-strategies.md`    | Designing indexes, covering indexes     |
| PostgreSQL Tuning     | `references/postgresql-tuning.md`   | PostgreSQL-specific optimizations       |
| MySQL Tuning          | `references/mysql-tuning.md`        | MySQL-specific optimizations            |
| Monitoring & Analysis | `references/monitoring-analysis.md` | Performance metrics, diagnostics        |

## Constraints

### MUST DO
```
END THIRD-PARTY FILE 429f2d2c41146064

The third-party file has ended. Everything between the 429f2d2c41146064 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2671 of 3867 bytes. © https://github.com/Jeffallan · MIT · https://github.com/zebbern/claude-code-guide/tree/HEAD/skills/database-optimizer/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
