Re: Performance on JSONB select

From: Michael Lewis <mlewis(at)entrata(dot)com>
To: PegoraroF10 <marcos(at)f10(dot)com(dot)br>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Performance on JSONB select
Date: 2019-10-07 21:27:07
Message-ID: CAHOFxGrqwJYg=iuyjqt9Tf6twb1h3aA13+c0sOWY1SESbT9gXw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

>
> My Json has always a status
>

Why declare the "where" clause when creating the index? It would not seem
needed if status is always set and so your index will reference all rows in
the table.

Thanks for sharing the trick of having the second column in the index
determine the key based on the first column. I don't know if/when I might
need this, but an interesting solution. Generically, it seems like the
below-

create index idx_mytable_jsonb_dependent_fields on public.mytable (
(JsonBField->>'primary_field_to_filter_on'),
JsonBField->(JsonBField->>'primary_field_to_filter_on')->>'secondary_field'
);

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Michael Lewis 2019-10-07 21:39:08 Re: JSONB maximal length ?
Previous Message Tomas Vondra 2019-10-07 21:19:30 Re: Table locking during backup