You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/crutchcorn/posts/uuid-v6-8/index.md
+42-10Lines changed: 42 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,10 +10,20 @@
10
10
}
11
11
---
12
12
13
+
[In our first article explaining what UUIDs are](/posts/what-are-uuids), we explored a few different variants of UUID:
13
14
15
+
-[UUIDv1](/posts/what-are-uuids#UUIDv1)
16
+
- A machine's network card information + a timestamp
17
+
-[UUIDv2](/posts/what-are-uuids#UUIDv2)
18
+
-[It's a long story.](/posts/what-happened-to-uuid-v2)
19
+
-[UUIDv3](/posts/what-are-uuids#UUIDv3and5)
20
+
- Encode a string using MD5
21
+
-[UUIDv4](/posts/what-are-uuids#UUIDv4)
22
+
- Random UUID with effectively zero chance of producing the same number twice
23
+
-[UUIDv5](/posts/what-are-uuids#UUIDv3and5)
24
+
- UUIDv3 but more secure (uses SHA-1)
14
25
15
-
16
-
In addition, there are 3 additional types of UUIDs that are part of [a proposal to extend the UUID specification](https://datatracker.ietf.org/wg/uuidrev/about/):
26
+
Since that time, however, there [was an RFC that was accepted](https://www.ietf.org/archive/id/draft-peabody-dispatch-new-uuid-format-04.html) which added 3 new standard UUID types:
17
27
18
28
-[UUIDv6](#UUIDv6)
19
29
- UUIDv1 but better for database indexes
@@ -28,26 +38,48 @@ Let's explore each of these UUID systems individually to understand them better.

34
44
35
-
[Better for database indexes](](https://ietf-wg-uuidrev.github.io/rfc4122bis/draft-00/draft-ietf-uuidrev-rfc4122bis.html#section-6.10))
45
+
And compare it to the UUIDv6 example:
36
46
47
+

37
48
49
+
We can see how the order of the UUIDv6 is "just" a rearrangement of the bytes presented in a UUIDv1.
38
50
39
-

51
+
Why is this?
40
52
41
-
# More Standard Timestamps with UUIDv7 {#UUIDv7}
53
+
Well, this reorder allows multiple UUIDs to be sorted without having to parse them more in-depth. This helps makes databases of UUIDv6s easier to index as opposed to UUIDv1s while retaining the same base information.
> [Read more about the specifics of UUIDv6's sorting improvements in their draft RFC.](https://ietf-wg-uuidrev.github.io/rfc4122bis/draft-00/draft-ietf-uuidrev-rfc4122bis.html#section-6.10)
56
+
57
+
**Why UUIDv6?**
58
+
59
+
This is useful if your projects are already using UUIDv1 and you need a drop-in replacement with better database indexing.
[According to the RFC that introduces v6, v7, and v8](https://ietf-wg-uuidrev.github.io/rfc4122bis/draft-00/draft-ietf-uuidrev-rfc4122bis.html#name-uuid-version-6):
> Systems that do not involve legacy UUIDv1 SHOULD consider using UUIDv7 instead.
66
+
67
+
Let's explore why that is by taking a look at UUIDv7 next.
68
+
69
+
# More Standard Timestamps with UUIDv7 {#UUIDv7}
70
+
71
+
If we look at the byte order of UUIDv7 without any additional context, it might start to look familiar to UUIDv1 and v6:
48
72
49
73

50
74
75
+
However, if we note the `input data` section of this graph, the distinction becomes clear.
76
+
77
+
While UUIDv1, v6, and v7 all track time; v1 and v6 use "a count of 100- nanosecond intervals since 00:00:00.00, 15 October 1582" as their time-keeping mechanism.
78
+
79
+
Compare and contrast that to UUIDv7 utilizing the far more standard ["Epoch time", or, "Unix time"](https://en.wikipedia.org/wiki/Unix_time).
80
+
81
+
See, Epoch time is broadly used in nearly every computer system that needs to keep track of time. This makes v7 the superior choice over v6 and v1 for most usages, since encoding and decoding date logic becomes far more standardized.
0 commit comments