Skip to content
Back to skills

Postgres Best Practices

ASecurity

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.

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 6, 2026
ai-agentssqlnodedatabasesecurityperformance

Security analysis

A100/100

Pro scans all 20 files and shows the line behind each finding

Scanned November 6, 2026

npx -y skills add bepaldes/heimdall-agent --skill postgres-best-practices --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Postgres Best Practices?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Postgres Best Practices
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/bepaldes-postgres-best-practices/badge)](https://www.skillsdirectory.com/skills/bepaldes-postgres-best-practices)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
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.

| Version | Initial Release    | End of Life        |
| ------- | ------------------ | ------------------ |
| 18      | September 2025     | November 2030      |
| 17      | September 2024     | November 2029      |
| 16      | September 2023     | November 2028      |
| 15      | October 2022       | November 2027      |
| 14      | September 2021     | November 2026      |

Source: [postgresql.org/support/versioning](https://www.postgresql.org/support/versioning/)

## References

| Area                    | Resource                                | When to Use                                                        |
| ----------------------- | --------------------------------------- | ------------------------------------------------------------------ |
| Schema Design           | `references/schema-design.md`           | Designing tables, choosing data types, normalizing, partitioning   |
| Indexing                | `references/indexing.md`                | Choosing index types, composite indexes, partial/covering indexes  |
| Query Optimization      | `references/query-optimization.md`      | Reading EXPLAIN ANALYZE, fixing bottlenecks, planner tuning        |
| Query Patterns          | `references/query-patterns.md`          | CTEs, window functions, lateral joins, UPSERT, JSONB, anti-patterns|
| Performance Diagnostics | `references/performance-diagnostics.md` | pg_stat views, lock analysis, VACUUM, connection management        |
| Logical Replication     | `references/logical-replication.md`     | Pub/sub replication, live migrations, CDC                          |
| Hot Standby             | `references/hot-standby.md`             | Streaming replication, read replicas, failover                     |
| Transaction Isolation   | `references/transaction-isolation.md`   | Isolation levels, lost updates, serialization failures, retry logic |
| Backup & Restore        | `references/backup-restore.md`          | pg_dump/pg_restore, pg_basebackup, PITR, recovery                 |
| Security & Roles        | `references/security-roles.md`          | Privileges, RLS, pg_hba.conf, authentication, SSL                 |
| Bulk Data Loading       | `references/bulk-loading.md`            | COPY patterns, ETL staging, optimizing large loads, batch ops      |
| Connection Pooling      | `references/connection-pooling.md`      | PgBouncer config, pool modes, prepared statements, sizing          |
| Major Version Upgrades  | `references/major-version-upgrades.md`  | pg_upgrade, logical replication migration, pre/post checklists     |

Files in this skill

  • SKILL.md3.3 KB
  • references/_contributing.md4 KB
  • references/_sections.md1.6 KB
  • references/_template.md1 KB
  • references/advanced-full-text-search.md1.4 KB
  • references/advanced-jsonb-indexing.md1.4 KB
  • references/backup-restore.md11.8 KB
  • references/bulk-loading.md8.7 KB
  • references/conn-idle-timeout.md1.3 KB
  • references/conn-limits.md1.3 KB
  • references/conn-pooling.md1.3 KB
  • references/conn-prepared-statements.md1.5 KB
  • references/connection-pooling.md9.2 KB
  • references/data-batch-inserts.md1.3 KB
  • references/data-n-plus-one.md1.3 KB
  • references/data-pagination.md1.3 KB
  • references/data-upsert.md1.4 KB
  • references/hot-standby.md7.2 KB
  • references/indexing.md10 KB
  • references/lock-advisory.md1.5 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.