Re: Does it make sense to break a large query into separate functions?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Does it make sense to break a large query into separate functions?
Дата
Msg-id 20549.1368112535@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Does it make sense to break a large query into separate functions?  (Merlin Moncure <mmoncure@gmail.com>)
Ответы Re: Does it make sense to break a large query into separate functions?  (Merlin Moncure <mmoncure@gmail.com>)
Список pgsql-general
Merlin Moncure <mmoncure@gmail.com> writes:
> right. note I think that (reduced invocation of immutable function) is
> the correct behavior.    If I say something is immutable, rightly or
> wrongly, I am giving postgres a free hand to reduce function calls.
> But (wandering off topic here),  But I'm wondering why the stable
> wrapper doesn't exhibit the same behavior.

The reason it won't inline such a wrapper is that if it expands foo(x)
to to_date(x, 'YYYY'), the latter expression will be considered stable,
not immutable; so for example any subsequent opportunity to
constant-fold it would not be taken.

It's conceivable that we could somehow decorate the parsetree so that
the function call node for to_date() would still be considered immutable
because it came out of inlining an immutable function.  But that's not
how things work now, and I'm dubious that it'd be worth the trouble.
Really the right answer here is to label the wrapper with the same
mutability level as its contents.

            regards, tom lane


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

Предыдущее
От: Nelson Green
Дата:
Сообщение: Storing small image files
Следующее
От: Achilleas Mantzios
Дата:
Сообщение: Re: Storing small image files