Query Optimization

Diagnose slow SQL queries using EXPLAIN plans, indexing, and partitioning.

1|3|Updated Feb 17, 2026
One-click install
npx skills add https://github.com/yogi100x/acceleration-council --skill query-optimization-yogi100x
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Query Optimization
Source: https://github.com/yogi100x/acceleration-council/tree/main/tech/data/query-optimization
Command: npx skills add https://github.com/yogi100x/acceleration-council --skill query-optimization-yogi100x

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Diagnose and resolve slow SQL queries by applying systematic optimizations, enabling consistent performance improvements.

Core Features & Use Cases

  • EXPLAIN plan interpretation to identify bottlenecks and indexing gaps.
  • Index design strategies including composite, covering, and partial indexes to accelerate reads.
  • Use of materialized views and partitioning for analytic workloads and high-volume data.
  • Real-world use case: optimize a reporting query by adding a composite index and refactoring subqueries to reduce execution time.

Quick Start

Run a baseline performance assessment on a sample workload and implement the first recommended optimization step.

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 an EXPLAIN plan?

Diagnosing slow SQL queries involves reading the EXPLAIN plan to identify execution bottlenecks and indexing gaps. This reveals table scan issues so you can apply targeted optimizations to reduce query execution time.

What's the best way to design indexes for complex SQL joins in analytics workloads?

Designing indexes for analytics workloads requires composite, covering, and partial indexes. This strategy accelerates reads across complex joins and high-volume data by ensuring queries retrieve data directly from the index structure.

When do I need partitioning or materialized views for database performance?

You need partitioning and materialized views for database performance when handling high-volume analytic workloads. These techniques restructure data access to prevent massive table scans and reduce execution time for reporting queries.

Does this query optimization approach work for both OLTP and analytics workloads?

Yes, this query optimization approach applies to both OLTP and analytics workloads. It handles simple lookups and complex joins using explain-driven changes and careful index design to ensure consistent performance improvements across workload types.

How do I safely deploy indexing changes to a production database?

To safely deploy indexing changes to a production database, apply guardrails for safe production deployment. This involves using an explain-driven approach to validate changes and ensure performance improvements without disrupting operations.

Why does refactoring subqueries improve SQL query performance?

Refactoring subqueries improves SQL query performance by simplifying the execution path and reducing intermediate result sets. Combined with adding a composite index, this reduces execution time for complex reporting queries.