Add MIN/MAX aggregate support for uuid - Mailing list pgsql-hackers

From Tristan Partin
Subject Add MIN/MAX aggregate support for uuid
Date
Msg-id DJGML0T9FCDV.3VA29JLODXEHZ@partin.io
Whole thread
Responses Re: Add MIN/MAX aggregate support for uuid
List pgsql-hackers
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

--
Tristan Partin
PostgreSQL Contributors Team
AWS (https://aws.amazon.com)



pgsql-hackers by date:

Previous
From: Masahiko Sawada
Date:
Subject: Re: Add a hook for handling logical decoding messages on subscribers.
Next
From: "Tristan Partin"
Date:
Subject: Re: Add MIN/MAX aggregate support for uuid