Hello Tom, I agree such functions are very useful, as they allow you to use ordinary aggregation functions such as sum/max/avg along with first/last ones (traditionally served by DISTINCT ON or LIMIT) in the same group-by node which improves performance and readability. The first/last extension you mentioned http://pgxn.org/dist/first_last_agg/ has a slight disadvantage: it relies on postgres providing it sorted data if user asks for defined ordering. This makes first/last functions not supporting hashAgg, only groupAgg which usually requires explicit sort. If you find first_last_agg performance poor take a look at argm extension http://pgxn.org/dist/argm/ . It provides similar functionality but works faster as it does not sort or make postgres core sort, but only chooses the first row within each group. As for the original question unfortunately the way from an extension to postgres core is not too easy and normally requires an extension to become popular and to be included in postgres distribution as a contrib module first. Regards, Alexey Bashtanov On 19/05/16 04:04, Tom Smith wrote:
|