Re: Coalesce bug ?

From: "David Johnston" <polobo(at)yahoo(dot)com>
To: "'Chris Angelico'" <rosuav(at)gmail(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: Coalesce bug ?
Date: 2012-12-21 16:53:52
Message-ID: 00ab01cddf9b$c2b466a0$481d33e0$@yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2012-12-21 17:09:57 Re: Coalesce bug ?
Previous Message Kevin Grittner 2012-12-21 16:41:02 Re: Coalesce bug ?