2ndQuadrant | PostgreSQL
PostgreSQL Solutions for the Enterprise
+39 0574 159 3000
  • Contact Us
  • EN
    • FR
    • IT
    • ES
    • DE
  • Support & Services
    • Support
      • 24/7 PostgreSQL Support
      • Developer Support
      • IBM Z Production Support
    • DBA Services
      • Remote DBA
      • Database Monitoring
    • Consulting Services
      • Health Check
      • Performance Tuning
      • Database Security Audit
      • PostgreSQL Upgrade
      • Kubernetes for Postgres and BDR
    • Migration Services
      • Migrate to PostgreSQL
      • Migration Assessment
  • Products
    • PostgreSQL with High Availability
    • BDR
    • 2ndQPostgres
    • pglogical
      • Installation instruction for pglogical
      • Documentation
    • repmgr
    • Barman
    • Postgres Cloud Manager
    • SQL Firewall
    • Postgres-XL
    • OmniDB
    • Postgres Installer
    • 2UDA
  • Downloads
    • Postgres Installer
    • 2UDA – Unified Data Analytics
  • Postgres Learning Center
    • Webinars
      • You forgot to put the WHERE in DELETE?
      • BDR Overview
    • Whitepapers
      • Highly Available Postgres Clusters
      • AlwaysOn Postgres
      • BDR
      • PostgreSQL Security Best Practices
    • Case Studies
      • Performance Tuning
        • BenchPrep
        • tastyworks
      • Distributed Clusters
        • ClickUp
        • European Space Agency (ESA)
        • Telefónica del Sur
        • Animal Logic
      • Database Administration
        • Agilis Systems
      • Professional Training
        • Met Office
        • London & Partners
      • Database Upgrades
        • Alfred Wegener Institute (AWI)
      • Database Migration
        • Healthcare Software Solutions (HSS)
        • Navionics
    • Training
      • Training Catalog and Scheduled Courses
        • Advanced Development & Performance
        • Linux for PostgreSQL DBAs
        • BDR
        • PostgreSQL Database Administration
        • PostgreSQL Data Warehousing & Partitioning
        • PostgreSQL for Developers
        • PostgreSQL Immersion
        • PostgreSQL Immersion for Cloud Databases
        • PostgreSQL Security
        • Postgres-XL-10
        • Practical SQL
        • Replication, Backup & Disaster Recovery
        • Introduction to PostgreSQL and Kubernetes
    • Books
      • PostgreSQL 11 Administration Cookbook
      • PostgreSQL 10 Administration Cookbook
      • PostgreSQL High Availability Cookbook – 2nd Edition
      • PostgreSQL 9 Administration Cookbook – 3rd Edition
      • PostgreSQL Server Programming Cookbook – 2nd Edition
      • PostgreSQL 9 Cookbook – Chinese Edition
    • PostgreSQL
      • PostgreSQL – History
      • Who uses PostgreSQL?
      • PostgreSQL FAQ
      • PostgreSQL vs MySQL
      • Business Case for PostgreSQL
      • Security Information
    • Events
    • Blog
  • About Us
    • About 2ndQuadrant
    • What Does “2ndQuadrant” Mean?
    • 2ndQuadrant’s Passion for PostgreSQL
    • Ask Simon
    • News
    • Careers
    • Team Profile
  • Blog
  • Menu
You are here: Home / Blog / Giuseppe's PlanetPostgreSQL / NoSQL with PostgreSQL 9.4 and JSONB
2ndQuadrant Press

NoSQL with PostgreSQL 9.4 and JSONB

February 23, 2015/1 Comment/in Giuseppe's PlanetPostgreSQL /by 2ndQuadrant Press

articolo-json-giuseppe

The introduction of the JSONB data type in PostgreSQL, definitely makes the “NoSQL” side of this relational DBMS come out: this introduction meets the requirements of all those who prefer a data structure in a “key-value” array, dictionary style (widely used in the field of development) and, at the same time, ensures all the advantages of a relational database.

PostgreSQL 9.2 already provided for the use of JSON type, maintening the compatibility of JSON data directly in a database. However, it was a text type data with the ability to validate JSON syntax. With this new type of JSONB data, information is stored in a dedicated binary format. So it is possible to benefit from specific algorithms which improve access performances and optimise storage on disk, which offer:

  • advanced access and comparison operators: thanks to the specialised structure, JSONB has allowed the implementation of new operators that, in addition to offering more flexibility, allow the user to harness the full power of hash, btree, GIST and GIN indexes;
  • reduced dimensions on disk: the space required to store documents of a complex structure with the JSONB data is smaller than disk requirements for the JSON format;
  • internal organisation as a dictionary with a unique key: this means that access is extremely fast, but the key order of entry within the JSONB structure is not preserved. Furthermore, in the presence of duplicated keys, only the last entered value is maintained, unlike to what happened with JSON data:

    $ SELECT '{"a":1, "b":2}'::JSONB = '{"b":2, "a":1}'::JSONB
     ?column?
     --------
      t
     (1 row)
    
    $ SELECT '{"a":"abc", "d":"def","z":[1,2,3],"d":"overwritten"}'::JSON
                  JSON
      ----------------------------------------------
      {"a":"abc", "d":"def","z":[1,2,3],"d":"overwritten"}
      (1 row)
    
    $ SELECT '{"a":"abc", "d":"def","z":[1,2,3],"d":"overwritten"}'::JSONB
                  JSON
      ----------------------------------------------
      {"a":"abc", "d":"overwritten","z":[1,2,3]}
      (1 row)

