From: | Yambu <hyambu(at)gmail(dot)com> |
---|---|
To: | Marc Mamin <M(dot)Mamin(at)intershop(dot)de> |
Cc: | "pgsql-sql(at)lists(dot)postgresql(dot)org" <pgsql-sql(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Index creation |
Date: | 2021-05-25 10:18:45 |
Message-ID: | CALhHtcARF_p4S+suVhvHWGXk20fTmfO+VwS=SbDZUcCtMwAcUA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Noted with thanks.
On Tue, May 25, 2021 at 9:44 AM Marc Mamin <M(dot)Mamin(at)intershop(dot)de> wrote:
> Hi,
>
>
>
> beside the other comments, you may try to rework your query to reduce the
> OR clauses which rise the uncertainty for the planner.
>
>
>
>
>
> e.g.:
>
>
>
> SELECT
>
> *
>
> FROM
>
> table_name
>
> WHERE code_id IN ( 1, 2)
>
>
>
> UNION
>
>
>
> SELECT
>
> *
>
> FROM
>
> table_name
>
> WHERE (code_id = 3 AND created_date < now())
>
> LIMIT 1
>
>
>
>
>
>
>
> *From:* Yambu [mailto:hyambu(at)gmail(dot)com]
> *Sent:* Montag, 24. Mai 2021 05:42
> *To:* pgsql-sql(at)lists(dot)postgresql(dot)org
> *Subject:* Index creation
>
>
>
> hello people, I would like to create an index so that the query on here
> can use it,
>
>
>
> SELECT
>
> *
>
> FROM
>
> table_name
>
> WHERE (code_id = 1
>
> OR code_id = 2
>
> OR (code_id = 3
>
> AND created_date < now()))
>
> LIMIT 1;
>
>
>
> please advise me on how I should create index. I created index on code_id
> but it's not being used
>
From | Date | Subject | |
---|---|---|---|
Next Message | Yambu | 2021-05-26 09:26:17 | Select for update |
Previous Message | Marc Mamin | 2021-05-25 09:44:00 | RE: Index creation |