What problem does it solve?
Deep reference for PostgreSQL schema design, query optimization, indexing, migration safety, and data modeling. Focused on patterns that prevent costly refactors.
Core Features & Use Cases
- Schema Design Principles: One Concern Per Table; Domain Names; Status Enums; Timestamps on Everything; Nullable Foreign Keys for Optional Relationships.
- Data Modeling Decisions: UUID vs Integer PKs; Join Table Design; Partial Unique Indexes; JSONB for Semi-Structured Data; When to Denormalize; Atomic Updates.
- Indexing Strategy: Index Your WHERE Clauses; Composite Indexes; PostgreSQL FK Indexing; Don't Index Everything; EXPLAIN ANALYZE.
- Query Optimization: Explicit Column Selection; Avoid ORDER BY random(); N+1 Query Detection; Aggregate Subqueries.
- Migration Safety: Never Use create_all(); Always Test Against Postgres; Review Autogenerated Migrations; Never Edit an Applied Migration; Lock-Aware Operations.
- Enum Patterns; Soft Delete; Audit Logging; Connection Management.
- Quick Reference: Summary of common fixes and guidelines.
Quick Start
Review a current schema change and apply these PostgreSQL patterns to ensure safer migrations and robust data models.