PostgreSQL 9.4: Indexing on jsonb Data Type (Part 3/3)

In the previous two parts, We have seen basic about JSON data types, operators and functions of PostgreSQL 9.4.

In this post, I am showing to create GIN INDEX on the jsonb data type of PostgreSQL 9.4.

If we are thinking to store large JSON document into an RDBMS product, we should also apply proper indexing for that JSON document.
The GIN indexing is very useful to search key and value pairs from the large jsonb documents.
This GIN index supports queries with this all @>, ?, ?& and ? different operators.

Below is a small demonstration to create GIN index for jsonb data type.

First, create sample table with jsonb data type and JSON data:

Create GIN index for jsonb column:

The SELECT query which makes use of this created index:

Create expression indexes for particular internal items and keys:

To SELECT internal ‘role’ key which makes use of this expression index

Anvesh Patel

Leave a Reply

Be the First to Comment!

Notify of
avatar
wpDiscuz