database-performance

Diagnose database performance issues using EXPLAIN analysis and schema reviews.

Updated May 6, 2026
One-click install
npx skills add https://github.com/korwlik23/skills --skill database-performance-korwlik23
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: database-performance
Source: https://github.com/korwlik23/skills/tree/main/v1/database-performance
Command: npx skills add https://github.com/korwlik23/skills --skill database-performance-korwlik23

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It helps identify and fix database performance bottlenecks by reviewing schema design, analyzing slow queries, and optimizing indexing and migrations while preserving data integrity.

Core Features & Use Cases

  • Query and plan optimization: Use EXPLAIN/EXPLAIN ANALYZE to pinpoint full scans, sorting/temp table issues, and N+1/unbounded query patterns, then propose targeted query rewrites and index improvements.
  • Schema and index strategy review: Recommend what must be indexed (foreign keys, join/where/order columns) and what should not be over-indexed, including composite index left-prefix rules and covering-index considerations.
  • Migration safety and scaling guidance: Provide migration risk analysis (locking, rollback, idempotency, FK behaviors), pagination strategy selection, connection pool guidance, monitoring metrics, and scaling options (replicas, caching, partitioning, sharding, archival).

Quick Start

Ask the AI to review your database schema and a slow query using EXPLAIN output, then produce an optimized indexing plan and a safe migration/action checklist based on realistic table sizes.

Frequently Asked Questions about database-performance

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

FAQPage Schema
How do I diagnose slow SQL queries using EXPLAIN output?

Schema indexing strategy requires indexing foreign keys and columns used in join, where, and order clauses. You must avoid over-indexing by applying composite index left-prefix rules and considering covering indexes to optimize read paths without degrading write throughput.

What is the best way to detect and fix N+1 query patterns?

Detecting N+1 query patterns involves analyzing query execution plans to identify unbounded loops of sequential database calls. Fix them by rewriting the queries to use proper joins or batch fetching, aligning pagination strategies, and verifying index coverage for the access paths.

How do I plan safe database migrations without locking tables?

Safe database migrations require analyzing locking risks, rollback procedures, and idempotency before execution. You evaluate foreign key behaviors and apply guardrails that prevent unsafe destructive changes without explicit confirmation, ensuring data integrity throughout the scaling process.

When do I need database scaling options like sharding or partitioning?

Database scaling options like partitioning, sharding, or archival are needed when you identify scaling bottlenecks that connection pooling and query optimization cannot resolve. You select these strategies alongside replicas and caching when monitoring metrics indicate sustained workload limits.

Does query optimization work for all relational database workloads?

Query optimization applies to common relational database workloads by reviewing schemas, slow queries, and indexing strategies. It produces evidence-backed recommendations with prioritized actions and clear risks, ensuring data integrity constraints are maintained across different database systems.