On May 15, 2006, at 20:21, Tom Lane wrote:
So, what gives? Am I missing something, or not understanding how
IMMUTABLE works?
The latter.
Hee-hee! And after all those nice things I wrote about you in a
previous email on this list!
But seriously, the documentation says (as if I need to tell you, but
I was reading it again to make sure that I'm not insane):
IMMUTABLE indicates that the function always returns the same
result when given the same argument values; that is, it does not do
database lookups or otherwise use information not directly present
in its argument list. If this option is given, any call of the
function with all-constant arguments can be immediately replaced
with the function value.
So that seems pretty clear to me. Now, granted, the recursive calls
to fib() don't pass a constant argument, but I still would think that
after the first time I called fib(28), that the next call to fib(28)
would be lightening fast, even if fib(27) wasn't.
So, uh, would you mind telling me what I'm missing? I'm happy to turn
that knowledge into a documentation patch to help future boneheads
like myself. :-)
Thanks,
David