db-query-optimization

Analyze execution plans and runtime metrics to optimize SQL queries.

7|Updated Feb 14, 2026
One-click install
npx skills add https://github.com/KentoShimizu/sw-agent-skills --skill db-query-optimization
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: db-query-optimization
Source: https://github.com/KentoShimizu/sw-agent-skills/tree/main/skills/db-query-optimization
Command: npx skills add https://github.com/KentoShimizu/sw-agent-skills --skill db-query-optimization

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Identify and reduce latency and resource costs caused by inefficient query plans by guiding plan-aware rewrites based on actual execution evidence.

Core Features & Use Cases

  • Start from actual execution plans and runtime metrics to pinpoint the highest-impact queries.
  • Propose rewrites and access-path changes, including index adjustments and materialization strategies.
  • Compare candidates for latency gain, risk, and maintainability; roll out changes with monitoring to ensure plan stability.

Quick Start

Analyze production workload, identify top latency queries, and apply the best plan-aware rewrites with minimal risk.

Frequently Asked Questions about db-query-optimization

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

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

SQL query optimization starts by analyzing actual execution plans and runtime metrics to pinpoint high-latency operations. You then apply plan-aware rewrites and access-path changes to reduce resource usage and improve latency.

What is the best way to reduce SQL latency in transactional workloads?

Reducing SQL latency in transactional workloads involves collecting workload metrics to identify top queries, then proposing index adjustments and materialization strategies. Candidates are compared for latency gain and risk before rollout.

How do I ensure plan stability after rewriting a query?

Plan stability is maintained by rolling out query rewrites with active monitoring. You compare candidate rewrites for maintainability and risk, ensuring the new execution plan does not regress into inefficient access paths.

Can I use workload analysis to fix slow analytical queries?

Workload analysis identifies slow analytical queries by examining actual execution evidence. You can then apply materialization strategies and plan-aware rewrites to lower latency and resource costs across analytical workloads.

When should I use materialization strategies for query optimization?

Materialization strategies are used when execution-plan analysis reveals repetitive heavy computations. By materializing intermediate results, you can alter the access path to significantly reduce latency and resource consumption.

What are the limitations of index adjustments for query optimization?

Index adjustments alone may not fix plan stability issues if the underlying query logic is inefficient. You must use execution-plan analysis and apply plan-aware rewrites to prevent correctness regressions and ensure maintainability.