Skip to content

Commit 7b3f320

Browse files
committed
docs: finish v6 and 7 sections
1 parent 175d62b commit 7b3f320

File tree

1 file changed

+42
-10
lines changed
  • content/crutchcorn/posts/uuid-v6-8

1 file changed

+42
-10
lines changed

content/crutchcorn/posts/uuid-v6-8/index.md

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,20 @@
1010
}
1111
---
1212

13+
[In our first article explaining what UUIDs are](/posts/what-are-uuids), we explored a few different variants of UUID:
1314

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)
1425

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:
1727

1828
- [UUIDv6](#UUIDv6)
1929
- UUIDv1 but better for database indexes
@@ -28,26 +38,48 @@ Let's explore each of these UUID systems individually to understand them better.
2838

2939
# Create a Database Index with UUIDv6 {#UUIDv6}
3040

31-
https://blog.devgenius.io/analyzing-new-unique-identifier-formats-uuidv6-uuidv7-and-uuidv8-d6cc5cd7391a
41+
If you've worked much with UUIDv1 UUIDs, you'll see a pattern in the new UUIDv6 mechanism. If we look at the UUIDv1 example:
3242

33-
https://ietf-wg-uuidrev.github.io/rfc4122bis/draft-00/draft-ietf-uuidrev-rfc4122bis.html#name-uuid-version-6
43+
![A UUID broken down into "Low Time", a dash, "Mid Time", a dash, "Version", "High Time", a dash, "Variant", "Clock", a dash, and finally a "MAC Address". An example UUIDv1 might be "4e2b4d4c-92e8-11ed-86a8-3fdb0085247e"](../what-are-uuids/UUIDv1.svg)
3444

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:
3646

47+
![// TODO: Write](./UUIDv6.svg)
3748

49+
We can see how the order of the UUIDv6 is "just" a rearrangement of the bytes presented in a UUIDv1.
3850

39-
![// TODO: Write](./UUIDv6.svg)
51+
Why is this?
4052

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.
4254

43-
https://blog.devgenius.io/analyzing-new-unique-identifier-formats-uuidv6-uuidv7-and-uuidv8-d6cc5cd7391a
55+
> [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.
60+
61+
**Why not UUIDv6?**
4462

45-
https://ietf-wg-uuidrev.github.io/rfc4122bis/draft-00/draft-ietf-uuidrev-rfc4122bis.html#name-uuid-version-7
63+
[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):
4664

47-
https://ietf-wg-uuidrev.github.io/rfc4122bis/draft-00/draft-ietf-uuidrev-rfc4122bis.html#name-example-of-a-uuidv7-value
65+
> 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:
4872

4973
![// TODO: Write](./UUIDv7.svg)
5074

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.
82+
5183
# Make your own UUID rules with UUIDv8 {#UUIDv8}
5284

5385
https://blog.devgenius.io/analyzing-new-unique-identifier-formats-uuidv6-uuidv7-and-uuidv8-d6cc5cd7391a

0 commit comments

Comments
 (0)