Re: Add MIN/MAX aggregate support for uuid

From: "Tristan Partin" <tristan(at)partin(dot)io>
To: "pgsql-hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Add MIN/MAX aggregate support for uuid
Date: 2026-06-23 18:05:34
Message-ID: DJGMMC02MYD1.2BFUW3Z23S9FZ@partin.io
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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 :(.

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

Attachment Content-Type Size
v1-0001-Add-MIN-MAX-aggregate-support-for-uuid.patch text/x-patch 8.0 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Geoghegan 2026-06-23 18:15:47 Re: [GSoC 2026] - B-tree Index Bloat Reduction - Approach & Questions
Previous Message Tristan Partin 2026-06-23 18:03:51 Add MIN/MAX aggregate support for uuid