Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decide on data type for tags: hstore, json, jsonb #13

Open
Ludee opened this issue Sep 10, 2020 · 4 comments · Fixed by #15
Open

Decide on data type for tags: hstore, json, jsonb #13

Ludee opened this issue Sep 10, 2020 · 4 comments · Fixed by #15
Assignees
Labels
help wanted Extra attention is needed question Further information is requested

Comments

@Ludee Ludee added help wanted Extra attention is needed question Further information is requested labels Sep 10, 2020
@jh-RLI jh-RLI linked a pull request Sep 18, 2020 that will close this issue
2 tasks
@jh-RLI
Copy link
Collaborator

jh-RLI commented Sep 24, 2020

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.

@Ludee
Copy link
Member Author

Ludee commented Sep 24, 2020

That doesn't really solve my question between json and jsonb.

see: http://www.silota.com/docs/recipes/sql-postgres-json-data-types.html

  1. 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.)

@jh-RLI jh-RLI linked a pull request Sep 28, 2020 that will close this issue
@jh-RLI jh-RLI removed a link to a pull request Sep 28, 2020
@AsaiWiz
Copy link

AsaiWiz commented Mar 3, 2021

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.

@jh-RLI jh-RLI reopened this Mar 3, 2021
@henhuy
Copy link

henhuy commented Jun 3, 2022

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants