Exercise 1: json vs. jsonb, and the Default Recommendation — Possible Solution ==================================================================== WHAT json STORES ------------------------------ Per this chapter, "json stores an exact textual copy of the input — preserving whitespace, key order, and even duplicate keys — and is re-parsed on every query." The json type keeps the original document exactly as it was written, byte for byte, but pays a real cost: every time it's queried, Postgres has to re-parse that raw text from scratch. WHAT jsonb STORES ------------------------------ Per this chapter, "jsonb stores a decomposed binary representation instead: no whitespace or key-order preservation, but considerably faster to query, and — critically — indexable." jsonb converts the document into an internal binary structure at write time, discarding formatting details that don't affect the actual data (whitespace, key order, duplicates), in exchange for much faster querying and the ability to be indexed at all. THE PRACTICAL GUIDANCE ------------------------------ Per this chapter, "use jsonb for nearly everything. json is really only worth reaching for when byte-for-byte preservation of the original document matters, such as an audit log that needs to store exactly what was received." WHY jsonb IS THE DEFAULT ------------------------------ For the overwhelming majority of real use cases, what matters is the DATA inside the document, not its exact original formatting — a product's attributes, a user's preferences, an API response being cached. In those cases, jsonb's speed and indexability (via GIN indexes, covered later in the chapter) make it strictly more useful. json is reserved for the narrower, specific case where the original byte-for-byte representation itself is the thing that matters — an audit trail that needs to prove exactly what bytes were received, where even reformatting the document would undermine its purpose as an exact record. WHY THIS WORKS AS AN ANSWER ------------------------------ It states both types' storage behavior using the chapter's own wording, and gives the chapter's own specific default recommendation along with its one named exception, rather than treating the two types as interchangeable.