PostgreSQL JSONB Columns Can Cause Heavy Write Amplification Under Frequent Updates
A developer's local benchmark found that incrementing one integer inside a 3.4 KB JSONB column generated about 142 MB of Write-Ahead Log traffic over 20,000 updates, roughly eight times more than updating dedicated scalar columns for the same change. The article attributes this to PostgreSQL's storage mechanics: JSONB values are stored as a single binary object, so any change rewrites the entire value and locks the whole row. Once a JSONB column exceeds the TOAST threshold, even a one-byte change allocates new TOAST chunks, which are written again and logged to WAL, leaving dead tuples behind. Indexing the column with GIN also rules out Heap-Only Tuple updates, forcing new index entries and occasional latency spikes. The author concludes that JSONB suits read-heavy workloads but can strain disk I/O, replication, and VACUUM when frequently mutated.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.



Discussion (0)
Log in to join the discussion and vote.
Log in