Re: Performance on JSONB select

From: Stephen Frost <sfrost(at)snowman(dot)net>
To: Michael Lewis <mlewis(at)entrata(dot)com>
Cc: PegoraroF10 <marcos(at)f10(dot)com(dot)br>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Performance on JSONB select
Date: 2019-10-02 21:57:47
Message-ID: 20191002215747.GR6962@tamriel.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Greetings,

* Michael Lewis (mlewis(at)entrata(dot)com) wrote:
> Much of indexing strategy depends on knowing the data like how many
> distinct values and what the distribution is like. Is JsonBField->>'status'
> always set? Are those three values mentioned in this query common or rare?
> Can you re-write this query to avoid using an OR in the where clause? Are
> you just wanting to add a GIN index for the jsonb paths? Or do you want
> indexed like below that are a bit stylized to this query?

If you know a field is going to always be there, you're better off, by
far, by just having a regular column for that value and a straight up
btree for it. This saves a significant amount of space and makes it
much easier to index and work with.

Thanks,

Stephen

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Stephen Frost 2019-10-02 22:09:15 Re: Wall shiping replica failed to recover database with error: invalid contrecord length 1956 at FED/38FFE208
Previous Message Shital A 2019-10-02 21:00:22 Re: Urgent :: Postgresql streaming replication issue - sync mode