I tried to limit the amount of rows returned by adding
...
where
received_at >= current_date - interval '2 years'
...
to my query. This caused the optimiser to start using an index on received_at
and also to lengthen the duration of the query 10-fold….
Here are the explain plans:
- Explain plan query without filter
- Explain plan query with filter
The query that starts using the Index is starting to do a lot of IO.
What is causing this?
What is the best next action?
Using PostgreSQL 15.