role-database:query-optimization

Analyze execution plans and recommend index strategies across PostgreSQL, MySQL, MongoDB, and ClickHouse.

14|3|Updated Feb 22, 2026
One-click install
npx skills add https://github.com/rnavarych/alpha-engineer --skill role-database-query-optimization
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: role-database:query-optimization
Source: https://github.com/rnavarych/alpha-engineer/tree/main/plugins/roles/role-database/skills/query-optimization
Command: npx skills add https://github.com/rnavarych/alpha-engineer --skill role-database-query-optimization

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps diagnose and resolve slow database query performance by providing guidance on analyzing query execution plans and implementing effective indexing strategies across multiple database engines.

Core Features & Use Cases

  • Query Plan Analysis: Understand EXPLAIN output for PostgreSQL, MySQL, MongoDB, and ClickHouse to identify bottlenecks.
  • Index Strategy: Learn best practices for B-tree, Hash, GIN, GiST, BRIN, partial, and covering indexes.
  • Use Case: When a critical report is taking too long to run, use this Skill to analyze the query plan, identify missing indexes, and implement the correct index type to drastically speed up execution.

Quick Start

Analyze the query plan for a slow SQL query using the 'explain-indexes.md' reference.

Frequently Asked Questions about role-database:query-optimization

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

FAQPage Schema
How do I optimize database query performance using execution plans?

To optimize database query performance, you analyze execution plans using database-specific EXPLAIN commands to identify bottlenecks and then apply appropriate index strategies to speed up slow queries.

What is the best index strategy for slow PostgreSQL queries?

The best index strategy depends on your query patterns, utilizing B-tree for standard lookups, GIN or GiST for complex data types, and partial or covering indexes to efficiently optimize slow PostgreSQL queries.

Does this query optimization approach work with MongoDB and ClickHouse?

Yes, this query optimization approach works with MongoDB and ClickHouse, alongside PostgreSQL and MySQL, by interpreting their specific execution plans and recommending appropriate indexing strategies.

How do I interpret EXPLAIN output to find missing indexes?

You interpret EXPLAIN output by examining the execution plan to identify sequential scans or high-cost operations, which directly indicates where missing indexes are causing slow database query performance.

When should I use BRIN or Hash indexes instead of B-tree?

You should use BRIN or Hash indexes instead of B-tree when dealing with large tables with naturally sorted physical data for BRIN, or when performing simple equality comparisons where Hash indexes offer better query optimization.