PostgreSQL JSON types: jsonpath, json, jsonb

Introduction

JSON data types are for storing JSON (JavaScript Object Notation) data, as specified in RFC 7159 .

Such data can also be stored as text, but the JSON data types have the advantage of enforcing that each stored value is valid according to the JSON rules.

There are also assorted JSON-specific functions and operators available for data stored in these data types; see Section 9.15.

PostgreSQL offers two types for storing JSON data: json and jsonb .

To implement efficient query mechanisms for these data types, PostgreSQL also provides the jsonpath data type described in Section 8.14.6.

The json and jsonb data types accept almost identical sets of values as input.

The major practical difference is one of efficiency .

The json data type stores an exact copy of the input text, which processing functions must reparse on each execution; while jsonb data is stored in a decomposed binary format that makes it slightly slower to input due to added conversion overhead, but significantly faster to process, since no reparsing is needed.

jsonb also supports indexing, which can be a significant advantage .

Whats new with JSON in 14

JSON par Dalibo

Commandes SQL JSON

Use cases

../../_images/use_cases.png