# PostgreSQL performance study compares json and jsonb storage size and speed

> **Key takeaway:** While jsonb incurs per-key storage overhead, its ability to be compressed via TOAST and its superior read speeds make it more efficient for most production workloads.

**Published:** 2026-11-08T22:30:11+00:00 
**Source:** Planet PostgreSQL 
**Category:** databases-storage 
**Canonical URL:** https://fosswire.org/news/postgresql-performance-study-compares-json-and-jsonb-storage.html 

## Summary
A technical investigation into PostgreSQL 17.11 and 18.6 has quantified the trade-offs between the json and jsonb data types. The study measured storage footprints and read performance across six distinct document shapes, including small compact files, large nested structures, and flat arrays.

The results demonstrate that while jsonb can be significantly larger than compact json before compression due to per-key metadata overhead, it often results in smaller on-disk footprints once PostgreSQL's TOAST compression is applied. Furthermore, jsonb consistently outperformed json in read speeds, providing improvements ranging from 2.7 to 10.6 times faster when accessing specific keys.

## Storage overhead and compression dynamics
- **Metadata Overhead:** The jsonb format incurs a per-key storage penalty because it stores a parsed document with headers for every key and value, which can increase uncompressed size by up to 36.1% for medium documents.
- **TOAST Compression Impact:** jsonb can trigger PostgreSQL TOAST compression more frequently than json because its parsed structure often exceeds the 2 kB threshold, potentially resulting in smaller on-disk sizes (e.g., 16.6% smaller for medium documents using pglz).
- **Read Performance:** Using the `->>` operator, jsonb was found to be 2.7 to 10.6 times faster than the json type across all tested document shapes in both PostgreSQL 17 and 18.
- **Data Type Sensitivity:** The storage efficiency of jsonb is highly dependent on document content; for example, large arrays of integers saw jsonb grow by 43.1% compared to compact json due to how numbers are stored as numeric types.
- **Whitespace Handling:** Unlike the json type, which preserves all original whitespace and indentation, jsonb strips whitespace, which can offset some of the metadata overhead when dealing with pretty-printed input.

## Why it matters
Software engineers and database administrators can use these findings to optimize PostgreSQL storage costs and query latency. The data suggests that jsonb is generally superior for indexed lookups and complex queries, though developers handling massive arrays of integers may need to account for higher storage overhead.