Re: [HACKERS] Function Volatility and Views Unexpected Behavior

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [HACKERS] Function Volatility and Views Unexpected Behavior
Дата
Msg-id 24070.1499887438@sss.pgh.pa.us
обсуждение исходный текст
Ответ на [HACKERS] Function Volatility and Views Unexpected Behavior  (David Kohn <djk447@gmail.com>)
Ответы Re: [HACKERS] Function Volatility and Views Unexpected Behavior  (David Kohn <djk447@gmail.com>)
Re: [HACKERS] Function Volatility and Views Unexpected Behavior  (Robert Haas <robertmhaas@gmail.com>)
Список pgsql-hackers
David Kohn <djk447@gmail.com> writes:
> I encountered some unexpected behavior when debugging a query that was
> taking longer than expected, basically, a volatile function that makes a
> column in a view is called even when that column is not selected in the
> query, making it so that the function is called for every row in the view,
> I'm not sure that that would necessarily be the expected behavior, as it
> was my understanding that columns that are not selected are not evaluated,
> for instance if there was a join in a view that produced some columns and
> said columns were not selected, I would expect it to be optimized away.

No, this is the expected behavior; we don't like optimization to change
the number of calls of a volatile function from what would occur in naive
evaluation of the query.  If that prospect doesn't bother you, it's
likely because your function isn't really volatile ...

> The other problem is that the function call does not appear in the query
> plan.

I think "explain verbose" will fix that for you.
        regards, tom lane



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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: [HACKERS] PostgreSQL10 beta2 with ICU - initdb fails on MacOS
Следующее
От: Peter Geoghegan
Дата:
Сообщение: Re: [HACKERS] [WIP] Zipfian distribution in pgbench