Postgres JSONB Best Practice

When to use JSONB.

Overview

Postgres JSONB is powerful and over-used. JSONB shines for genuinely schema-flexible data (per-tenant custom fields, third-party API payloads, evolving event shapes); it hurts when used for fields that have stable schema and frequent access, because every read pays the parsing cost and most queries cannot use simple indexes. The discipline is per-column rationale: JSONB only when the schema flexibility is real, structured columns for everything else.

The approach

The practical approach is per-column rationale required (JSONB only when schema flexibility is real), GIN indexes per JSONB column for queryable access patterns, structured columns for hot fields with stable schema, jsonb_path_ops for per-query path expressions, and documented per-table JSONB rationale committed to the schema documentation so the choice is reviewable.

Why this compounds

JSONB discipline compounds across the schema lifetime. Each correctly-used JSONB column preserves the schema flexibility the workload actually needs; each structured column kept out of JSONB preserves query performance and indexability; the team builds intuition for when JSONB pays off versus when it costs.

JSONB discipline is a database discipline that pays off across years. Nova AI Ops integrates with Postgres telemetry, surfaces JSONB patterns, and supports the team’s schema design discipline.