Re: how to avoid repeating expensive computation in select

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: how to avoid repeating expensive computation in select
Дата
Msg-id 3854.1296772410@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: how to avoid repeating expensive computation in select  (Bob Price <rjp_email@yahoo.com>)
Список pgsql-general
Bob Price <rjp_email@yahoo.com> writes:
> If I set the COST of expensivefunc high, and label it IMMUTABLE, will the query executor note that the two
invocationsto expensivefunc have the same inputs so it can only call it once and re-use the result the second time? 

No.  There is a myth prevalent among certain wishful thinkers that
IMMUTABLE does something like that, but it doesn't.  IMMUTABLE only
licenses the planner to fold a call *with constant arguments* into a
constant result, by executing the function once before the query
actually starts.  Textually distinct calls of a function are not folded
together in any case.

            regards, tom lane

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

Предыдущее
От: Nicklas Avén
Дата:
Сообщение: Re: how to avoid repeating expensive computation in select
Следующее
От: Tom Lane
Дата:
Сообщение: Re: how to avoid repeating expensive computation in select