database-optimizer

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

Updated Aug 11, 2026
One-click install
npx skills add https://github.com/DucCuong159/Realtime-chatapp --skill database-optimizer-duccuong159
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: database-optimizer
Source: https://github.com/DucCuong159/Realtime-chatapp/tree/main/.agent/skills/database-optimizer
Command: npx skills add https://github.com/DucCuong159/Realtime-chatapp --skill database-optimizer-duccuong159

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Slow queries, missing indexes, N+1 patterns, and unplanned scaling bottlenecks degrade application performance and inflate infrastructure costs. This Skill provides expert guidance for systematically profiling, tuning, and scaling 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 Architecture: Design multi-tier caching with Redis, implement read replicas, sharding, and partitioning strategies for horizontal growth. - N+1 Detection & ORM Tuning: Identify and 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 assistant 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 full table scans or expensive join operations. Then rewrite the query, add composite or covering indexes matching the join and filter columns, and validate the improvement with benchmarking.

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

Detect N+1 patterns by profiling ORM query logs or application traces, then resolve them with eager loading, batch queries, or JOIN optimization. For GraphQL APIs, use DataLoader patterns with query batching and field-level caching.

What indexing strategy works best for high-traffic applications?

Design indexes based on actual query patterns rather than indexing every column. Use composite indexes with correct column ordering, partial indexes for filtered queries, and specialized types like GIN for JSONB or full-text search in PostgreSQL.

Does this approach work with NoSQL databases like MongoDB or DynamoDB?

Yes, the guidance covers MongoDB aggregation pipeline optimization and compound indexes, plus DynamoDB query patterns and GSI/LSI design. It also addresses cloud-native services like Aurora, Cosmos DB, and BigQuery.

When should I use database sharding versus read replicas?

Read replicas scale read-heavy workloads with eventual consistency trade-offs, while sharding addresses write-heavy workloads requiring horizontal partitioning. Choose sharding only when vertical scaling and read replicas no longer meet write throughput demands.

Why is query optimization not enough for my performance problem?

Bottlenecks often span the full stack: connection pooling, transaction isolation, missing cache layers, or schema design. Profile the entire system with APM tools and database metrics before assuming the query itself is the root cause.