Recently I tried to resolve a recurring question in our team:
Is JSON or JSONB actually faster in PostgreSQL?
I couldn’t find a clear answer that matched real-world usage, so I ran my own benchmark.
Setup
I loaded 1 million records with identical data into both JSON and JSONB columns and tested common operations.
Hardware:
Dell PowerEdge R450
2x Intel Xeon Silver 4310 (24/48 cores @ 2.1GHz)
I intentionally used mid-range hardware so the differences would be easier to see.
What I tested
- INSERT performance
- Key-based search (
data->>'field' = 'value') - Nested updates
- Complex multi-condition queries
- Array access (
data->'items'[0]) - Key existence (
data ? 'key') - Path queries (
data #> '{user,profile,name}') - Aggregations
- Storage size
Results
Insert speed
JSON was faster:
- JSON: 8.6s
- JSONB: 11.3s
~31% difference, which makes sense - JSON is stored as plain text.
Query performance
This is where things got interesting.
JSONB was significantly faster across all read operations:
- Simple key extraction → 6.2x faster
- Nested field access → 7.6x faster
- Array operations → 7.3x faster
- Complex conditions → 9.1x faster
On average: ~7x faster
GIN indexes + binary format make a huge difference here.
Updates
For partial updates:
- JSONB was ~71% faster
Storage
- JSON: ~1200 MB
- JSONB: ~888 MB
JSONB used ~26% less space, mainly due to key deduplication.
Key takeaway
If your workload is read-heavy (which is most backend systems):
JSONB pays for itself very quickly.
Even with slower inserts, the performance gain in queries dominates after relatively few operations.
One important detail
Operators like:
@>??&
only work with JSONB.
Without them, efficient querying becomes very limited.
Repo
I published the full benchmark here:
https://github.com/ineron/postgresql-json-jsonb-benchmark
Includes:
- SQL scripts
- Python automation
- Docker setup
Final thought
I expected JSONB to be faster, but not by this margin.
Curious if anyone has seen similar results in production?
Top comments (0)