It is anyway necessary to point out that JSONB data is compatible with all functions introduced for the JSON data.

The effects of this possibility of indexing the JSONB type is translated into a better availability of data to be read, thus allowing an efficient access to the whole content of a JSONB field.

This makes it possible to efficiently use PostgreSQL in order to analyse data which does not have a predefined scheme, by moving it closer to the “NoSQL” world. In this regard, community member Thom Brown conducted some tests showing how an increase in reading performances (and a more reduced space occupied by indexes) was found, as compared to a JSON field, thus reaching reading performances even higher than those of typically NoSQL DBMS, such as MongoDB.

Conclusions

The introduction of +JSONB+ type definitely moves PostgreSQL closer to developers who normally use data in a +JSON+ format. An example is web developers who widely use JavaScript and have possibly already started working with PostgreSQL using the +JSON+ type for storing data. By evolving to +JSONB+, they will be able to use all the power of the PostgreSQL engine to develop that data easily and efficiently.

Tags: 9.4, array, btree, database, dbms, dictionary, GIN, GIST, hash, javascript, JSON, JSONB, key-value, mongodb, NOSQL, object, postgres 9.4, PostgreSQL, PostgreSQL 9.4, unstructured data
Share this entry
  • Share on Facebook
  • Share on Twitter
  • Share on WhatsApp
  • Share on LinkedIn
1 reply

Trackbacks & Pingbacks

  1. JSONB type performance in PostgreSQL 9.4 | 2ndQuadrant says:
    March 3, 2015 at 9:54 am

    […] NoSQL with PostgreSQL 9.4 and JSONB → […]

    Reply

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Search

Recent Posts

  • Setting SSL/TLS protocol versions with PostgreSQL 12 November 27, 2019
  • Webinar: Using SSL with PostgreSQL and pgbouncer [Follow Up] November 14, 2019
  • PostgreSQL 12: Implementing K-Nearest Neighbor Space Partitioned Generalized Search Tree Indexes November 5, 2019
  • Webinar: PostgreSQL Partitioning [Follow up] October 28, 2019
  • Postgres-BDR: It is also about fast safe upgrades October 15, 2019

Featured External Blogs

Tomas Vondra's Blog

Our Bloggers

  • Simon Riggs
  • Alvaro Herrera
  • Andrew Dunstan
  • Craig Ringer
  • Francesco Canovai
  • Gabriele Bartolini
  • Giulio Calacoci
  • Ian Barwick
  • Marco Nenciarini
  • Mark Wong
  • Pavan Deolasee
  • Petr Jelinek
  • Shaun Thomas
  • Tomas Vondra
  • Umair Shahid

PostgreSQL Cloud

2QLovesPG 9.6 backup Barman BDR Business Continuity community conference database DBA development devops disaster recovery greenplum Hot Standby JSON JSONB kanban logical decoding logical replication monitoring open source performance PG12 pgbarman pgday pglogical PG Phriday postgres Postgres-BDR postgres-xl PostgreSQL PostgreSQL 9.6 PostgreSQL10 PostgreSQL 11 PostgreSQL11 PostgreSQL 11 New Features postgresql repmgr Recovery release replication sql standby wal webinar
UK +44 (0)870 766 7756

US +1 650 378 1218

Support & Services

24/7 Production Support

Developer Support

Remote DBA for PostgreSQL

PostgreSQL Database Monitoring

PostgreSQL Health Check

PostgreSQL Performance Tuning

Database Security Audit

Upgrade PostgreSQL

PostgreSQL Migration Assessment

Migrate from Oracle to PostgreSQL

Products

HA Postgres Clusters

Postgres-BDR

2ndQPostgres

pglogical

repmgr

Barman

Postgres Cloud Manager

SQL Firewall

Postgres-XL

OmniDB

Postgres Installer

2UDA

Postgres Learning Center

Introducing Postgres

Blog

Webinars

Books

Videos

Training

Case Studies

Events

About Us

About 2ndQuadrant

What does 2ndQuadrant Mean?

News

Careers 

Team Profile

©2001-2019 2ndQuadrant Ltd. All rights reserved | Privacy Policy
  • Twitter
  • LinkedIn
  • Facebook
  • Youtube
  • Mail
Incremental backup with Barman 1.4.0 JSONB type performance in PostgreSQL 9.4
Scroll to top
×