Andriy Tkachuk <ant(at)imt(dot)com(dot)ua> writes:
> At second. calc_total() is immutable function:
> but it seems that it's not cached in one session:
It's not supposed to be.
The reason the "runtime" is small in your example is that the planner
executes the function call while preparing the plan, and this isn't
counted in EXPLAIN's runtime measurement. There's no claim anywhere
that the results of such an evaluation would be saved for other plans.
regards, tom lane