postgresql-optimization

Optimizes PostgreSQL queries, indexes, configuration, and maintenance through a seven-phase workflow.

Updated Jun 12, 2026
One-click install
npx skills add https://github.com/bilacchi/agents-skills --skill postgresql-optimization-bilacchi
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: postgresql-optimization
Source: https://github.com/bilacchi/agents-skills/tree/main/skills/postgresql-optimization
Command: npx skills add https://github.com/bilacchi/agents-skills --skill postgresql-optimization-bilacchi

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Slow PostgreSQL queries, missing indexes, and untuned configurations degrade application performance, and diagnosing them requires coordinating many separate tasks. This Skill provides a structured seven-phase workflow covering assessment, query analysis, indexing, tuning, maintenance, and monitoring. ## Core Features & Use Cases - Query Analysis: Run EXPLAIN ANALYZE, identify scan types, and review join strategies to find optimization opportunities. - Indexing Strategy: Identify missing indexes and design B-tree, composite, and partial indexes. - Configuration & Maintenance: Tune shared_buffers, work_mem, and autovacuum, then schedule VACUUM and ANALYZE routines. - Use Case: A production dashboard endpoint takes 8 seconds to load. Follow the workflow to profile the slow query, add a composite index, tune work_mem, and set up Grafana monitoring to confirm the improvement. ## Quick Start Analyze my slow PostgreSQL query and recommend an indexing and configuration tuning plan.

Frequently Asked Questions about postgresql-optimization

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

FAQPage Schema
How do I optimize slow PostgreSQL queries?▼

Start by running EXPLAIN ANALYZE on the slow query to identify scan types and join strategies. Then add appropriate indexes, rewrite inefficient joins or subqueries, and verify improvements by comparing execution times before and after changes.

How to design an indexing strategy for PostgreSQL?▼

Identify missing indexes from query plans, then create B-tree indexes for equality lookups, composite indexes for multi-column filters, and partial indexes for filtered subsets. Review index usage regularly to remove unused indexes that slow writes.

Which PostgreSQL configuration settings affect query performance?▼

The key settings are shared_buffers for caching, work_mem for sort and hash operations, effective_cache_size for planner estimates, and checkpoint settings for write behavior. Autovacuum tuning also prevents table bloat that degrades query plans.

Why is my PostgreSQL table bloated and how do I fix it?▼

Table bloat happens when dead tuples accumulate faster than autovacuum removes them, often from heavy updates or deletes. Schedule regular VACUUM and ANALYZE jobs, monitor autovacuum activity, and adjust its thresholds for high-churn tables.

When should I not rely on a general PostgreSQL optimization workflow?▼

Avoid applying generic tuning steps without environment-specific validation, since optimal settings depend on hardware, workload, and data volume. Always test changes in staging and consult a database specialist for mission-critical production systems.