Database Optimization

OptimizeSlow database queries by tuning SQL performance and adding indexes.

4|Updated Mar 6, 2026
One-click install
npx skills add https://github.com/OpenLabor/openlabor --skill database-optimization-openlabor
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Database Optimization
Source: https://github.com/OpenLabor/openlabor/tree/main/skills_archive/database-optimization
Command: npx skills add https://github.com/OpenLabor/openlabor --skill database-optimization-openlabor

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Optimize slow database queries to improve performance.

Core Features & Use Cases

  • Identify slow queries from logs and execution plans.
  • Add appropriate indexes based on query patterns.
  • Avoid N+1 queries — use eager loading or batch queries
  • Monitor connection pool utilization and adjust limits

Quick Start

Run a profiling pass on your production workload and implement the recommended indexes and query rewrites.

Frequently Asked Questions about Database Optimization

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

FAQPage Schema
How do I optimize slow SQL queries in a production database?

To optimize slow SQL queries, you identify bottlenecks from execution plans and logs, then apply appropriate indexes and rewrite queries to avoid N+1 patterns. This improves application performance across OLTP, reporting, and analytics workloads.

What is the best way to resolve N+1 query problems in relational databases?

The best way to resolve N+1 query problems is to implement eager loading or batch queries. This reduces redundant database round-trips by fetching related data in a single operation, significantly boosting application performance.

How do I use execution plans to add appropriate database indexes?

You use execution plans to analyze query patterns and identify missing database indexes. By reviewing the plans, you can add appropriate indexes that target slow queries, directly improving data retrieval speed and overall performance.

Does database optimization work for both OLTP and analytics workloads?

Yes, database optimization works for both OLTP and analytics workloads. It identifies slow queries and monitors connection pool utilization across diverse production environments, ensuring performance improvements for transactional and reporting tasks.

Why does monitoring connection pool utilization improve query performance?

Monitoring connection pool utilization improves query performance by preventing connection exhaustion under heavy production workloads. Adjusting pool limits ensures applications maintain steady database access without overwhelming the relational database with concurrent requests.

When should I rewrite SQL instead of adding indexes to optimize a database?

You should rewrite SQL instead of adding indexes when execution plans reveal N+1 query patterns or inefficient joins. While indexes speed data retrieval, query rewrites like eager loading address structural inefficiencies that indexes alone cannot fix.