-
Notifications
You must be signed in to change notification settings - Fork 0
/
jsonVsjsonb.txt
17 lines (11 loc) · 921 Bytes
/
jsonVsjsonb.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
The data types json and jsonb, as defined by the PostgreSQL documentation,are almost identical;
the key difference is that json data is stored as an exact copy of the JSON input text, whereas jsonb stores data in a decomposed binary form; that is, not as an ASCII/UTF-8 string, but as binary code.
And this has some immediate benefits:
more efficiency,
significantly faster to process,
supports indexing (which can be a significant advantage, as we'll see later),
simpler schema designs (replacing entity-attribute-value (EAV) tables with jsonb columns, which can be queried, indexed and joined, allowing for performance improvements up until 1000X!)
And some drawbacks:
slightly slower input (due to added conversion overhead),
it may take more disk space than plain json due to a larger table footprint, though not always,
certain queries (especially aggregate ones) may be slower due to the lack of statistics.