CtrlK
BlogDocsLog inGet started
Tessl Logo

g14wxz/query-explain-plan-debugging

Provides EXPLAIN ANALYZE workflow for identifying missing indexes, sequential scans, and query plan issues.

94

Quality

94%

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

index.mddocs/

Query Explain Plan Debugging

Provides EXPLAIN ANALYZE workflow for identifying missing indexes, sequential scans, and query plan issues.

Overview

This tile defines a systematic workflow for debugging slow PostgreSQL queries using EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON). The agent executes explain plans via MCP execute_sql, parses the JSON output, and identifies four categories of problems: sequential scans on indexed columns, missing indexes on WHERE/JOIN columns, row-estimate vs actual-row deviations, and nested-loop joins on large tables.

Reference

Explain Command Format

EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON) <query>;

Problem Detection Matrix

ProblemPlan SignalFix
Seq Scan on indexed column"Node Type": "Seq Scan" with index presentInvestigate planner settings, run ANALYZE
Missing index"Node Type": "Seq Scan" on WHERE/JOIN columnCREATE INDEX CONCURRENTLY
Stale statisticsPlan Rows vs Actual Rows ratio > 10xANALYZE table_name
Nested Loop on large set"Nested Loop" with inner > 1000 rowsAdd join-column index or restructure query
Low cache-hit ratioShared Read Blocks > Shared Hit BlocksANALYZE or tune shared_buffers

Key JSON Plan Fields

FieldPurpose
Node TypeIdentifies scan/join strategy
Plan RowsPlanner's row estimate
Actual RowsReal rows returned at execution
Shared Hit BlocksPages read from buffer cache
Shared Read BlocksPages read from disk

Dependencies

  • supabase-mcp-verification — MUST pass before executing any SQL via MCP.
  • db-diagnostics-inspection — Provides supplementary index and table-health diagnostics used in follow-up analysis.

Composition Position

This tile operates as a diagnostic utility invoked on-demand when a query performance issue is identified. It does not create permanent database objects. Other tiles that create indexes or RPCs invoke this tile to verify their output performs correctly.

docs

index.md

tile.json