query

Analyze EXPLAIN plans and recommend indexes for slow database queries.

26|8|Updated Mar 19, 2026
One-click install
npx skills add https://github.com/arbazkhan971/godmode --skill query-arbazkhan971
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: query
Source: https://github.com/arbazkhan971/godmode/tree/main/skills/query
Command: npx skills add https://github.com/arbazkhan971/godmode --skill query-arbazkhan971

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps developers and DBAs diagnose and fix slow database queries by interpreting EXPLAIN plans, identifying N+1 patterns, recommending indexes, and validating measurable latency improvements while accounting for write trade-offs.

Core Features & Use Cases

  • EXPLAIN analysis: Parse EXPLAIN and EXPLAIN ANALYZE output to surface sequential scans, nested loops, misestimated row counts, and disk-based sorts.
  • Index recommendations: Suggest appropriate index types (B-tree, GIN, BRIN, partial, covering) and production-safe creation patterns such as concurrent indexing with explicit write-cost guidance.
  • ORM & N+1 remediation: Identify N+1 query patterns from ORM traces and propose eager-loading, joins, or raw SQL rewrites plus verification steps.
  • Verification and safety: Provide repeatable EXPLAIN runs, median timing checks, test-suite validation, stop conditions, and rollback guidance to prevent regressions.
  • Use case: Speed up a user-facing API endpoint by removing N+1s and adding targeted indexes while ensuring write performance remains acceptable.

Quick Start

Ask the skill to analyze the slow SQL or ORM trace and recommend specific index and query changes to hit your target latency.

Frequently Asked Questions about query

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

FAQPage Schema
How do I fix N+1 query problems in my ORM?

To fix N+1 query problems, identify the pattern in ORM traces and rewrite the logic using eager-loading, joins, or raw SQL. Verify the remediation by running EXPLAIN ANALYZE to confirm the repeated queries are eliminated.

What is the best way to optimize slow PostgreSQL queries?

Optimize slow PostgreSQL queries by interpreting EXPLAIN plans to find inefficient sequential scans and nested loops, then applying targeted B-tree, GIN, or BRIN indexes to improve data retrieval latency.

Does adding a database index affect write performance?

Adding a database index does impact write performance by increasing insert and update costs. Mitigate this by using concurrent indexing patterns and evaluating write trade-offs against the query latency improvements.

How do I interpret EXPLAIN ANALYZE output for inefficient joins?

Interpret EXPLAIN ANALYZE output by looking for nested loops, misestimated row counts, and disk-based sorts. These indicators reveal inefficient joins and scans, guiding specific query rewrites or index additions.

Can I use concurrent indexing to avoid downtime in production?

Yes, you can use concurrent indexing to avoid locking tables in production. Establish production-safe creation patterns to maintain availability while adding indexes to fix high-latency queries.

What are the limitations of fixing slow queries with indexes?

Limitations of fixing slow queries with indexes include diminishing returns on complex aggregations and increased write overhead. Establish stop conditions and rollback guidance to prevent regressions if latency targets are unmet.