jsonb_slice
jsonb_slice · Experimental partial reads of external uncompressed JSONB values
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 102450 | jsonb_slice | jsonb_slice | 0.6.0 | FEAT | PostgreSQL | C |
PostgreSQL · 16, 18, 19
Usage
Sources:
- README.md
- jsonb_slice.control
- jsonb_slice–0.6.0.sql
- jsonb_slice–0.5.0–0.6.0.sql
- getting-started.md
- 0.6.0.md
- verify.yml
jsonb_slice 0.6.0 is a research extension for reading one field or path from a large JSONB value without fetching the entire value when storage permits it. Upstream explicitly advises against production use. CI covers PostgreSQL 16; the optimized TOAST reader is documented for 18 and 19.
Explicit Accessors
A superuser creates the relocatable C extension. Explicit functions and operators need no preload:
jsonb_slice_get and jsonb_slice_get_text accept a key or integer index; negative indices count from the end. jsonb_slice_path and jsonb_slice_path_text traverse a text-array path. Operators ~> and ~#> return JSONB; ~>> and ~#>> return SQL text. Missing locations return SQL NULL. JSONB results preserve JSON null, whereas text results convert it to SQL NULL.
Optional Transparent Mode
Load the hook before planning a query and enable it per session:
The default is off. For persistent loading, add the library to session_preload_libraries while preserving other entries and reconnect. Creating the extension alone does not activate the hook in every session. Eligible common plan expressions using built-in JSONB accessors can then call the extension; expressions outside the supported traversal retain the built-in implementation.
Storage and Upgrade Boundaries
Partial reads require an external, uncompressed value. Inline or compressed values use PostgreSQL’s complete-value functions. Transparent mode additionally requires an eligible relation with a JSONB column declared STORAGE EXTERNAL; changing that setting alone does not rewrite old values. On PostgreSQL 18/19 with heap TOAST storage, 0.6.0 reuses one TOAST scan per lookup. jsonb_slice.fetch_path = 'portable' selects the older slice reader. No general speedup is guaranteed.
After installing matching files, use the supplied 0.5.0-to-0.6.0 upgrade or earlier sequential chain, and reconnect sessions to load the new library: