postgres

Optimize PostgreSQL schemas, queries, and operations for reliability and performance.

16|9|Updated Nov 6, 2013
One-click install
npx skills add https://github.com/erikstmartin/dotfiles --skill postgres-erikstmartin
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: postgres
Source: https://github.com/erikstmartin/dotfiles/tree/main/skills/catalog/sql/postgres
Command: npx skills add https://github.com/erikstmartin/dotfiles --skill postgres-erikstmartin

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

PostgreSQL is a powerful database system but can be complex to tune; this Skill provides pragmatic guidelines to design schemas, optimize queries, and operate PostgreSQL reliably.

Core Features & Use Cases

  • Schema design guidance: proper PKs, data types, and indexing strategies to support scalable queries.
  • Performance optimization: use EXPLAIN ANALYZE, indexing, partitioning, and VACUUM/vacuum tuning to reduce latency.
  • Migrations and operations: plan safe migrations, WAL/checkpoint awareness, backup considerations, and replication readiness.

Quick Start

Audit your current PostgreSQL setup against these guidelines and begin optimizing a representative workload.

Frequently Asked Questions about postgres

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

FAQPage Schema
How do I optimize slow PostgreSQL queries using EXPLAIN ANALYZE?

Optimize PostgreSQL queries by running EXPLAIN ANALYZE to inspect execution plans, then apply proper indexing strategies and partitioning to reduce latency. This approach identifies bottlenecks so you can adjust schema design and indexing rules for scalable performance.

What are the best practices for PostgreSQL schema design and indexing?

PostgreSQL schema design best practices include defining proper primary keys, selecting appropriate data types, and applying targeted indexing strategies. Following these rules ensures scalable queries and reliable performance across development and production environments.

How do I tune autovacuum and VACUUM settings in PostgreSQL?

Tune PostgreSQL autovacuum and VACUUM settings by adjusting parameters based on workload characteristics to maintain reliability. Proper autovacuum tuning prevents bloat and ensures consistent performance without manual intervention during routine operations.

How do I plan safe PostgreSQL migrations without downtime?

Plan safe PostgreSQL migrations by evaluating WAL and checkpoint awareness, backup considerations, and replication readiness before execution. This approach ensures migrations proceed without disrupting production reliability or losing data integrity.

When do I need partitioning for PostgreSQL performance optimization?

PostgreSQL partitioning is needed when managing large tables that cause query latency or VACUUM overhead. Partitioning distributes data across smaller segments, improving query optimization and reducing maintenance burden for high-volume workloads.

Why does PostgreSQL autovacuum fall behind and how do I fix it?

PostgreSQL autovacuum falls behind when tuning parameters are too conservative for high write volumes. Fix it by adjusting autovacuum settings to increase frequency, ensuring VACUUM operations keep pace with data changes and prevent bloat.