PluginBench
Skill
Official
Pass
Audit score 90

postgres-best-practices

neondatabase/postgres-skills

Best practices and guidelines for PostgreSQL schema design, indexing, query optimization, and common pitfalls.

What is postgres-best-practices?

A comprehensive reference for working with PostgreSQL 14–18, covering schema design, indexing strategies, query optimization, migrations, and performance diagnostics. Use when writing SQL, designing database schemas, optimizing queries, or setting up a Postgres database.

  • Schema design patterns, data types, normalization, and partitioning strategies
  • Indexing guidance including index types, composite indexes, and covering indexes
  • Query optimization via EXPLAIN ANALYZE, planner tuning, and bottleneck identification
  • Query patterns including CTEs, window functions, lateral joins, UPSERT, and JSONB
  • Performance diagnostics using pg_stat views, lock analysis, and VACUUM management
  • Logical replication, hot standby, streaming replication, and read replica setup

How to install postgres-best-practices

npx skills add https://github.com/neondatabase/postgres-skills --skill postgres-best-practices
Claude Code
Cursor
Windsurf
Cline

How to use postgres-best-practices

  1. 1.Install the skill using the provided npm command
  2. 2.Consult the appropriate reference guide based on your task (schema design, indexing, query optimization, etc.)
  3. 3.Apply the recommended patterns and best practices to your code or database configuration
  4. 4.Use EXPLAIN ANALYZE and pg_stat views to validate performance improvements
  5. 5.Review version-specific features (tagged [PG15+], [PG18+]) for your PostgreSQL version

Use cases

Good for
  • Designing normalized database schemas with appropriate data types and constraints
  • Creating and tuning indexes to improve query performance on large tables
  • Analyzing slow queries with EXPLAIN ANALYZE and implementing optimization fixes
  • Setting up logical replication for live migrations or change-data-capture pipelines
  • Configuring streaming replication and read replicas for high availability
Who it's for
  • Database architects designing new Postgres systems
  • Backend engineers writing SQL and optimizing queries
  • DevOps and database administrators managing Postgres infrastructure
  • Data engineers building ETL pipelines and bulk-loading workflows
  • Teams implementing high-availability and disaster-recovery setups

postgres-best-practices FAQ

Which PostgreSQL versions does this skill cover?

PostgreSQL 14 through 18. Version-specific features are tagged (e.g., [PG15+], [PG18+]). Always run the latest minor release within your major version.

How do I choose the right index type for my query?

Consult the indexing reference guide, which covers B-tree, hash, GiST, GIN, and BRIN indexes with guidance on when each is appropriate based on query patterns and data characteristics.

What should I do if my query is slow?

Use EXPLAIN ANALYZE to identify bottlenecks, then refer to the query optimization reference for planner tuning, index strategies, and common anti-patterns to avoid.

How do I set up replication for high availability?

The hot standby reference covers streaming replication and read replica setup; the logical replication reference covers pub/sub replication for live migrations and CDC.

What's the best way to upgrade to a new PostgreSQL major version?

Consult the major version upgrades reference for pg_upgrade procedures, logical replication migration strategies, and pre/post-upgrade checklists.

Full instructions (SKILL.md)

Source of truth, from neondatabase/postgres-skills.


name: postgres-best-practices description: Best practices and guidelines for working with Postgres. Covers schema design, indexing strategies, query optimization, migrations, and common pitfalls. Use when writing SQL, designing database schemas, optimizing queries, or setting up a Postgres database.

Postgres Best Practices

Guidelines and best practices for working with Postgres, covering schema design, indexing, query optimization, and common pitfalls.

Supported Versions

This skill covers PostgreSQL 14 through 18. Version-specific features are tagged (e.g., [PG15+], [PG18+]); environment-dependent examples identify required privileges, extensions, or multi-node setup.

PostgreSQL provides 5 years of support per major version. Always run the latest minor release.

VersionInitial ReleaseEnd of Life
18September 2025November 2030
17September 2024November 2029
16September 2023November 2028
15October 2022November 2027
14September 2021November 2026

Source: postgresql.org/support/versioning

References

AreaResourceWhen to Use
Schema Designreferences/schema-design.mdDesigning tables, choosing data types, normalizing, partitioning
Indexingreferences/indexing.mdChoosing index types, composite indexes, partial/covering indexes
Query Optimizationreferences/query-optimization.mdReading EXPLAIN ANALYZE, fixing bottlenecks, planner tuning
Query Patternsreferences/query-patterns.mdCTEs, window functions, lateral joins, UPSERT, JSONB, anti-patterns
Performance Diagnosticsreferences/performance-diagnostics.mdpg_stat views, lock analysis, VACUUM, connection management
Logical Replicationreferences/logical-replication.mdPub/sub replication, live migrations, CDC
Hot Standbyreferences/hot-standby.mdStreaming replication, read replicas, failover
Transaction Isolationreferences/transaction-isolation.mdIsolation levels, lost updates, serialization failures, retry logic
Backup & Restorereferences/backup-restore.mdpg_dump/pg_restore, pg_basebackup, PITR, recovery
Security & Rolesreferences/security-roles.mdPrivileges, RLS, pg_hba.conf, authentication, SSL
Bulk Data Loadingreferences/bulk-loading.mdCOPY patterns, ETL staging, optimizing large loads, batch ops
Connection Poolingreferences/connection-pooling.mdPgBouncer config, pool modes, prepared statements, sizing
Major Version Upgradesreferences/major-version-upgrades.mdpg_upgrade, logical replication migration, pre/post checklists