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-02 16:13:08 |
Message-ID: | CAHOFxGpFn8+r+_RjRMkbUH0TY0DPhyaV=+JraTi8caZWBy7cZA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
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?
CREATE INDEX idx_MyTable_status USING btree( JsonBField->>'status' );
CREATE INDEX idx_MyTable_descartada_date USING btree(
To_Date(JsonBField->'descartada'->>'data','yyyy-mm-dd') );
CREATE INDEX idx_MyTable_contrato_date USING btree(
To_Date(JsonBField->'contrato'->>'data','yyyy-mm-dd') );
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Gierth | 2019-10-02 16:20:11 | Re: Possible bug: SQL function parameter in window frame definition |
Previous Message | Jason Ralph | 2019-10-02 15:41:00 | PG11 Parallel Thanks!! |