do you know if there is a way to improve this query?
The database where this query runs is very large, and it could take a lot of time to return the result.
We have indexes on field_1, field_2 and state
We are using Postgres
SELECT id
FROM a
WHERE
(field_1 = 999 OR field_2 = 876) AND state IN ('finished', 'closed')
ORDER BY created_at desc
One suggestion that I get is to split this query in two and then remove the "OR".
Another suggestion is to add some "pagination"
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…