In The Hidden Cost of PostgreSQL JSONB Columns Under High Write Load, DEV author John (@johnnylemonny) compares two PostgreSQL schemas for a workload that repeatedly updates small fields in large event records. One schema keeps operational state inside a JSONB document. The other gives fields such as the retry counter their own columns while retaining JSONB for the rest of the payload. The comparison makes a useful distinction between the size of a logical edit and the work a database has to do to store it.
A small edit can replace a large value
John's delivery example uses a JSON function to change values within a document. PostgreSQL creates a new row version for the update. A changed JSONB document is a replacement value, and the storage work can extend to TOAST when the document is kept out of line. An update to an ordinary column can preserve the existing out-of-line value when the document stays unchanged. For a retry counter that changes far more often than the original event data, making that distinction in the schema can affect both writes and the volume of write-ahead log records.
What the schema comparison measures
The post reports observations from a local workload using generated event data. Its second table changes more than the placement of the retry counter. It also uses a lower fillfactor and includes a partial index on status. That makes the result a comparison of two layouts under one test setup. To isolate an effect, a follow-up could first hold the indexing and page-space settings steady while changing where the counter lives.
Heap-only tuple updates also depend on the columns referenced by indexes and the space available on the old row's page. Giving the retry counter its own column leaves the document alone. Whether that update qualifies for HOT still depends on the table's actual indexes and page space. PostgreSQL describes the conditions for HOT updates.
Which fields in an event record change after ingestion, and which indexes reference them? Those are the first details worth comparing when adapting John's test to a different workload.