From: Stephen Frost <sfrost@snowman.net>
To: Michael Lewis <mlewis@entrata.com>
Cc: PegoraroF10 <marcos@f10.com.br>
Cc: pgsql-general <pgsql-general@postgresql.org>
Subject: Re: Performance on JSONB select
Date: Wed, 2 Oct 2019 17:57:47 -0400
Message-ID: <20191002215747.GR6962@tamriel.snowman.net> (raw)
In-Reply-To: <CAHOFxGpFn8+r+_RjRMkbUH0TY0DPhyaV=+JraTi8caZWBy7cZA@mail.gmail.com>
References: <1570027063947-0.post@n3.nabble.com>
<CAHOFxGpFn8+r+_RjRMkbUH0TY0DPhyaV=+JraTi8caZWBy7cZA@mail.gmail.com>
Greetings,
* Michael Lewis (mlewis@entrata.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
Attachments:
signature.asc (application/pgp-signature, 818B) download
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: sfrost@snowman.net, mlewis@entrata.com, marcos@f10.com.br
Subject: Re: Performance on JSONB select
In-Reply-To: <20191002215747.GR6962@tamriel.snowman.net>
References: <1570027063947-0.post@n3.nabble.com> <CAHOFxGpFn8+r+_RjRMkbUH0TY0DPhyaV=+JraTi8caZWBy7cZA@mail.gmail.com> <20191002215747.GR6962@tamriel.snowman.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox