Re: Computed index on transformation of jsonb key set - Mailing list pgsql-general

From Steven Schlansker
Subject Re: Computed index on transformation of jsonb key set
Date
Msg-id 8E30DDCB-7096-48B4-9221-29E9AA5367B9@gmail.com
Whole thread Raw
In response to Re: Computed index on transformation of jsonb key set  (Andrew Gierth <andrew@tao11.riddles.org.uk>)
List pgsql-general
> 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.




pgsql-general by date:

Previous
From: Sathish Kumar
Date:
Subject: Re: Import Database
Next
From: Tony Shelver
Date:
Subject: Re: Postgres for SQL Server users