Question :
I have a subquery that will return 3 records, to later add the result of some calculations (using some functions).
When I am running the full query, Postgres is calculating a high number of expected rows and decides not to use the index. but when I use just the subquery, the index is used.
Plese refer to the attached screenshots.
Have any of you experienced this?
Thank you,
The EXPLAIN for the full query is as follows:
When I analyze the subquery, the index gets used.
Answer :
The use of the function in the outer query was preventing parallelism.
After setting the functions to PARALLEL SAFE
, it started working fine using the index. Thank you @mustaccio!!
Please refer to the parallelism documentation in the following links: