Postgres Best Practices

neondatabase/postgres-skills/skills/postgres-best-practices

作者 neondatabase27fe45e0f71e無授權條款48 個星標收錄於 2026年10月9日更新於 2026年10月9日儲存庫2 天前更新

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.

AI 產生的概覽

提供 PostgreSQL 結構描述設計、索引、查詢最佳化、複寫、備份與安全性的最佳實務指引。

功能
此技能提供適用於 PostgreSQL 14 至 18 版本的最佳實務指引。它會引導代理查閱參考文件,內容涵蓋結構描述設計、索引、查詢最佳化、查詢模式、效能診斷、邏輯複寫、熱待命、交易隔離、備份與還原、安全性與角色、大量載入、連線集區以及主要版本升級。它產出的是建議與推薦,而非檔案或程式碼成品。
適用情境
在撰寫 SQL、設計資料庫結構描述、最佳化查詢或設定 PostgreSQL 資料庫時使用。它也適用於複寫、備份、安全性角色與版本升級相關問題。
執行需求
不需要指令碼或工具,僅為指示加上參考文件。除讀取隨附的參考檔案外,代理無需憑證或網路存取。

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

來源與署名

來源:neondatabase/postgres-skills位於skills/postgres-best-practices提交27fe45e

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架