sql-optimization

Analyze SQL execution plans and rewrite subqueries as JOINs.

1.5k|222|Updated Jul 4, 2025
One-click install
npx skills add https://github.com/Datus-ai/Datus-agent --skill sql-optimization-datus-ai
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sql-optimization
Source: https://github.com/Datus-ai/Datus-agent/tree/main/tests/data/skills/sql-optimization
Command: npx skills add https://github.com/Datus-ai/Datus-agent --skill sql-optimization-datus-ai

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Slow, unoptimized SQL queries cause application latency, wasted compute resources, and poor user experience for data-driven workflows, making it difficult to deliver responsive analytics and reporting.

Core Features & Use Cases

  • Execution Plan Analysis: Identify performance bottlenecks by reviewing query execution plans to spot inefficient operations and full table scans.
  • Index Optimization: Detect missing indexes that slow down query performance and recommend appropriate index additions.
  • Query Rewriting: Convert unnecessary subqueries to JOINs where possible to reduce execution time and improve query efficiency.
  • Use Case: For example, if you have a slow monthly sales report query that takes 45 seconds to run, use this skill to optimize it to execute in under 3 seconds.

Quick Start

Use the sql-optimization skill to improve the performance of the slow customer churn analysis query in your PostgreSQL database.

Frequently Asked Questions about sql-optimization

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

FAQPage Schema
How do I optimize slow SQL queries causing application latency?

To optimize slow SQL queries, analyze the query execution plan to identify performance bottlenecks like full table scans, detect missing indexes, and rewrite subqueries as JOINs to reduce execution time.

What's the best way to identify missing indexes in PostgreSQL?

The best way to identify missing indexes is by reviewing the query execution plan using EXPLAIN analysis to spot full table scans and recommend appropriate index additions for faster performance.

Does query tuning work with BigQuery and MySQL databases?

Yes, query tuning works with BigQuery, MySQL, and PostgreSQL databases. It analyzes execution plans and rewrites inefficient subqueries to reduce query execution time across relational database systems.

How do I use EXPLAIN analysis to fix full table scans?

Use EXPLAIN analysis to review the query execution plan, identify inefficient operations like full table scans, and resolve them by adding missing indexes or converting subqueries to JOINs.

Why does my monthly sales report query take 45 seconds to run?

A monthly sales report query takes 45 seconds to run because of unoptimized operations like full table scans. Optimizing execution plans and indexes can reduce query execution time to under 3 seconds.