Re: BUG #14301: function in case expression called when it should not be

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: BUG #14301: function in case expression called when it should not be
Дата
Msg-id 7178.1472484514@sss.pgh.pa.us
обсуждение исходный текст
Ответ на BUG #14301: function in case expression called when it should not be  (rikard@ngs.hr)
Список pgsql-bugs
rikard@ngs.hr writes:
> select case when doSlow then sum(slowFunction()) else sum(1) end as total
> from something group by doSlow

You are misunderstanding how aggregates work.  The aggregates are
evaluated first, then the surrounding expressions are done once at
the end of the query (or group).  The fact that the CASE might choose
the other branch at the end doesn't eliminate the necessity to run
both aggregates across all the rows.

            regards, tom lane

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

Предыдущее
От: rikard@ngs.hr
Дата:
Сообщение: BUG #14301: function in case expression called when it should not be
Следующее
От: Tom Lane
Дата:
Сообщение: Re: BUG #14300: Empty cube representation