Re: JSON Indexes

From: Vik Fearing <vik(dot)fearing(at)dalibo(dot)com>
To: CS_DBA <cs_dba(at)consistentstate(dot)com>, PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: JSON Indexes
Date: 2014-06-24 21:16:59
Message-ID: 53A9EACB.8000604@dalibo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 06/24/2014 10:15 PM, CS_DBA wrote:
> I added a PK constraint on the id column and created this json index:
>
> create index mytest_json_col_idx on mytest ((task->'name'));
>
> However the planner never uses the index...
>
>
> EXPLAIN SELECT (mytest.task->>'name') as name,
>
> COUNT((mytest.task->>'name')) AS task_count
>
> FROM mytest
>
> GROUP BY (mytest.task->>'name')
>
> ORDER BY 2 DESC;
>
>
> Am I missing something?

Yes, you're querying task->>'name' but the index is on task->'name'.
--
Vik

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Patrick Krecker 2014-06-24 22:54:06 Getting "cache lookup failed for aggregate" error
Previous Message Merlin Moncure 2014-06-24 21:16:35 Re: JSON Indexes