Re: First Aggregate Funtion?

Поиск
Список
Период
Сортировка
От Merlin Moncure
Тема Re: First Aggregate Funtion?
Дата
Msg-id CAHyXU0xKQhrqwimGvQ8b3CvrZjWMye0r+pay_50RUBc+SFfbMw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: First Aggregate Funtion?  (Paul A Jungwirth <pj@illuminatedcomputing.com>)
Список pgsql-hackers
On Mon, Jul 20, 2015 at 10:06 AM, Paul A Jungwirth
<pj@illuminatedcomputing.com> wrote:
>> The above implementation of "first" aggregate returns the first non-NULL item
>> value.
>
> I'm curious what advantages this approach has over these FIRST/LAST
> functions from the Wiki?:
>
>     https://wiki.postgresql.org/wiki/First/last_%28aggregate%29
>
> Also to get the "first non-null value" you can apply an ordering to
> just the aggregate function, e.g.:
>
>     select first(id order by start_time nulls last) from events;
>
> If you want speed you should probably write a C version.

C functions come with a lot of administration headaches, and the
performance gain will probably not be significant unless you totally
bypass the SPI interface.   Even then, I suspect (vs the pl/pgsql
variant which caches plan) the majority of overhead is is in calling
the function, not the actual implementation.  It's be interesting to
see the results though.

merlin



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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: [BUGS] object_classes array is broken, again
Следующее
От: Heikki Linnakangas
Дата:
Сообщение: Re: All-zero page in GIN index causes assertion failure