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)
Список
Дерево обсуждения
First Aggregate Funtion? Tony Caduto <tony_caduto@amsoftwaredesign.com>
Re: First Aggregate Funtion? Martijn van Oosterhout <kleptog@svana.org>
Re: First Aggregate Funtion? "Mike Rylander" <mrylander@gmail.com>
Re: First Aggregate Funtion? sudalai <sudalait2@gmail.com>
Re: First Aggregate Funtion? Robert Haas <robertmhaas@gmail.com>
Re: First Aggregate Funtion? sudalai <sudalait2@gmail.com>
Re: First Aggregate Funtion? Merlin Moncure <mmoncure@gmail.com>
Re: First Aggregate Funtion? Paul A Jungwirth <pj@illuminatedcomputing.com>
Re: First Aggregate Funtion? Corey Huinker <corey.huinker@gmail.com>
Re: First Aggregate Funtion? Marko Tiikkaja <marko@joh.to>
Re: First Aggregate Funtion? Jim Nasby <Jim.Nasby@BlueTreble.com>
Re: First Aggregate Funtion? Merlin Moncure <mmoncure@gmail.com>
Re: First Aggregate Funtion? Bruno Wolff III <bruno@wolff.to>
On Mon, Jul 20, 2015 at 10:06 AM, Paul A Jungwirth
 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
Дата:
От: Heikki Linnakangas
Дата:
FAQ