database-optimizer

Diagnose and optimize database queries, indexes, caching, and scaling architectures.

Updated May 8, 2026
One-click install
npx skills add https://github.com/kiprotichgidii/agent-skills --skill database-optimizer-kiprotichgidii
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: database-optimizer
Source: https://github.com/kiprotichgidii/agent-skills/tree/main/skills/database-optimizer
Command: npx skills add https://github.com/kiprotichgidii/agent-skills --skill database-optimizer-kiprotichgidii

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Slow queries, missing indexes, N+1 patterns, and poorly scaled database architectures degrade application performance and inflate infrastructure costs. This Skill provides expert guidance for systematically identifying bottlenecks and applying proven optimization techniques across relational, NoSQL, and cloud databases. ## Core Features & Use Cases - Query & Index Optimization: Analyze execution plans, rewrite complex queries, and design composite, partial, or specialized indexes for PostgreSQL, MySQL, SQL Server, MongoDB, and more. - Caching & Scaling Architectures: Design multi-tier caching with Redis, implement read replicas, sharding, and partitioning strategies for horizontal growth. - N+1 Detection & ORM Tuning: Resolve N+1 query patterns in Django ORM, SQLAlchemy, Entity Framework, and GraphQL DataLoader setups. - Use Case: Your e-commerce API slows down under traffic. Use this Skill to profile slow queries with pg_stat_statements, add covering indexes, introduce a Redis cache-aside layer, and validate improvements with pgbench. ## Quick Start Ask the AI to analyze your slowest database query and recommend an indexing and caching strategy for your specific database platform.

Frequently Asked Questions about database-optimizer

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

FAQPage Schema
How do I optimize a slow SQL query with multiple JOINs?▼

Start by running EXPLAIN ANALYZE to inspect the execution plan and identify costly sequential scans or nested loops. Then rewrite subqueries, reorder JOINs, and add composite or covering indexes matching the query's filter and join columns.

How to fix N+1 queries in Django ORM or SQLAlchemy?▼

N+1 queries are resolved with eager loading: use select_related or prefetch_related in Django, and joinedload or selectinload in SQLAlchemy. For GraphQL APIs, apply DataLoader patterns to batch and cache field-level fetches.

What caching strategy works best for database performance?▼

Cache-aside with Redis is the most common pattern: the application checks the cache first and populates it on misses. Combine it with TTL-based invalidation and an L1 application cache for frequently accessed, rarely changing data.

Does this optimization guidance apply to NoSQL databases like MongoDB?▼

Yes, it covers MongoDB aggregation pipeline optimization, compound index design, and DynamoDB GSI/LSI patterns. It also addresses cloud services like Aurora, Cosmos DB, and BigQuery with platform-specific tuning.

When should I denormalize my database schema?▼

Denormalize when read-heavy workloads suffer from expensive multi-table JOINs and benchmarks show measurable gains. Always validate with profiling data first, since denormalization trades write complexity and storage for read speed.

Why is my database index not being used by the query planner?▼

Planners skip indexes when statistics are stale, the index column order mismatches the query, or the table is small enough that a sequential scan is cheaper. Update statistics and verify column ordering against actual query patterns.