How to create index on json array in postgres

From: Surya S <surya(dot)s(at)citrusinformatics(dot)com>
To: pgsql-sql(at)lists(dot)postgresql(dot)org
Subject: How to create index on json array in postgres
Date: 2019-01-01 05:49:59
Message-ID: 08b38bb7-c0a5-1fe1-3e13-536383d66a2e@citrusinformatics.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi,

     I have a json field called 'elements' in my table demo which
contains an array 'data' containing key value pairs. the 'data' array
has the below structure. the data array may have multiple json entries.I
am using postgres version 9.5

{ "data": [{ "ownr": "1", "siUsr": [2], "sigStat": "APPR", "modifiedOn":
1494229698039, "isDel": "false", "parentId": "nil", "disName":
"exmp.json", "uniqueId": "d88cb52", "usrType": "owner", "usrId": "1",
"createdOn": 1494229698039, "obType": "file" }] }

In my query I have multiple filters based on obj(Eg : obj->>usrId,
obj->>siUsr etc) where obj corresponds to
json_array_elements(demo.elements->'data').How do I create btree indices
on filters like obj->>userId ,obj->>sigUsr? Please revert.

Regards

Surya

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Alexey Bashtanov 2019-01-04 17:10:37 Re: How to create index on json array in postgres
Previous Message 梁博 2019-01-01 01:38:22 Re:Re: backend process was crashed when using zabbix monitor