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

Please share your ideas and opinions about this topic with me, your contribution will add true value to this topic.
If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.

If you like this post, then please share it with others.
Please follow, I will share my experience towards the success of Database Research and Development Activity.

I put up a post every day, please keep reading and learning.
Discover Yourself, Happy Blogging !
Anvesh M. Patel.

More from

Leave a Reply

Be the First to Comment!

Notify of