From: | Michael Lewis <mlewis(at)entrata(dot)com> |
---|---|
To: | Sankar P <sankar(dot)curiosity(at)gmail(dot)com> |
Cc: | PostgreSQL General <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | Re: DISTINCT on jsonb fields and Indexes |
Date: | 2020-06-22 16:45:44 |
Message-ID: | CAHOFxGpWgy4PC0MczyWHK6UTgc-RxO_RS0cezLChkH+Tksbk-A@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Sun, Jun 21, 2020 at 10:43 PM Sankar P <sankar(dot)curiosity(at)gmail(dot)com>
wrote:
> I have a table with the schema:
>
> CREATE TABLE fluent (id BIGSERIAL, record JSONB);
>
> Then I created a couple of indexes:
> 1) CREATE INDEX idx_records ON fluent USING GIN (record);
>
What about using non-default jsonb_path_ops?
> 2) CREATE INDEX idx_btree_records ON fluent USING BTREE ((record ->>
> 'destinationServiceName'));
>
Is this key always set? If so, make it a proper column so you get
statistics on common values and number of distinct values as such.
If it is rarely used, create a partial index perhaps. I am a little
surprised that the plain btree index wasn't used from my naive point of
view. Did you check execution time with sequential scan disabled to try to
strongly encourage the use of index scan?
From | Date | Subject | |
---|---|---|---|
Next Message | Paul Förster | 2020-06-22 16:48:15 | Re: Netapp SnapCenter |
Previous Message | Flaris Feller | 2020-06-22 16:44:17 | Re: ERROR: invalid memory alloc request size 18446744073709551613 |