JSON vs. jsonb in Postgres: size and speed, measured now-next.nl · 12 points · 0...
HN Best 200 @best
JSON vs. jsonb in Postgres: size and speed, measured now-next.nl · 12 points · 0 comments · HN thread
TL;DR Now-Next measured json versus jsonb in PostgreSQL 17.11 and 18.6 across six document shapes, in compact and pretty-printed forms. Size on disk ranged from 22.6% smaller to 40.9% larger for jsonb, depending on the documents, whitespace and compression, while reads with ->> were 2.7 to 10.6 times faster from jsonb in every case timed. The article also reports that a 26% size advantage for jsonb in a 2026 BestHub benchmark could not be reproduced. The thread has no comments yet.
- Compact small documents (about 200 bytes) took 17.8% more space as jsonb; the same documents pretty-printed took 3.6% less, so whitespace in the input changes the outcome.
- Compression decides on-disk size: a medium compact document was 36% larger as jsonb before compression but 16.6% smaller on disk, because only the jsonb form crossed PostgreSQL's roughly 2 kB TOAST threshold.
- Reading one key with ->> was 2.7 to 10.6 times faster from jsonb; for compressed documents the compression method (lz4 versus pglz) mattered as much as the type.
- Loading was slower for jsonb (2.4 times for small documents) and GIN indexes are only possible on jsonb; jsonb_path_ops was smaller and faster to build than jsonb_ops.
- jsonb changes data: duplicate keys keep the last value, numbers are normalised, output is reformatted, and json has no equality operator for GROUP BY or DISTINCT.
- Results come from one machine; differences under 10% are treated as ties, and the authors recommend measuring your own documents above about 2 kB.
Discussion No comments have been posted on this submission yet, so there is no discussion to summarise. The story has 12 points.
#PostgreSQL #jsonb #databaseBenchmarks #performance #storage