RE: Working with JSONB data having node lists

From: Steven Winfield <Steven(dot)Winfield(at)cantabcapital(dot)com>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, geoff hoffman <geoff(at)rxmg(dot)com>
Cc: "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: RE: Working with JSONB data having node lists
Date: 2018-01-31 08:04:14
Message-ID: E9FA92C2921F31408041863B74EE4C2001A47A07DB@CCPMAILDAG03.cantab.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

If you can do this one without unnesting the downloads array I do not know how. Having done that: (WHERE dlarray->'publd' = '123)

I think it’s doable like this:

select * from contacts where data @> '{"downloads":[{"pubid":123}]}'::jsonb

…which would be aided by a gin index on ‘data’ using jsonb_path_ops:

CREATE INDEX idx_data_path_ops on contacts USING gin (data jsonb_path_ops);
https://www.postgresql.org/docs/10/static/datatype-json.html#JSON-INDEXING

Best,
Steve.

This email is confidential. If you are not the intended recipient, please advise us immediately and delete this message.
The registered name of Cantab- part of GAM Systematic is Cantab Capital Partners LLP.
See - http://www.gam.com/en/Legal/Email+disclosures+EU for further information on confidentiality, the risks of non-secure electronic communication, and certain disclosures which we are required to make in accordance with applicable legislation and regulations.
If you cannot access this link, please notify us by reply message and we will send the contents to you.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Pavel Suderevsky 2018-01-31 10:17:17 Understanding Huge Pages
Previous Message Peter Eisentraut 2018-01-31 04:32:53 Re: PostgreSQL Kerberos Authentication