Why PostgreSQL volatile function is faster than inline subquery?
Volatility has to do with the expected results and the type of query so the query planner can be more efficient.
I suspect it has something to do with that your query is performing an index scan.
Without an explain it is very difficult to know what the query planner is doing. Please add this.