Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

Re: IMMUTABLE?



On May 15, 2006, at 21:31, Tom Lane wrote:

Sure.  As I read it, that's talking about a static transformation:
planner sees 2 + 2 (or if you prefer, int4pl(2,2)), planner runs the
function and replaces the expression with 4.  Nothing there about
memoization.

Oh, I see. So it's more like a constant or C macro.

It's true that the system *could* memoize (or in our more usual
parlance, cache function values) given the assumptions embodied in
IMMUTABLE.  But we don't, and I don't see any statement in the docs
that promises that we do.  For 99% of the functions that the planner
deals with, memoization would be seriously counterproductive because
the function evaluation cost is comparable to if not less than the
lookup cost in a memo table.  (int4pl is a good case in point.)

Yes, but there are definitely programming cases where memoization/ caching definitely helps. And it's easy to tell for a given function whether or not it really helps by simply trying it with CACHED and without.

Would this be a simple thing to implement?

Best,

David



Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group