CtrlK
BlogDocsLog inGet started
Tessl Logo
PluginPublic

g14wxz/db-diagnostics-inspection

Provides database health diagnostics via slow query analysis, bottleneck identification, and Postgres inspection.

Quality

100%

Does it follow best practices?

Run evals on this skill

Adds up to 20 points to the overall score

View guide
SecuritybySnyk

Passed

No findings from the security scan

Overview
Quality
Evals
Security
Files

SKILL.mdskills/db-diagnostics-inspection/

name:
db-diagnostics-inspection
description:
Inspects database health by analyzing slow queries, identifying bottlenecks, and checking Postgres performance indicators. Use when diagnosing database issues, checking slow queries, inspecting DB health, finding performance bottlenecks, or troubleshooting Supabase Postgres problems.

Pre-Conditions

  • supabase-mcp-verification MUST have completed successfully.
  • The MCP execute_sql tool MUST be available and authenticated.
  • The pg_stat_statements extension MUST be enabled on the target database. If not enabled, HALT and instruct the operator to run CREATE EXTENSION IF NOT EXISTS pg_stat_statements;.

Execution Phases

Phase 1 — Collect Slow Query Data

  1. Execute SELECT query, calls, mean_exec_time, total_exec_time, rows FROM pg_stat_statements ORDER BY mean_exec_time DESC LIMIT 20; via MCP execute_sql.
  2. Record each query's mean_exec_time and calls count.
  3. Flag every query with mean_exec_time > 100ms as a slow-query candidate.

Phase 2 — Analyze Table Statistics

  1. Execute SELECT relname, seq_scan, idx_scan, n_live_tup, n_dead_tup, last_autovacuum FROM pg_stat_user_tables ORDER BY seq_scan DESC; via MCP execute_sql.
  2. Flag tables where seq_scan > 1000 AND idx_scan = 0 — these indicate missing indexes.
  3. Flag tables where n_dead_tup > 10000 — these indicate vacuum backlog.

Phase 3 — Evaluate Index Health

  1. Execute SELECT indexrelname, idx_scan, idx_tup_read, idx_tup_fetch FROM pg_stat_user_indexes WHERE idx_scan = 0 ORDER BY idx_tup_read DESC; via MCP execute_sql.
  2. Report all unused indexes (zero scans) as candidates for removal.
  3. Cross-reference Phase 2 missing-index tables and recommend index creation targets.

Phase 4 — Check Connection and Lock Pressure

  1. Execute SELECT state, count(*) FROM pg_stat_activity GROUP BY state; via MCP execute_sql.
  2. Execute SELECT relation::regclass, mode, granted FROM pg_locks WHERE NOT granted; via MCP execute_sql.
  3. Flag connection counts exceeding 80% of max_connections.
  4. Report all blocked locks with the waiting relation and lock mode.

Verification Report

The agent MUST produce a structured report containing:

  • Slow Queries: List of flagged queries with execution stats.
  • Table Health: Tables with sequential-scan-only access or vacuum backlog.
  • Index Recommendations: Unused indexes to drop, missing indexes to create.
  • Connection Status: Active/idle counts and any lock contention.
  • Severity Rating: CRITICAL / WARNING / HEALTHY for each category.

HALT if any category is CRITICAL and surface the finding immediately.

skills

db-diagnostics-inspection

tile.json