I've created a naming function for multiple table id combinations for human understanding. Essentially it denormalises tables combining the important data into a varchar.
It takes 3 parameters, and is a stable function but I can't get my view to use it as such. When my view returns 10k results, with the same 3 input values for every row... it executes the function 10000 times, making the query take 100x longer.
My function is not meant to be fast, but presumably with the query plan the database considers that it's going to be faster that way (I have cross joins, and window aggregates etc)
I've tried putting the rest of the query into an inner query, my function into a lateral join, and have increased the function cost to millions, all in vain.
Is there a way to hint it's (cached) execution (other than what I've already tried), or some factor that would make postgres ignore the stable declaration (too many arguments)?