PostgreSQL has supported jsonb for many years, and it has become a practical choice for applications that need flexible document-style data without giving up relational database capabilities. It is common to see JSONB columns used for product attributes, application metadata, event payloads, configuration, audit information, and other semi-structured data.
With PostgreSQL 19, the interesting performance story is not a single change that suddenly makes every JSONB query faster. Instead, PostgreSQL 19 introduces several database-level improvements that can affect JSONB-heavy workloads indirectly, including changes around TOAST compression, GIN index maintenance, sorting, optimizer behavior, and JSON path functionality. PostgreSQL 19 is still in the beta stage as of August 2026, so benchmark results should be treated as version-testing results rather than production guarantees. The PostgreSQL project released Beta 2 on July 16, 2026 and specifically encourages testing application workloads against the beta while advising against production use of beta releases.
That makes PostgreSQL 19 a good candidate for a controlled JSONB benchmark.
The goal is not simply to compare two version numbers. The goal is to determine which JSONB workloads actually benefit, which remain unchanged, and whether a migration introduces different storage or query-planning behavior for your application.
Why JSONB Performance Is Different
A JSONB query can involve several layers of work.
For example:
SELECT id
FROM products
WHERE attributes @> '{"brand": "Contoso"}';
The database may need to parse the query, identify an appropriate index, search the index, inspect heap or table pages, decompress stored JSONB data when necessary, and return the matching rows.
A simplified execution path looks like this:
SQL query
|
v
Query planner
|
v
GIN / other index
|
v
Table or heap access
|
v
JSONB evaluation
|
v
Result
Performance therefore depends on much more than the JSONB operator itself.
The dataset, document size, index type, selectivity, compression, cache state, query shape, and PostgreSQL version can all influence the result.
What PostgreSQL 19 Changes for JSONB Workloads
The PostgreSQL 19 release notes do not describe the release as a wholesale rewrite of the JSONB storage or query engine. Instead, several general database improvements can influence JSONB-heavy applications.
One notable change is that PostgreSQL 19 changes the default TOAST compression method from pglz to lz4. TOAST is used to store large values, including large JSONB documents, outside the main table row when appropriate. This means applications with large JSONB values should specifically benchmark storage size, read performance, write performance, and compression behavior after migration.
PostgreSQL 19 also improves GIN index vacuuming using streaming reads. This is relevant because GIN is one of the primary indexing mechanisms used with JSONB. The release also includes broader performance improvements such as asynchronous I/O read-ahead scheduling, radix-sort improvements, and other internal performance work that can influence workloads containing substantial JSONB processing.
The important distinction is that these changes do not mean every JSONB query will automatically become faster. Their impact depends heavily on the workload.
JSONB Indexing Still Matters
PostgreSQL provides two primary GIN operator classes for JSONB: jsonb_ops and jsonb_path_ops.
The default jsonb_ops operator class supports a broader set of operators, while jsonb_path_ops supports fewer operations but can provide better performance for the operations it supports. PostgreSQL's documentation explicitly describes jsonb_path_ops as offering better performance for its supported operators.
For example:
CREATE INDEX ix_products_attributes
ON products
USING GIN (attributes);
This creates a default GIN index.
A path-oriented index can instead be created with:
CREATE INDEX ix_products_attributes_path
ON products
USING GIN (attributes jsonb_path_ops);
Do not assume the second index is always better.
The correct choice depends on the operators used by the application.
For example, a containment-heavy workload may behave differently from one that frequently uses key-existence operators such as ?.
Benchmark JSONB Containment Queries
Containment is one of the most common JSONB access patterns.
Consider:
SELECT id, name
FROM products
WHERE attributes @> '{"brand": "Contoso"}';
Benchmark this query against PostgreSQL 18 and PostgreSQL 19 using exactly the same dataset and index definitions.
The benchmark should capture:
Execution time.
Planning time.
Rows returned.
Shared buffer hits.
Shared buffer reads.
Index usage.
CPU utilization.
Storage size.
Query plan.
Use:
EXPLAIN (ANALYZE, BUFFERS)
SELECT id, name
FROM products
WHERE attributes @> '{"brand": "Contoso"}';
The important part is not simply the final execution time. BUFFERS helps determine whether a difference comes with different memory or disk access behavior.
Benchmark JSON Path Queries Separately
JSON path queries should be treated as a separate workload.
For example:
SELECT id
FROM products
WHERE attributes @?
'$.specifications.weight ? (@ > 10)';
PostgreSQL 19 adds additional string methods to jsonpath, including functions such as lower(), upper(), replace(), split_part(), ltrim(), rtrim(), and btrim(). These methods are useful from a functionality perspective, but their performance should be measured for the actual expressions used by an application rather than assuming that a new function is faster simply because it is new.
This distinction is important when writing a migration benchmark.
A new capability is not automatically a performance optimization.
Large JSONB Documents Are Especially Important
JSONB performance can change significantly as document size increases.
A useful benchmark matrix might contain documents around:
| Document Size | Example Workload |
|---|---|
| 1 KB | Small metadata |
| 10 KB | Product/application attributes |
| 100 KB | Detailed event payload |
| 1 MB | Large configuration or document |
| 5 MB+ | Large archival payload |
The exact sizes should match your application.
Large JSONB values are especially interesting because TOAST behavior becomes more relevant. Since PostgreSQL 19 changes the default TOAST compression method to LZ4, applications with large JSONB values should compare both storage characteristics and query behavior rather than looking only at CPU time.
Benchmark GIN Index Maintenance
JSONB read performance is only half of the story.
A GIN index can accelerate searches, but maintaining the index has a cost when JSONB documents are inserted or updated.
For a write-heavy workload, benchmark:
INSERT INTO products (...)
VALUES (...);
and:
UPDATE products
SET attributes = jsonb_set(
attributes,
'{inventory}',
'100'::jsonb
)
WHERE id = 100000;
Measure:
Insert latency.
Update latency.
Transaction throughput.
WAL generation.
Index size.
Table size.
Vacuum behavior.
CPU and I/O utilization.
PostgreSQL 19 includes a GIN vacuuming performance improvement using streaming reads, so write-heavy JSONB workloads are particularly worth testing rather than relying on read-only query benchmarks.
Compare Query Plans, Not Just Timings
Suppose PostgreSQL 18 reports:
Bitmap Index Scan
-> Bitmap Heap Scan
while PostgreSQL 19 chooses:
Index Scan
That difference is more important than simply seeing a lower execution-time number.
Record the complete plans.
For each benchmark, compare:
Planning Time
Execution Time
Rows
Index chosen
Heap blocks
Shared hits
Shared reads
Sort operations
Parallel workers
This can explain why performance changed.
Use Production-Style Data Distribution
A JSONB benchmark should not contain identical documents.
Imagine a products table where every row contains:
{
"brand": "Contoso",
"category": "Laptop"
}
That does not represent a realistic production dataset.
Instead, create distributions such as:
Brand A 35%
Brand B 20%
Brand C 10%
Other brands 35%
Likewise, include documents with missing keys, nested objects, arrays, null values, and different document sizes.
Selectivity has a major effect on index behavior.
A query returning 5 rows from 10 million records is very different from one returning 4 million rows.
Test Cached and Uncached Workloads
Database cache state can significantly affect results.

Join the conversation! Your thoughts help the community grow.