From: Steven Schlansker <stevenschlansker@gmail.com>
To: Andrew Gierth <andrew@tao11.riddles.org.uk>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Computed index on transformation of jsonb key set
Date: Mon, 6 May 2019 18:26:17 -0700
Message-ID: <8E30DDCB-7096-48B4-9221-29E9AA5367B9@gmail.com> (raw)
In-Reply-To: <87h8ajx4y4.fsf@news-spur.riddles.org.uk>
References: <8A0F49D1-CA16-445B-BC4E-F53E9925809C@gmail.com>
<87h8ajx4y4.fsf@news-spur.riddles.org.uk>
> On Apr 27, 2019, at 12:55 AM, Andrew Gierth <andrew@tao11.riddles.org.uk> wrote:
>
> Obvious solution:
>
> create function uuid_keys(mapData jsonb) returns uuid[]
> language plpgsql immutable strict
> as $$
> begin
> return array(select jsonb_object_keys(mapData)::uuid);
> end;
> $$;
>
> create index on tbl using gin (uuid_keys(mapData));
>
> select * from tbl where uuid_keys(mapData) && array[...];
Thank you Andrew, I modified it slightly to use `language sql` but otherwise
it gets me going forward.
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: stevenschlansker@gmail.com, andrew@tao11.riddles.org.uk
Subject: Re: Computed index on transformation of jsonb key set
In-Reply-To: <8E30DDCB-7096-48B4-9221-29E9AA5367B9@gmail.com>
References: <8A0F49D1-CA16-445B-BC4E-F53E9925809C@gmail.com> <87h8ajx4y4.fsf@news-spur.riddles.org.uk> <8E30DDCB-7096-48B4-9221-29E9AA5367B9@gmail.com>
* 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