postgresql-optimization

Optimizes PostgreSQL databases through query tuning, indexing strategies, and configuration management.

Updated Aug 11, 2026
One-click install
npx skills add https://github.com/DucCuong159/Realtime-chatapp --skill postgresql-optimization-duccuong159
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: postgresql-optimization
Source: https://github.com/DucCuong159/Realtime-chatapp/tree/main/.agent/skills/postgresql-optimization
Command: npx skills add https://github.com/DucCuong159/Realtime-chatapp --skill postgresql-optimization-duccuong159

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Slow PostgreSQL queries, missing indexes, and misconfigured database settings degrade application performance and are difficult to diagnose without a structured approach. This Skill provides a phased workflow for systematically assessing, tuning, and monitoring PostgreSQL databases. ## Core Features & Use Cases - Query Analysis & Tuning: Run EXPLAIN ANALYZE, identify scan types and join strategies, and rewrite inefficient queries with CTEs and pagination. - Indexing Strategy: Identify missing indexes and design B-tree, composite, and partial indexes based on actual query patterns. - Configuration & Maintenance: Tune shared_buffers, work_mem, and effective_cache_size, then schedule VACUUM, ANALYZE, and autovacuum monitoring. - Use Case: A production API endpoint becomes slow after data growth. Use this workflow to identify the offending query with EXPLAIN ANALYZE, add a composite index, adjust work_mem, and set up Grafana dashboards to prevent regression. ## Quick Start Analyze my slow PostgreSQL queries 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, join strategies, and execution time bottlenecks. Then rewrite inefficient queries, add appropriate indexes, and test the improvements against baseline performance.

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.

What PostgreSQL configuration settings affect performance most?

The key settings are shared_buffers for caching, work_mem for sort and hash operations, and effective_cache_size for planner estimates. Checkpoint settings and autovacuum configuration also significantly impact sustained production performance.

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

Table bloat occurs when dead tuples accumulate faster than autovacuum removes them. Schedule regular VACUUM and ANALYZE operations, monitor autovacuum activity, and check table bloat statistics to keep storage efficient.

When should I not use this PostgreSQL optimization workflow?

Avoid it when the task does not clearly match PostgreSQL optimization scope, or when required inputs, permissions, or success criteria are missing. Results still require environment-specific validation, testing, and expert review before production changes.