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_nameWHERE code_id IN ( 1, 2) UNION SELECT *FROM table_nameWHERE (code_id = 3 AND created_date < now())LIMIT 1 From: Yambu [mailto:hyambu@gmail.com] Sent: Montag, 24. Mai 2021 05:42To: pgsql-sql@lists.postgresql.orgSubject: 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
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
WHERE (code_id = 3 AND created_date < now())
LIMIT 1
From: Yambu [mailto:hyambu@gmail.com] Sent: Montag, 24. Mai 2021 05:42To: pgsql-sql@lists.postgresql.orgSubject: Index creation
hello people, I would like to create an index so that the query on here can use it,
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
pgsql-sql by date:
Соглашаюсь с условиями обработки персональных данных