db-explain

Analyze PostgreSQL query execution plans using EXPLAIN ANALYZE to diagnose performance issues.

3|Updated Feb 7, 2026
One-click install
npx skills add https://github.com/gabrielnsmnto/kord-aios --skill db-explain-gabrielnsmnto
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: db-explain
Source: https://github.com/gabrielnsmnto/kord-aios/tree/main/src/features/builtin-skills/kord-aios/database/db-explain
Command: npx skills add https://github.com/gabrielnsmnto/kord-aios --skill db-explain-gabrielnsmnto

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Slow database queries are hard to diagnose without visibility into how PostgreSQL actually executes them. This Skill runs EXPLAIN (ANALYZE, BUFFERS) on your SQL queries and interprets the resulting execution plans, helping you identify sequential scans, missing indexes, poor row estimates, and memory spills. ## Core Features & Use Cases - Query Plan Analysis: Executes EXPLAIN with ANALYZE, BUFFERS, and VERBOSE options against a PostgreSQL/Supabase database and presents execution time, planning time, buffer hits, and row estimates. - Issue Diagnosis: Detects common performance problems such as sequential scans on large tables, missing join indexes, temp file spills from sorts, stale statistics, and slow RLS policies, with concrete fix suggestions like CREATE INDEX or VACUUM ANALYZE. - Iterative Optimization Workflow: Supports a baseline-hypothesize-test-remeasure loop, plan comparison between query variants, and JSON plan export for visualization tools like explain.depesz.com. - Use Case: A developer notices an API endpoint responding slowly. They pass the underlying SQL query to this Skill, discover a sequential scan filtering 500,000 rows due to an unindexed RLS policy, and apply the suggested partial index to cut execution time. ## Quick Start Ask the agent to run db-explain on your slow SQL query, for example by providing the query text and requesting a full EXPLAIN ANALYZE performance breakdown with index recommendations.

Frequently Asked Questions about db-explain

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

FAQPage Schema
How do I analyze a slow PostgreSQL query with EXPLAIN ANALYZE?▼

Run EXPLAIN (ANALYZE, BUFFERS) followed by your SQL query through psql against your database. The output shows actual execution time, buffer cache hits versus disk reads, and the plan nodes, which reveal bottlenecks like sequential scans or disk-based sorts.

What does a sequential scan in a query plan mean?▼

A sequential scan means PostgreSQL reads the entire table row by row instead of using an index. It is slow on large tables when filtering rows, and the typical fix is creating an index on the filtered or joined columns.

Is it safe to run EXPLAIN ANALYZE on production queries?▼

EXPLAIN ANALYZE actually executes the query, so it is safe for SELECT statements but dangerous for INSERT, UPDATE, or DELETE. Wrap write queries in a transaction with BEGIN and ROLLBACK to analyze them without persisting changes.

Why does my query plan show wrong row estimates?▼

Wrong row estimates come from stale table statistics, causing the planner to choose poor join strategies. Run ANALYZE or VACUUM ANALYZE on the affected tables to refresh statistics and let the planner make accurate cost decisions.

How do I fix a slow RLS policy in Supabase?▼

Slow RLS policies often force sequential scans because policy columns lack indexes. Create an index matching the policy filter, such as a partial index on user_id with a WHERE clause for non-deleted rows, so the policy check uses the index.