Indexes in JSONB

From: Saurav Sarkar <saurav(dot)sarkar1(at)gmail(dot)com>
To: PostgreSQL General <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Indexes in JSONB
Date: 2022-03-29 05:05:41
Message-ID: CAP+kwAVfutZ+_3pau_4OkdnTAQpnSUNkpyTQvF6kTc-qYB1E1g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi All,

We use JSONB /NoSQL functionality of PostgreSQL.

One of the column "doc" in our table "Table1" is of type JSONB.

Now the rows in this column "doc" can have different values with different
schemas.

For e.g values of doc per row will be something like below

ROW1 = {"id":"1", "name":"abc" }
ROW2 = {"id:"2" , "address": "address1"}
ROW3= {"id":"3" , "name":"def", "country":"country1" }

So you can see the JSON is changing and keys/schema can be different for
each rows.

During the course of time indexes will be created for the json keys of the
JSON values in this column.
For e.g. on "name", "address" , "country" now. Later I can have another key
and index like on "continent".

As per postgresql limitations there are limits on the indexes. So I
understand we can create many indexes.

But obviously I understand creating many indexes will impact write
performance and space will be utilized.

Would like to know if creating indexes in this manner can create any other
issues or inputs on the whole topic of indexes in JSONB types.

Best Regards,
Saurav

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Magnus Hagander 2022-03-29 08:49:46 Re: Indexes in JSONB
Previous Message Dilip Kumar 2022-03-29 04:17:26 Re: Support logical replication of DDLs