Which data type to choose json or jsonb or text

I would like to store a large json hash code (or content, call it what you want), and “big” I mean something more than 1000 key pairs of values, I do not want to do any searches in this json field, I just want to get it from the database and pass it to javascript in order to parse it and build a visual result.

There is a type jsonand in Postgresql jsonb(and maybe I can use a field textas well for storing json). I just want to make the right choice for this purpose, so I would like advice from experienced people.

+4
source share
1 answer

Assuming you're talking about real, strict JSON (no fad, such as unmentioned keys) ...

jsonnot too different from text. It is not much different from JSON validation .

jsonb- This is a different beast compared to these two: it is a full-fledged data structure with its own internal format, which has much more operations available when searching. For example, jsonnot applicable =(equality operator). jsonbIt has. ( textalso, although it is semantically different.)

It is much more sensible to index, but it needs to be converted back and forth while reading and writing.

Given that jsonbdoes not look like a choice of sound here.


... Therefore, only one solution remains:

, JSON ? ? ( , ) ?

json . text - , . , JSON, . !

+9

Source: https://habr.com/ru/post/1651802/


All Articles