Open Ludee opened 3 years ago
We chose JSON because it seems to be the best option for our use case and offers great support. I already updated the data package files.
That doesn't really solve my question between json
and jsonb
.
see: http://www.silota.com/docs/recipes/sql-postgres-json-data-types.html
- Difference between JSON and JSONB
The JSON data type is basically a blob that stores JSON data in raw format, preserving even insignificant things such as whitespace, the order of keys in objects, or even duplicate keys in objects. It offers limited querying capabilities, and it's slow because it needs to load and parse the entire JSON blob each time.
JSONB on the other hand stores JSON data in a custom format that is optimized for querying and will not reparse the JSON blob each time.
If you know before hand that you will not be performing JSON querying operations, then use the JSON data type. For all other cases, use JSONB.
The following example demonstrates the difference:
select '{"user_id":1, "paying":true}'::json, '{"user_id":1, "paying":true}'::jsonb;
json | jsonb
--------------------------------+-------------------------------- {"user_id":1, "paying":true} | {"paying": true, "user_id": 1} (1 row)
(the whitespace and the order of the keys are preserved in the JSOB column.)
I see one typo: (the whitespace and the order of the keys are preserved in the JSOB column.) Should read (the whitespace and the order of the keys are preserved in the JSON column.). JSONB does not retain whitespace and order of keys as it stored parsed json.
Thanks for the info @Ludee! I think for our use cases, querying the JSONs is not crucial (perhaps this never occurs). Therefore, I tend to JSON. Additionally, I don't know if OEDialect supports JSONB. If not, maybe this should be added as it could be useful for metadata querying!
hstore vs. json vs. jsonb
I'm currently looking for an improvement for variable data structures (key-value-pairs).
Research:
Criterial:
Examples:
OSM uses hstore.
I use this issue as documentation. Feel free to comment and improve!