PostgreSQL: When to Use JSONB vs Relational Columns
The definitive guide to choosing between JSONB flexibility and relational structure in PostgreSQL.
The Short Answer
Use relational columns for data you query by. Use JSONB for data you query with but do not filter on.
Relational Wins
Indexes, foreign keys, type safety, and query performance. If you are filtering, sorting, or joining on a column, make it relational.
JSONB Wins
Schema flexibility, nested data, and payload storage. Configuration objects, API responses, form submissions, and block-based content (like this site uses) are perfect for JSONB.
The Hybrid Pattern
The best PostgreSQL schemas use both. Relational columns for the skeleton (id, slug, status, created_at), JSONB for the flesh (blocks, settings, metadata). This is exactly how caw_content works.
// Related Posts
PostgreSQL: The Only Database You Actually Need
You do not need MongoDB for documents or Pinecone for AI. Postgres JSONB and pgvector handle it all without sacrificing relational integrity.
Mar 6, 2026Anti-Pattern: Writing Code Before the Schema is Locked
When database changes break the API weekly, your project is bleeding out. Lock the database schema first, define the API contracts second.
Mar 16, 2026Zero-Downtime Migrations: Keeping the Engine Running
If updating your schema forces you to put up a "maintenance mode" banner, your deployment strategy is obsolete. Here is how to orchestrate seamless updates.