Re: Partial index on JSON column

From: Michael Lewis <mlewis(at)entrata(dot)com>
To: Samuel Williams <space(dot)ship(dot)traveller(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Partial index on JSON column
Date: 2019-02-19 21:25:17
Message-ID: CAHOFxGqsy8XqRsFC8z_uFuSKbpuJUfgaXigFXELU6it6pweT5A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Feb 19, 2019 at 1:41 PM Samuel Williams <
space(dot)ship(dot)traveller(at)gmail(dot)com> wrote:

> Hello
>
> I have a table with ~3 billion events.
>
> Of this, there are a small subset of events which match the following
> query:
>
> CREATE INDEX index_user_event_for_suggestion_notification ON
> public.user_event USING btree ((((parameters ->>
> 'suggestion_id'::text))::integer), what) WHERE ((parameters ->>
> 'suggestion_id'::text) IS NOT NULL)
>

You may want to use this-
CREATE INDEX index_user_event_for_suggestion_notification ON
public.user_event USING btree (parameters ->> 'suggestion_id', what) WHERE
parameters ? 'suggestion_id';

-Michael

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Michael Lewis 2019-02-19 21:28:41 Re: Partial index on JSON column
Previous Message Samuel Williams 2019-02-19 21:24:44 Re: Partial index on JSON column