> Something to consider: Since you've told Postgres that your function is > immutable, it might be remembering the result from the first execution and > using it in the second. Try restarting the server between the EXPLAIN and the > test. > Now that you've said this as well (hopefully you are not just repeating me)... Is this even possible or does an IMMUTABLE function has get evaluated at least one time per query? From Tom's comments I am assuming that, per plan, at minimum the planner will execute a function with constant literals one time and simply reuse the results. It does not sound as if a function with "field sourced values" will ever be "cached". Futhermore, even if a function is always called with the same constants the caching mechanism does not cross the statement boundary (not even to the transaction level let alone global). > By the way, why do you declare your functions as "STRICT IMMUTABLE" > and "STRICT VOLATILE"? Is this a question about the layout of the commands spatially? David J. -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general