Re: indexed range queries on jsonb?

From: Christian Ramseyer <rc(at)networkz(dot)ch>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: indexed range queries on jsonb?
Date: 2014-08-26 13:46:17
Message-ID: 53FC8FA9.3060403@networkz.ch
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Abdul Sayeed 2014-08-26 13:54:24 Re: PostgreSQL DB Replication
Previous Message Larry White 2014-08-26 13:30:13 indexed range queries on jsonb?