UUID versions

167 views
Skip to first unread message

nilskp

unread,
Nov 21, 2011, 3:23:33 PM11/21/11
to java-uuid-ge...@googlegroups.com
I could probably spend some hours looking this up, but I thought I'd try here first, as people probably already know this.

How do I pick the UUID version I want to use, i.e. are there scenarios where one is better than another?

Are UUIDs generated from different versions more likely to clash, e.g. for UUID generation using different versions in the same system.

nilskp

unread,
Nov 21, 2011, 3:24:53 PM11/21/11
to java-uuid-ge...@googlegroups.com
I just realized that since the version number is embedded in the UUID, there's no chance of clashes between versions.

Tatu Saloranta

unread,
Nov 21, 2011, 4:06:48 PM11/21/11
to java-uuid-ge...@googlegroups.com
On Mon, Nov 21, 2011 at 12:24 PM, nilskp <nil...@gmail.com> wrote:
> I just realized that since the version number is embedded in the UUID,
> there's no chance of clashes between versions.

Correct, no clashes.

If performance was to matter, time/location based variant is the most
efficient, but it seldom matters all that much.
From theoretical perspective I think random-based variant is probably
the most sensible one, when used with SecureRandom(). However, many
find it intuitively hard to trust statistics that all but guarantee no
collisions, and find it better to use time/location variant.
Name-based variant is just hashing given String, so it can work too
but one might as well just use SHA-1 or other hashing mechanism.

-+ Tatu +-

nilskp

unread,
Nov 25, 2011, 11:46:38 PM11/25/11
to java-uuid-ge...@googlegroups.com
Thanks.
Reply all
Reply to author
Forward
0 new messages