Re: indexed range queries on jsonb? - Mailing list pgsql-general

From Christian Ramseyer
Subject Re: indexed range queries on jsonb?
Date
Msg-id 53FC8FA9.3060403@networkz.ch
Whole thread Raw
In response to indexed range queries on jsonb?  (Larry White <ljw1001@gmail.com>)
List pgsql-general
On 8/26/14 3:30 PM, Larry White wrote:


>
> Logically, what I want is to be able to make queries like this:
>
>     select * from document where ((payload->'intTest'))> 5;
>
> With casting, I came up with:
>
>     select * from document where (((payload->'intTest'))::text)::integer
>     > 5;
>
> But this query does not use the index according to Explain
>

I have not tested this with a jsonb property but you should be able to
define an index over payload->'intTest'::integer using an expression
index, described here:

http://www.postgresql.org/docs/9.1/static/indexes-expressional.html

Christian


pgsql-general by date:

Previous
From: Larry White
Date:
Subject: indexed range queries on jsonb?
Next
From: Abdul Sayeed
Date:
Subject: Re: PostgreSQL DB Replication