Re: Coalesce bug ? - Mailing list pgsql-general

From David Johnston
Subject Re: Coalesce bug ?
Date
Msg-id 00ab01cddf9b$c2b466a0$481d33e0$@yahoo.com
Whole thread Raw
In response to Re: Coalesce bug ?  (Chris Angelico <rosuav@gmail.com>)
Responses Re: Coalesce bug ?  (Chris Angelico <rosuav@gmail.com>)
List pgsql-general
> 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.



pgsql-general by date:

Previous
From: "Kevin Grittner"
Date:
Subject: Re: Coalesce bug ?
Next
From: Tom Lane
Date:
Subject: Re: Coalesce bug ?