database-performance

Identify and implement database performance optimizations for queries, schemas, and caching.

Updated Jul 19, 2025
One-click install
npx skills add https://github.com/omanjaya/attendancedev --skill database-performance
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: database-performance
Source: https://github.com/omanjaya/attendancedev/tree/main/.claude/skills/database-performance
Command: npx skills add https://github.com/omanjaya/attendancedev --skill database-performance

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Slow queries and poor database design hinder application performance. This Skill provides practical guidance on schema design, indexing strategies, and caching patterns to accelerate data access.

Core Features & Use Cases

  • Index Strategies: Single, composite, covering, and unique constraints to speed lookups.
  • Query Optimization: Avoid N+1 queries, select only needed columns, and use chunking for large datasets.
  • Caching Patterns: Cache expensive queries and dashboard data to reduce load.

Quick Start

Add a composite index on (department_id, status) and fetch active employees with pagination, while enabling query caching for the result.

Frequently Asked Questions about database-performance

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

FAQPage Schema
How do I fix slow database queries in my web application?

Slow queries often stem from missing indexes, N+1 query patterns, or fetching unnecessary columns. Create composite indexes on frequently filtered columns, use selective column retrieval, and batch related queries to eliminate round trips. Implement caching for expensive or repeated queries to reduce database load.

What's the best indexing strategy for relational databases?

Indexing strategy depends on your query patterns. Use single indexes for frequently searched columns, composite indexes for multi-column filters, covering indexes to avoid table lookups, and full-text indexes for text search. UUID-based primary keys benefit from careful index placement to avoid fragmentation.

How do I avoid N+1 queries when fetching related data?

N+1 queries occur when fetching a parent record triggers separate queries for each child. Solve this by batch loading related records in a single query, using joins or eager loading, or caching aggregated results. Chunking large datasets prevents memory spikes while maintaining efficiency.

Can I use caching to reduce database load?

Yes. Cache expensive query results, dashboard data, and frequently accessed aggregates to minimize repeated database hits. Define cache invalidation rules based on data freshness requirements. Combine caching with query optimization—indexes and selective columns—for compounding performance gains.

What's the difference between composite and covering indexes?

Composite indexes span multiple columns and speed up queries filtering on those columns in order. Covering indexes include all columns needed for a query, allowing the database to satisfy the query from the index alone without accessing the table, reducing I/O cost.

How do I optimize schema design for query performance?

Schema design impacts performance through normalization trade-offs and indexing opportunities. Use unique constraints to enforce data integrity, design composite keys aligned with query filters, and structure tables to minimize joins. Pair schema choices with appropriate indexes and caching for relational databases.