query-performance-tuning

Diagnose slow database queries by interpreting EXPLAIN ANALYZE output.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/ohsonerdy/openclaw-frontier-stack --skill query-performance-tuning
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: query-performance-tuning
Source: https://github.com/ohsonerdy/openclaw-frontier-stack/tree/main/skills/query-performance-tuning
Command: npx skills add https://github.com/ohsonerdy/openclaw-frontier-stack --skill query-performance-tuning

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you quickly identify why a database query is slow and choose the safest, highest-leverage fix by interpreting execution plans, index behavior, and working-set limits.

Core Features & Use Cases

  • Diagnostic workflow before indexing: Confirm slowness, capture an actual plan with realistic parameters, identify the dominant slow node, then classify the root cause (wrong plan, wrong access path, or wrong working set).
  • EXPLAIN interpretation: Read the plan effectively (sequential vs index scans, row estimates vs actuals, filter effectiveness, sort/hash join behavior) for PostgreSQL- and MySQL-style signals.
  • Indexing and N+1 remediation: Recommend the right index shape (including composite/covering/partial patterns) and detect/fix N+1 query patterns common in ORM-heavy codebases.
  • Denormalization vs indexing decision: Provide a rule-based approach to when denormalization (computed columns, materialized views, or read stores) becomes warranted.
  • Working-set sizing and capacity actions: Determine whether the issue is disk-bound thrashing and select interventions like memory scaling, partitioning, archiving, or index bloat recovery.

Quick Start

Use it when you see that a request is slow and you want the fastest path to an actionable diagnosis: generate a slow-query tuning report for the specific SQL and its EXPLAIN ANALYZE output (with realistic parameters) explaining the failure mode and the most likely fix.

Frequently Asked Questions about query-performance-tuning

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

FAQPage Schema
How do I diagnose slow database queries using EXPLAIN ANALYZE output?

Diagnose slow database queries by capturing an actual execution plan with realistic parameters, locating the dominant slow node, and classifying the root cause across wrong plans, wrong access paths, or working-set issues to propose validated remediation steps.

When should I use denormalization instead of adding indexes to fix database performance?

Denormalization becomes warranted over indexing when query tuning rules indicate that computed columns, materialized views, or read stores better resolve the slow database query's working-set limits or access path inefficiencies than standard composite or covering indexes.

How do I detect and fix N+1 query patterns in ORM-heavy codebases?

Detect N+1 query patterns by analyzing slow-query logs or traces to identify repeated sequential access paths, then fix them through query rewrites or targeted index selection to optimize overall database performance and reduce redundant sequential scans.

What is the best way to resolve disk-bound thrashing and working-set issues in database performance tuning?

Resolve disk-bound thrashing and working-set issues by sizing memory requirements, then selecting capacity interventions like memory scaling, data partitioning, archiving, or index bloat recovery to ensure the active working set fits efficiently in memory.

Does this query tuning approach work for both PostgreSQL and MySQL execution plans?

Yes, query tuning applies to both PostgreSQL and MySQL by interpreting execution plan signals such as sequential versus index scans, row estimates versus actuals, filter effectiveness, and sort or hash join behavior to pinpoint the slow node.

Why are my database indexes not being chosen even after running query tuning?

Indexes may be mis-chosen due to outdated database statistics, leading to wrong access paths or incorrect row estimates in the execution plan; resolving this requires stats updates, query rewrites, or index design adjustments like partial or covering index patterns.