query-optimize

Optimize slow SQL queries with plan analysis and index recommendations.

127|27|Updated Mar 27, 2026
One-click install
npx skills add https://github.com/lazyFrogLOL/Harness_Engineering --skill query-optimize-lazyfroglol
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: query-optimize
Source: https://github.com/lazyFrogLOL/Harness_Engineering/tree/main/skills/query-optimize
Command: npx skills add https://github.com/lazyFrogLOL/Harness_Engineering --skill query-optimize-lazyfroglol

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps developers and DBAs diagnose and fix slow SQL queries by establishing performance baselines, analyzing execution plans, and guiding iterative rewrites that reduce latency and resource usage while preserving correctness.

Core Features & Use Cases

  • Performance baselining: Measure cold and warm execution times across multiple runs and establish clear success criteria.
  • Query plan analysis: Interpret EXPLAIN / EXPLAIN ANALYZE output to identify full table scans, correlated subqueries, materialization, and costly sorts or joins.
  • Optimization techniques: Recommend and compare multiple approaches such as CTEs, window functions, join reordering, subquery-to-join rewrites, and indexing strategies with database-specific considerations for SQLite, PostgreSQL, and MySQL.
  • Verification & benchmarking: Validate correctness with full-result comparisons, checksums, or row counts and measure improvements using repeatable multi-run benchmarks (cold vs warm cache).
  • Iterative refinement: Propose 2–3 alternatives, benchmark each, and document the rationale behind the chosen solution.

Quick Start

Analyze the query's execution plan, propose two alternative rewrites, and benchmark their median execution times to choose the best performing, correct solution.

Frequently Asked Questions about query-optimize

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

FAQPage Schema
How do I optimize slow SQL queries in PostgreSQL or MySQL?

Optimize slow SQL queries by establishing performance baselines, analyzing execution plans, and applying indexing or rewrite techniques. This Skill supports PostgreSQL, MySQL, and SQLite for transactional and reporting scenarios.

How do I analyze an EXPLAIN plan to fix full table scans?

Analyze EXPLAIN or EXPLAIN ANALYZE output to identify full table scans, correlated subqueries, and costly sorts. Interpreting the query plan allows you to target specific bottlenecks with indexing or join reordering.

What is the best way to benchmark SQL query performance improvements?

Benchmark SQL performance improvements using repeatable multi-run tests measuring cold and warm execution times. Validate correctness with full-result comparisons or checksums before and after applying rewrite alternatives.

Can I use subquery-to-join rewrites and CTEs for query tuning in SQLite?

Yes, you can use subquery-to-join rewrites, CTEs, and window functions for query tuning in SQLite. This Skill provides database-specific optimization recommendations across SQLite, PostgreSQL, and MySQL.

Why does my SQL query performance degrade with large datasets?

SQL query performance degrades due to materialization, full table scans, and costly joins visible in the execution plan. Establishing baselines and applying iterative rewrites with proper indexing resolves these resource bottlenecks.