Ragnar Hafstað wrote:
this has nothing to do with the return type. a volatile function is a
function that is not garanteed to return the same value given same
input parameters, (such as currval()).
when a volatile function is used thus:
SELECT * FROM mytable WHERE col=myvolatilefunc();
the planner must call the function once per table row, and assume
possibly different return values each time, so an indexscan will
not improve timings.
Why not use the index scan for every row, is this a "limit" in the
planner ? I think there is something in the planner I don't understand :-)
on the other hand, if the function is labeled STABLE, the planner
can assume that the same value will alway be returned, so only
one call to it can be made, and an indexscan might be found the
most effective.
The two other function types are not interesting, but I don't understand
the planners use of index optimization.
/BL
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster