database-optimization

Optimize relational database performance with SQL EXPLAIN analysis and indexing strategies.

1|Updated Jan 6, 2026
One-click install
npx skills add https://github.com/hyukudan/ai-skills --skill database-optimization-hyukudan
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: database-optimization
Source: https://github.com/hyukudan/ai-skills/tree/main/examples/skills/database-optimization
Command: npx skills add https://github.com/hyukudan/ai-skills --skill database-optimization-hyukudan

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill addresses slow database queries and performance bottlenecks, ensuring your applications run efficiently and responsively.

Core Features & Use Cases

  • Pagination Strategies: Implements efficient cursor-based pagination to overcome the limitations of offset-based pagination.
  • N+1 Problem Solutions: Provides techniques like eager loading and batch loading to prevent inefficient query patterns.
  • Query Optimization: Guides on analyzing EXPLAIN output, optimizing indexes, and writing efficient SQL.
  • Connection Pooling & Locking: Explains best practices for managing database connections and preventing lock contention.
  • Use Case: When users report that loading a list of items is taking too long, this skill can help identify and fix the underlying database performance issues.

Quick Start

Use the database-optimization skill to analyze slow queries and suggest indexing improvements.

Frequently Asked Questions about database-optimization

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

FAQPage Schema
How do I fix slow database queries and performance bottlenecks?

Fix slow database queries by analyzing SQL EXPLAIN output, optimizing indexes, and resolving N+1 problems with eager loading. This eliminates performance bottlenecks by ensuring your relational database retrieves data efficiently without unnecessary query overhead.

What is the best way to implement efficient pagination in SQL?

Efficient SQL pagination is best implemented using cursor-based strategies rather than offset-based pagination. This approach overcomes the performance limitations of offset pagination by avoiding the need to scan and skip rows, resulting in faster query response times.

How does analyzing EXPLAIN output help with query optimization?

Analyzing EXPLAIN output helps with query optimization by revealing the SQL execution plan. It allows you to identify inefficient scans, missing indexes, and bottlenecks so you can restructure queries and add proper indexing for better performance.

How do I prevent N+1 query problems in my application?

Prevent N+1 query problems by implementing eager loading or batch loading techniques. These strategies fetch related data in a single query or batches instead of executing individual queries for each relationship, drastically reducing database load.

What are the best practices for managing database connection pooling and lock contention?

Best practices for managing connection pooling and lock contention involve configuring optimal pool sizes and reducing transaction scope. This prevents database lock contention and ensures efficient connection reuse without exhausting database resources.

When should I use cursor-based pagination instead of offset-based pagination?

Use cursor-based pagination instead of offset-based pagination when dealing with large datasets. Offset pagination scans and skips rows, causing significant delays, while cursor-based pagination directly seeks records, eliminating bottlenecks and improving query performance.