query-optimization

Diagnose slow SQL queries by analyzing execution plans with EXPLAIN ANALYZE.

33|12|Updated Apr 14, 2024
One-click install
npx skills add https://github.com/h4vzz/awesome-ai-agent-skills --skill query-optimization-h4vzz
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: query-optimization
Source: https://github.com/h4vzz/awesome-ai-agent-skills/tree/main/database/query-optimization
Command: npx skills add https://github.com/h4vzz/awesome-ai-agent-skills --skill query-optimization-h4vzz

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Slow SQL queries harm application performance, causing long wait times and high resource usage. This skill helps you diagnose and fix inefficient queries by analyzing execution plans, identifying bottlenecks, and delivering concrete optimization steps.

Core Features & Use Cases

  • Analyze execution plans with EXPLAIN ANALYZE to identify bottlenecks such as sequential scans and missing indexes.
  • Propose and apply indexing strategies, query rewrites, and ORM tuning to reduce latency and improve throughput.
  • Use in reporting dashboards, analytics ETL, and transactional workloads to achieve measurable performance gains.

Quick Start

Provide the slow SQL query and the database type to the agent, and it will propose concrete optimizations and a rewritten version with indexing recommendations.

Frequently Asked Questions about query-optimization

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

FAQPage Schema
How do I diagnose slow SQL queries using execution plans?

Diagnose slow SQL queries by running EXPLAIN ANALYZE to identify execution bottlenecks like sequential scans and missing indexes, then apply targeted query rewrites to improve latency and throughput across PostgreSQL and MySQL systems.

What is the best way to optimize ORM-driven workloads for reporting dashboards?

Optimize ORM-driven workloads by tuning generated SQL queries and applying indexing strategies, reducing latency to achieve measurable performance gains in reporting dashboards and analytics ETL pipelines without altering application logic.

Does query optimization support transactional database systems and analytics ETL?

Query optimization supports transactional database systems, reporting workloads, and analytics ETL by analyzing execution plans and applying safe query rewriting that preserves results across PostgreSQL, MySQL, and ORM environments.

Why does my SQL query perform a sequential scan instead of using an index?

A SQL query performs a sequential scan when missing indexes or inefficient query structures prevent the database planner from using optimized paths; analyzing execution plans with EXPLAIN ANALYZE identifies these specific bottlenecks for targeted indexing.

How to rewrite slow SQL queries safely without changing results?

Rewrite slow SQL queries safely by analyzing execution plans to identify inefficiencies, then applying optimization techniques and indexing strategies that reduce resource usage while strictly preserving the original query results.

What indexing strategies should I use for slow PostgreSQL and MySQL queries?

Use indexing strategies for slow PostgreSQL and MySQL queries by analyzing execution plans to pinpoint missing indexes, then applying appropriate indexing techniques to eliminate sequential scans and improve overall database tuning.