JSONBはPostgreSQLのバイナリJSON型です。効率的でクエリ可能かつインデックス可能な形式でJSONデータを保存します。リレーショナルデータベース内に柔軟で半構造化データを保存でき、リレーショナル完全性とNoSQL的な柔軟性を組み合わせることができます。これはPostgresの最も強力な機能の一つです。
JSONB vs JSON
JSON → stores the exact text (preserves whitespace/key order/duplicates), parsed each query
JSONB → stores a DECOMPOSED BINARY format → slightly slower to write, but MUCH faster
to query, and supports INDEXING and rich operators
→ Use JSONB in almost all cases (JSON only if you need exact text preservation).
