Re: why VOLATILE attribute is required?

Поиск
Список
Период
Сортировка
От Szymon Guz
Тема Re: why VOLATILE attribute is required?
Дата
Msg-id CAFjNrYvbNGf2_k63H-HcY2QNA4JFd6RTjRqKPg_j3917a9ZboA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: why VOLATILE attribute is required?  (Rafal Pietrak <rafal@zorro.isa-geek.com>)
Ответы Re: why VOLATILE attribute is required?
Список pgsql-general


On 22 September 2011 16:29, Rafal Pietrak <rafal@zorro.isa-geek.com> wrote:
On Thu, 2011-09-22 at 07:50 -0500, Merlin Moncure wrote:
> On Thu, Sep 22, 2011 at 5:28 AM, Rafal Pietrak <rafal@zorro.isa-geek.com> wrote:
>
> if you change the state of the database, including (and especially)
> system catalogs, your function is volatile, period.

Hmmm. To quote from the online documentation:

"VOLATILE indicates that the function value can change even within a
single table scan"

this funciton return value does not change. Further we read:

"any function that has side-effects must be classified volatile, even if
its result is quite predictable, to prevent calls from being optimized
away;"

Well. In this caase, I'd like it being optimised away. This is the
expected result. And the above documentation fragment states it as only
a precausion, not an ERROR.

Are there other reasons for that ERROR (e.g. not a warrning)?

Yes, the reason is that caching that function could be a problem.

And why do you want to optimize that? 
Does it take too much time, or do you want to call that thousands of times?
Have you checked how much the function lasts?
 


regards
Szymon

В списке pgsql-general по дате отправления:

Предыдущее
От: Eric Ridge
Дата:
Сообщение: OS X 10.7, psql, and tab completion?
Следующее
От: Jeff Adams
Дата:
Сообщение: Sending Results From One Function As Input into Another Function