| From: | Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com> |
|---|---|
| To: | Tristan Partin <tristan(at)partin(dot)io> |
| Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: Add MIN/MAX aggregate support for uuid |
| Date: | 2026-06-24 05:58:47 |
| Message-ID: | CALj2ACU7L1nVQdDeHXjQY5GGzKUDFk6Lj-0-HfUN=-jua0Easw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
On Tue, Jun 23, 2026 at 11:05 AM Tristan Partin <tristan(at)partin(dot)io> wrote:
>
> On Tue Jun 23, 2026 at 6:04 PM UTC, Tristan Partin wrote:
> > I noticed that we support various comparison operators on uuid values.
> > However, we were missing support for the MIN and MAX aggregate
> > functions, which seems like a logical thing to also support if we
> > support operators.
> >
> > The use case that I envision the most is finding the oldest and newest
> > UUID v7 values in a set. UUID v7 is a timestamp-prefixed identifier.
> > According to RFC 9562[0], the first 48 bits of a UUID v7 value are
> > a Unix Epoch timestamp. Additionally, Postgres implements Method 3 of
> > Section 6.2[1] for UUID v7 such that the next 12 bits bits store a
> > 1/4096 (or 2^12) fraction of sub-millisecond precision. See the comment
> > in generate_uuidv7() for more details.
> >
> > [0]: https://datatracker.ietf.org/doc/html/rfc9562#name-uuid-version-7
> > [1]: https://datatracker.ietf.org/doc/html/rfc9562#monotonicity_counters
>
> And of course no patch attached :(.
The intent looks fine to me for UUIDv7. It would be interesting to
understand why there's been no such support for versions < v7 so far
in Postgres. Is there a limitation?
A minor comment on the patch.
1/ + UUIDs are compared lexicographically on their 128-bit value.
For version 7 UUIDs,
How about using UUIDv7 instead of "version 7 UUIDs"?
--
Bharath Rupireddy
Amazon Web Services: https://aws.amazon.com
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Henson Choi | 2026-06-24 06:04:09 | Re: Row pattern recognition |
| Previous Message | Michael Paquier | 2026-06-24 05:57:47 | Re: Add per-backend lock statistics |