3 ms·
If my application never sees a difference to normal JSON, everything is compatible and all there is are perf improvements, why is there a new set of functions t
by nikeee 3y ago
If my application never sees a difference to normal JSON, everything is compatible and all there is are perf improvements, why is there a new set of functions to interact with it (jsonb_*)?
It seems that the JSON type is even able to contain JSONB. So why even use these functions, if the normal ones don't care?
- dtech 3y agoThe difference is the storage format, which is important for a SQL database since you define it in the schema. Also the performance characteristics are different.
- The_Colonel 3y agoAs someone mentioned below, the order of keys is undefined in JSON spec, but applications may rely on it anyway, and thus conversion to JSONB may lead to breakage. There are some other minor advantages of having exact representation of the original - e.g. hashing, signatures, equality comparison is much simpler on the JSON string (you need a strict key order, which is again undefined by the spec, but happens in the real world anyway).
- 0x457 3y ago`json_` functions return json, `jsonb_` functions return jsonb. Both take either as input. If you're modifying something "in-place" then `jsonb_` functions would be better since they avoid conversion.