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.
npx skills add aj-geddes/useful-ai-prompts --skill database-performance-debugging -a claude-codeWhat 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-code2Manually: put the files in place
~/.claude/skills/database-performance-debugging/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/database-performance-debugging/
1Skills CLI (Vercel)
npx skills add aj-geddes/useful-ai-prompts --skill database-performance-debugging -a codex2Manually: put the files in place
.agents/skills/database-performance-debugging/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add aj-geddes/useful-ai-prompts --skill database-performance-debugging -a cursor2Manually: put the files in place
.cursor/skills/database-performance-debugging/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install aj-geddes/useful-ai-prompts database-performance-debugging2Manually: put the files in place
.github/skills/database-performance-debugging/SKILL.md1Skills CLI (Vercel)
npx skills add aj-geddes/useful-ai-prompts --skill database-performance-debugging -a gemini-cli2Platform CLI
gemini skills install https://github.com/aj-geddes/useful-ai-prompts --path skills/database-performance-debuggingManually: put the files in place
.devin/skills/database-performance-debugging/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add aj-geddes/useful-ai-prompts --skill database-performance-debugging -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
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