Native UUIDv6/v7 support?

60 views
Skip to first unread message

Daniils Petrovs

unread,
Jun 5, 2023, 5:10:47 AM6/5/23
to elixir-ecto
Some users of Ecto would find it very useful to be able to easily start using UUIDv6/v7 right in Ecto, without needing to fall back to another external library.

UUIDv6/v7 is still in draft status, however it has substantial improvements over UUIDv4, the current implementation of UUID generation in Ecto.UUID. Mainly several organisations have found that using UUIDs with a time-ordered value can dramatically improve query performance in scenarios where ordering prediction attacks aren't a concern.

José Valim

unread,
Jun 5, 2023, 6:26:20 AM6/5/23
to elixi...@googlegroups.com
Three points:

1. We probably should not adopt it officially while it is in draft status, since a library can evolve and iterate quicker
2. Once it is no longer a draft, making it part of Ecto will depend on official database support and adoption
3. And even if it is made part of Ecto, it won't really provide any benefit over a library, the user experience will be the same, so there is no reason to rush (or even to have it in Ecto as things stand)

So I would say an external library is fine and the way to go in at least short- and medium-term.

--
You received this message because you are subscribed to the Google Groups "elixir-ecto" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-ecto...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-ecto/a07c5ff4-3519-444c-924e-2ffc362e5520n%40googlegroups.com.

Daniel Kukuła

unread,
Nov 18, 2025, 2:20:24 AMNov 18
to elixir-ecto
UUID is officially supported in postgres 18 https://www.postgresql.org/docs/current/datatype-uuid.html.
Should we revisit this ticket ?

José Valim

unread,
Nov 18, 2025, 5:11:39 PMNov 18
to elixi...@googlegroups.com
Yes, a pull request is welcome. Ecto.UUID can already represent them, so it may be a matter of being able to generate them. We can do so by implementing: Ecto.UUID.autogenerate(:v4 | :v7)

The API for autogenerating v7 in the schema will be a bit verbose, autogenerate: {Ecto.UUID, :autogenerate, [:v7]} but we can find ways to improve it later.



Daniel Kukuła

unread,
Nov 19, 2025, 2:59:27 AMNov 19
to elixir-ecto
I will try to create one this week.

Yordis Prieto

unread,
Nov 19, 2025, 4:13:45 PMNov 19
to elixir-ecto
Jose, would be prudent to align around `:uniq` or bring something to the Elixir core? I say this because I have observed far to many copy+pasting of Ecto.UUID module in far too many projects. By now, I wish some alignment happens across the ecosystem, especially for things are well established and in maintenance  mode such as some of the versions of the UUIDs
Reply all
Reply to author
Forward
0 new messages