Skip to main content
skill CX Codex

database-performance-debugging — Claude Code skill: fix slow queries

A skill that walks your agent through finding slow SQL queries and reading their execution plans. Useful when the app drags or the database burns CPU.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add aj-geddes/useful-ai-prompts --skill database-performance-debugging -a claude-code
Open on GitHub

What database-performance-debugging does

The skill covers query analysis, index work and execution plan review. Four reference guides sit in the references/ directory: identifying slow queries, common issues and solutions, execution plan analysis, and the debugging process itself.

Quick start ships snippets for MySQL, PostgreSQL and SQL Server. On MySQL you turn on the slow query log and set long_query_time; on PostgreSQL you create the pg_stat_statements extension and sort queries by mean execution time; on SQL Server you pull stats from sys.dm_exec_query_stats. Profiling runs through EXPLAIN ANALYZE.

The pg_stat_statements extension has to exist before you query it, so create it first or those statements fail. The skill installs into Claude, Codex, Cursor, GitHub Copilot, Gemini CLI and OpenCode — only the platform flag changes.

What it helps with

  • track down queries that stall the application
  • turn on the slow query log and set a time threshold
  • read an execution plan with EXPLAIN ANALYZE
  • tell an index problem apart from a badly written query
  • catch a performance regression after a release

Example prompts for the agent

  • Find the slow queries in PostgreSQL, start with pg_stat_statements
  • Read the execution plan for this query and tell me what's missing
  • Turn on the slow query log in MySQL and show me what's piling up

How to install database-performance-debugging

1Skills CLI (Vercel)

npx skills add aj-geddes/useful-ai-prompts --skill database-performance-debugging -a claude-code

2Manually: put the files in place

~/.claude/skills/database-performance-debugging/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/database-performance-debugging/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about database-performance-debugging

How do I install database-performance-debugging in Claude?

Run npx skills add aj-geddes/useful-ai-prompts --skill database-performance-debugging -a claude-code. The skill then lands at ~/.claude/skills/database-performance-debugging/SKILL.md.

What does database-performance-debugging do?

It guides the agent through database performance work: finding slow queries, inspecting execution plans and tuning indexes. The reference guides in references/ carry the detail.

Which databases does the skill cover?

The quick start has examples for MySQL, PostgreSQL and SQL Server. PostgreSQL needs the pg_stat_statements extension.

Source text

SKILL.md · MIT
---
name: database-performance-debugging
description: >
  Debug database performance issues through query analysis, index optimization,
  and execution plan review. Identify and fix slow queries.
---

# Database Performance Debugging

## Table of Contents

- [Overview](#overview)
- [When to Use](#when-to-use)
- [Quick Start](#quick-start)
- [Reference Guides](#reference-guides)
- [Best Practices](#best-practices)

## Overview

Database performance issues directly impact application responsiveness. Debugging focuses on identifying slow queries and optimizing execution plans.

## When to Use

- Slow application response times
- High database CPU
- Slow queries identified
- Performance regression
- Under load stress

## Quick Start

Minimal working example:

```sql
-- Enable slow query log (MySQL)
SET GLOBAL slow_query_log = 'ON';
SET GLOBAL long_query_time = 0.5;

-- View slow queries
SHOW GLOBAL STATUS LIKE 'Slow_queries';
SELECT * FROM mysql.slow_log;

-- PostgreSQL slow queries
CREATE EXTENSION pg_stat_statements;
SELECT mean_exec_time, calls, query
FROM pg_stat_statements
ORDER BY mean_exec_time DESC LIMIT 10;

-- SQL Server slow queries
SELECT TOP 10
  execution_count,
  total_elapsed_time,
  statement_text
FROM sys.dm_exec_query_stats
ORDER BY total_elapsed_time DESC;

-- Query profiling
EXPLAIN ANALYZE
SELECT * FROM orders WHERE user_id = 123;
// ... (see reference guides for full implementation)
```

## Reference Guides

Detailed implementations in the `references/` directory:

| Guide | Contents |
|---|---|
| [Identify Slow Queries](references/identify-slow-queries.md) | Identify Slow Queries |
| [Common Issues & Solutions](references/common-issues-solutions.md) | Common Issues & Solutions |
| [Execution Plan Analysis](references/execution-plan-analysis.md) | Execution Plan Analysis |
| [Debugging Process](references/debugging-process.md) | Debugging Process |

## Best Practices

### ✅ DO

- Follow established patterns and conventions
- Write clean, maintainable code
- Add appropriate documentation
- Test thoroughly before deploying

### ❌ DON'T

- Skip testing or validation
- Ignore error handling
- Hard-code configuration values

© aj-geddes · MIT · aj-geddes/useful-ai-prompts

Similar skills

All skills for Data and databases →

From the same set118

changelog-maintenance A skill that gets your agent to write and maintain CHANGELOG.md in Keep a Changelog format, with Added, Changed, Fixed and Security sections. CX Codex +1 495installs grafana-dashboard Lets your agent write Grafana dashboards: panels, template variables, alerts and provisioning. Handy when you need monitoring up before the next deploy. CX Codex +1 494installs Model Hyperparameter Tuning A skill for tuning model hyperparameters: grid search, random search, Bayesian optimization with Optuna. Useful once baseline settings stop improving. CX Codex +1 494installs api-reference-documentation A skill that walks the agent through writing API reference docs: endpoints, auth, request and response examples, OpenAPI specs. CX Codex +1 494installs code-documentation A skill that makes the agent write documentation inside your code: JSDoc, Python docstrings, JavaDoc, inline comments and API notes. Useful when functions and classes need describing, not rewriting. CX Codex +1 492installs reactive-programming A skill for reactive streams in RxJS: observables, operators, backpressure. Useful when a project leans on async data and events. CX Codex +1 491installs api-pagination A skill that tells the agent how to page through big collections: offset/limit, cursors, keyset. Useful when a user list or search result set outgrows one response. CX Codex +1 489installs nosql-database-design Guides the agent through NoSQL schema work: MongoDB collections, DynamoDB tables, embedding vs referencing, indexes. Useful before the schema hardens in code. CX Codex +1 486installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor