Draft:JSONB
Submission declined on 1 March 2025 by Mwwv (talk). This submission reads more like an essay than an encyclopedia article. Submissions should summarise information in secondary, reliable sources and not contain opinions or original research. Please write about the topic from a neutral point of view in an encyclopedic manner.
Where to get help
How to improve a draft
You can also browse Wikipedia:Featured articles and Wikipedia:Good articles to find examples of Wikipedia's best writing on topics similar to your proposed article. Improving your odds of a speedy review To improve your odds of a faster review, tag your draft with relevant WikiProject tags using the button below. This will let reviewers know a new draft has been submitted in their area of interest. For instance, if you wrote about a female astronomer, you would want to add the Biography, Astronomy, and Women scientists tags. Editor resources
| ![]() |
Comment: Almost entirely cited with primary sources. mwwv converse∫edits 20:26, 1 March 2025 (UTC)
JSONB is a data type for storing JSON data in a more efficient binary form, which appeared in the PostgreSQL DBMS starting with version 9.4.[1]
This type of data and work with it resembles the usual JSON data type, however, its data is not stored in text, but stored in binary form for quick search on the content of such data.
JSONB application
[edit]The problem of record search performance is very relevant for relational databases used in E-commerce. E-commerce goods and their attributes are often added/changed, new types of goods are added with a new data structure, which forces the use of a special data model.
The standard data model suitable for this subject area is called EAV (Entity-Attribute-Value), the essence of which is that instead of storing the attribute value in a column, the value is stored in a row. However, the low speed of searching records in the EAV model does not allow using it in its pure form. If attribute-value pairs from the EAV model are written in the JSONB field, this will allow a quick search and this will solve the problem [2]. That is why the relational DBMS PostgreSQL required such a data type as JSONB, which allows indexing of JSON data and effective searching in these data.
JSONB indexing
[edit]Two index options exist for JSONB [3], for example:
CREATE INDEX idxgin ON entity USING GIN (attribute_value);
CREATE INDEX idxginp ON entity USING GIN (attribute_value jsonb_path_ops);
where "entity" is a table of entities, and "attribute_value" is a JSONB field that contains attribute-value pairs.
The second index is much more effective for queries with the condition "attribute1" = "value1". An example of the query (the idxginp index is used):
SELECT * FROM entity WHERE attribute_value @> '{"attribute1": "value1"}';
The disadvantage of such indexing is that only @>, @? and @@ operators is supported.[4]
Search performance
[edit]Data search performance in JSONB of PostgreSQL can be compared with data search performance in NoSQL databases. For example, searching for one record from 10 millions with a JSONB field can take faster than 1 ms.
JSONB advantages and disadvantages
[edit]Using JSONB provides the following advantages:
- The PostgreSQL relational database ensures the reliability of data storage using the ACID principles (atomicity, consistency, isolation, and durability) [5] and at the same time it will allow to work effectively with unstructured data stored in JSONB.
- If unstructured JSON data is required on an existing project, which usually already has a relational database such as PostgreSQL, then additional infrastructure for a NoSQL database is not needed, but JSONB must be used.
- Data synchronization between the main relational PostgreSQL database and NoSQL database for efficient work with unstructured data is not necessary if JSONB is used. Thus, the time and costs for project development and support are reduced.
The disadvantage of JSONB is:
- Only the @> operator ensures effective search in JSONB data.
References
[edit]- ^ https://www.postgresql.org/docs/9.4/release-9-4.html
- ^ https://coussej.github.io/2016/01/14/Replacing-EAV-with-JSONB-in-PostgreSQL/
- ^ https://www.postgresql.org/docs/current/datatype-json.html#JSON-INDEXING
- ^ https://www.postgresql.org/docs/current/functions-json.html#FUNCTIONS-JSONB-OP-TABLE
- ^ https://www.techtarget.com/searchdatamanagement/definition/ACID
- in-depth (not just passing mentions about the subject)
- reliable
- secondary
- independent of the subject
Make sure you add references that meet these criteria before resubmitting. Learn about mistakes to avoid when addressing this issue. If no additional references exist, the subject is not suitable for Wikipedia.