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

What is the reasoning behind using JSONB in PostgreSQL? #27

Closed
codeliner opened this issue Jan 2, 2017 · 6 comments
Closed

What is the reasoning behind using JSONB in PostgreSQL? #27

codeliner opened this issue Jan 2, 2017 · 6 comments

Comments

@codeliner
Copy link
Member

Question taken from the chat. Asked by @shochdoerfer

Do you guys query the JSON payload a lot? If not the JSON field would be more efficient as no conversion happens.

@codeliner
Copy link
Member Author

/cc @prolic

@shochdoerfer
Copy link
Contributor

Just to give a bit of context: The PostgreSQL guys recommend using JSON when using the field just for storage and JSONB when you want to issue queries against the data. The reasoning behind this is that the conversion from JSON to the binary format of JSONB and back costs time to compute.

In addition to that the JSON fields has 2 "advantages" over JSONB: The json format of the output does not change - e.g. the order of the object keys is maintained and since the JSON specification potentially allows multiple keys by the same name, the JSON field in PostgreSQL does the same.

To be fair I have no idea what "more efficient" really means but with millions of events that get read and parsed maybe the JSON field access might be a bit faster.

@prolic
Copy link
Member

prolic commented Jan 2, 2017 via email

@shochdoerfer
Copy link
Contributor

Sure can tackle that one as well ;)

Migrate to JSON completely or make it configurable? What would you prefer?

@prolic
Copy link
Member

prolic commented Jan 2, 2017 via email

@shochdoerfer
Copy link
Contributor

Sounds legit ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants