From: Enrico Thierbach <eno@open-lab.org>
To: Oleg Bartunov <obartunov@postgrespro.ru>
Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: Trouble matching a nested value in JSONB entries
Date: Tue, 03 Jul 2018 12:16:46 +0200
Message-ID: <82F5E247-F0E9-40BF-AA5D-C136AB4D8459@open-lab.org> (raw)
In-Reply-To: <CAF4Au4waMhCKji=7X=4WjbYrHXA0nhMvT1Y-SgKUYcwKyEzX5Q@mail.gmail.com>
References: <B4DAA03F-FF61-420B-B4BE-B9A00A1E15E7@open-lab.org>
<CAF4Au4waMhCKji=7X=4WjbYrHXA0nhMvT1Y-SgKUYcwKyEzX5Q@mail.gmail.com>
Oleg,
>> 1 | {"group_id": 1}
>> 2 | {“group_id": 1}
>> 3 | {“group_id": 2}
>> 4 | {“group_id": 3}
>>
>> PS: Please note that I am currently at postgres 9.5. An update, if
>> necessary, would be possible though.
>
> Upgrade, please !
>
> I have only master 11beta2 right now:
>
> select * from qq where js @> '{"group_id":1}';
> id | js
> ----+-----------------
> 1 | {"group_id": 1}
> 2 | {"group_id": 1}
> (2 rows)
thanks for your answer. Your code does work fine on 9.5 already; what I
would like to achieve is to get records where the group_id entry is 1 or
2, and a fear that
select * from mytable where (metadata @> '{"group_id":1}') OR
(metadata @> '{"group_id”:2}’)
- while doable - would not make the best use of existing indices.
Any more ideas?
Best,
/eno
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: eno@open-lab.org, obartunov@postgrespro.ru
Subject: Re: Trouble matching a nested value in JSONB entries
In-Reply-To: <82F5E247-F0E9-40BF-AA5D-C136AB4D8459@open-lab.org>
References: <B4DAA03F-FF61-420B-B4BE-B9A00A1E15E7@open-lab.org> <CAF4Au4waMhCKji=7X=4WjbYrHXA0nhMvT1Y-SgKUYcwKyEzX5Q@mail.gmail.com> <82F5E247-F0E9-40BF-AA5D-C136AB4D8459@open-lab.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox