From: | Erwin Brandstetter <brsaweda(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)lists(dot)postgresql(dot)org |
Cc: | Ben Clements <benhasgonewalking(at)gmail(dot)com> |
Subject: | Re: Idea: Add first() and last() aggregate functions to the main release |
Date: | 2023-03-11 23:49:43 |
Message-ID: | CAGHENJ5QVH5gRLSEBMapgYi_zAcAartu8hBmrNomnVYLez=44g@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Sat, 11 Mar 2023 at 23:38, Ben Clements <benhasgonewalking(at)gmail(dot)com>
wrote:
> Idea/request for enhancement:
>
> Add the first() and last() aggregate functions to the main release (CREATE
> EXTENSION first_last_agg).
>
> Use Case: PostgreSQL equivalent to Oracle's MAX(...) KEEP (DENSE_RANK
> FIRST/LAST ORDER BY ...) <https://dba.stackexchange.com/a/324646/100880>
> (https://dba.stackexchange.com/a/324646/100880)
>
> GitHub: https://github.com/wulczer/first_last_agg
>
> Reason: As a non-dba, I can’t install additional modules like
> first_last_agg.
>
For what it's worth, I support the inclusion of first() and last() in the
main release. It makes queries involving multiple aggregate functions a lot
simpler. Most hosted services only allow official contrib modules.
The module has been around for more than 10 years now. First on
https://www.pgxn.org/dist/first_last_agg, then on
https://github.com/wulczer/first_last_agg. And it's been available from
apt.postgresql.org for a long time now.
Related questions pop up on Stackoverflow every now and then.
(I don't see anything related in the Postgres Todo, yet.)
The implementation in the additional module first_last_agg looks very
simple and straight-forward. Might be an easy task to incorporate into
mainline Postgres. But my C foo is just not good enough to judge whether
the implementation is ideal.
Regards
Erwin
From | Date | Subject | |
---|---|---|---|
Next Message | Martijn de Munnik | 2023-03-12 08:49:45 | Re: ERROR: only immutable functions supported in continuous aggregate view |
Previous Message | Ron | 2023-03-11 20:54:18 | Re: confusion between max_standby_archive_delay, max_standby_archive_delay and max_standby_archive_delay |