https://github.com/postgrespro/jsonb_schema
Store jsonb schema separately from data
https://github.com/postgrespro/jsonb_schema
Last synced: 16 days ago
JSON representation
Store jsonb schema separately from data
- Host: GitHub
- URL: https://github.com/postgrespro/jsonb_schema
- Owner: postgrespro
- License: other
- Created: 2020-08-23T10:55:14.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-08-24T09:54:47.000Z (over 4 years ago)
- Last Synced: 2025-04-15T00:45:53.308Z (16 days ago)
- Language: C
- Size: 14.6 KB
- Stars: 5
- Watchers: 8
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
This extension allows to reduce size of jsonb objects by storing it's schema separately from data.
It is assumed that there are not so much different schema used by applications.
So storing schema separately in `jsonb_schemes` table and keeping only it's ID in JSONB object
allows to significantly reduce space used by JSONB objects.There are just two functions provided by this extension:
`jsonb_pack` and `jsonb_unpack`. Both take JSONB objects and return JSONB object.`jsonb_pack` separates schema from data and stores schema in `jsonb_schemes` table (if not present yet).
Then it constructs JSONB array [schema_id,obj_data]`jsonb_pack` takes JSONB array [schema_id,obj_data], retrieve schema from `jsonb_schemes` table
and merge it with object data, restoring original JSONB object.