TaPO4eg3D
TaPO4eg3D

Reputation: 73

Why PostgreSQL keeps json field when jsonb is much more efficient?

The first reason that pops up in the mind is backward capability. But maybe much more significant reasons exist?

Upvotes: 0

Views: 78

Answers (1)

Laurenz Albe
Laurenz Albe

Reputation: 246493

json has its uses:

  • it has less processing overhead when you store and retrieve the whole column, because it is stored as plain text and doesn't have to be parsed and converted to the internal binary representation.

  • it conserves the formatting and attribute order.

  • it does not remove duplicate attributes.

In short, json is better if you don't want to process the column inside the database, that is, when the column is just used to store application data.

If you want to process the JSON inside the database, jsonb is better.

Upvotes: 3

Related Questions