Skip to content

Instantly share code, notes, and snippets.

View 0x1D-1983's full-sized avatar
💭
Somewhere between the gutter and the stars

Janos Kelemen 0x1D-1983

💭
Somewhere between the gutter and the stars
  • EDF Trading
  • Birmingham, UK
  • 09:20 (UTC +01:00)
  • LinkedIn in/0x1d
View GitHub Profile
@sdrapkin
sdrapkin / Avoid using Guid.CreateVersion7 in .NET.md
Last active May 3, 2026 15:29
Avoid using Guid.CreateVersion7 in .NET

.NET: Avoid using Guid.CreateVersion7

TL;DR: Guid.CreateVersion7 in .NET 9+ claims RFC 9562 compliance but violates its big-endian requirement for binary storage. This causes the same database index fragmentation that v7 UUIDs were designed to prevent. Testing with 100K PostgreSQL inserts shows rampant fragmentation (35% larger indexes) versus properly-implemented sequential GUIDs.

Guid.CreateVersion7 method was introduced in .NET 9 and is now included for the first time in a long-term-supported .NET 10. Microsoft docs for Guid.CreateVersion7 state “Creates a new Guid according to RFC 9562, following the Version 7 format.” We will see about that.

RFC 9562

RFC 9562 defines a UUID as a 128-bit/16-byte long structure (which System.Guid is, so far so good). RFC 9562 requires UUIDv7