OpenParable
Skip to content
← Back to skills

Postgresql Performance

Testing & Quality
postgresql-performance

Postgresql Performance is an Agent Skill for testing & quality published in the majiayu000/claude-skill-registry repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.

Optimize PostgreSQL performance - EXPLAIN ANALYZE, indexing, query tuning

View on GitHub ↗
QUICK START

How to use this skill

Bring this guide into your coding agent with a prompt tailored to the tool you use.

  1. Open your project in Codex.
  2. Copy and paste the prompt below.
  3. Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/majiayu000/claude-skill-registry/blob/HEAD/skills/data/postgresql-performance/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/postgresql-performance, but wait for my approval before writing files or running scripts.

Copying this prompt does not install or run the skill. Review third-party files before use.

PostgreSQL Performance Skill

Atomic skill for query optimization

Overview

Production-ready patterns for EXPLAIN analysis, index design, and configuration tuning.

Prerequisites

  • PostgreSQL 16+
  • pg_stat_statements extension

Parameters

parameters:
  operation:
    type: string
    required: true
    enum: [analyze_query, create_index, tune_config, diagnose]
  target_time_ms:
    type: integer
    default: 100

Quick Reference

EXPLAIN Commands

EXPLAIN (ANALYZE, BUFFERS) SELECT * FROM users WHERE email = '[email protected]';

Index Types

Use CaseTypeExample
EqualityB-treeCREATE INDEX idx ON t(col)
JSONBGINUSING GIN(data jsonb_path_ops)
Time-seriesBRINUSING BRIN(created_at)

Key Metrics

MetricHealthyWarning
Seq Scan rows< 10K> 100K
Buffer hit> 99%< 95%
Planning time< 10ms> 100ms

Diagnostic Queries

-- Slow queries
SELECT query, mean_exec_time FROM pg_stat_statements ORDER BY mean_exec_time DESC LIMIT 10;

-- Unused indexes
SELECT indexrelname, idx_scan FROM pg_stat_user_indexes WHERE idx_scan = 0;

-- Table bloat
SELECT tablename, n_dead_tup FROM pg_stat_user_tables WHERE n_dead_tup > 10000;

Troubleshooting

ProblemCauseSolution
Seq ScanMissing indexCreate index
High buffer readsCold cacheIncrease shared_buffers
Wrong estimatesStale statsRun ANALYZE

Usage

Skill("postgresql-performance")