100% ブラウザ内完結計算 • サーバーログ完全ゼロ • 即時実行
Curious Techie開発者ツールボックス
Regex & CryptographyIETF RFC 9562 (superseding RFC 4122)✓ クイック検索リファレンス表 (6 項目) • JA

UUIDバージョン別リファレンス(RFC 4122 / RFC 9562準拠)

UUID v1, v3, v4, v5, v7のビット構造・DBインデックス特性・用途比較

CT
Curious-Techie Engineering Team認証著者

Web Protocols & Security Architecture Research

公開日:
•
更新日:
•6 min read
準拠仕様:RFC 9110(IETF)
査読者: Curious-Techie Architecture Peer Review Group

概要と適用範囲

RFC 9562で改定されたUUID規格は、分散システムにおけるプライマリキー生成において、衝突なし・中央調整不要の一意性を保証します。

仕様一覧表&マトリクス

キーワード、コード番号、またはディレクティブ名で即時検索

キー / コード定義と詳細GEOセマンティック階層仕様と補足
UUIDv4
UUID Version 4 (Random)

Generated using cryptographically secure pseudorandom numbers; contains 122 bits of pure random entropy.

f47ac10b-58cc-4372-a567-0e02b2c3d479
●UUIDv4
↳UUID version
↳random identifier
↳cryptographic random token
RFC 9562 §5.4

The most popular UUID on the internet; completely stateless. Can cause B-tree fragmentation in heavy write databases.

UUIDv7
UUID Version 7 (Unix Epoch Time-Ordered)

Combines a 48-bit Unix timestamp in milliseconds with 74 bits of random entropy; monotonically sortable.

018f3a2c-9b1a-7b3e-8c4d-5e6f7a8b9c0d
●UUIDv7
↳UUID version
↳time-ordered identifier
↳database primary key optimization
RFC 9562 §5.7

The modern replacement for UUIDv1 and UUIDv4 for database primary keys. Completely prevents index page splits.

UUIDv1
UUID Version 1 (Gregorian Time + MAC)

Combines a 60-bit 100-nanosecond timestamp since 1582 with the hardware network card MAC address.

6ba7b810-9dad-11d1-80b4-00c04fd430c8
●UUIDv1
↳UUID version
↳hardware timestamp identifier
↳legacy MAC address bound ID
RFC 9562 §5.1

Privacy risk: leaks the server’s exact network MAC address and creation timestamp.

UUIDv5
UUID Version 5 (SHA-1 Name-Based)

Generated by hashing a namespace UUID and a name string using SHA-1; deterministic and repeatable.

886313e1-3b8a-5372-9b90-0c9aee199e5d
●UUIDv5
↳UUID version
↳name-based deterministic ID
↳SHA-1 idempotent namespace hash
RFC 9562 §5.5

Given the same namespace and string, always generates the exact same UUID. Preferred over UUIDv3 (which uses MD5).

Nil UUID
Nil UUID (Empty / Null)

Special-form UUID where all 128 bits are set to zero.

00000000-0000-0000-0000-000000000000
●Nil UUID
↳UUID special format
↳zero identifier
↳null object reference
RFC 9562 §5.9

Standardized placeholder for uninitialized or null UUID fields.

Max UUID
Max UUID (All Ones)

Special-form UUID where all 128 bits are set to binary one (0xFF).

ffffffff-ffff-ffff-ffff-ffffffffffff
●Max UUID
↳UUID special format
↳maximum identifier
↳boundary range sentinel
RFC 9562 §5.10

Used as an upper boundary sentinel in database range scans and indexing.

技術的な具体例とコード

Generating UUID v4 vs UUID v7 in Node.js

javascriptコードをコピー
import crypto from 'node:crypto';

// 1. UUID v4 (Native built-in)
const idV4 = crypto.randomUUID();
console.log('UUIDv4:', idV4);

// 2. UUID v7 (Unix millisecond timestamp + randomness)
function generateUUIDv7() {
  const bytes = new Uint8Array(16);
  crypto.getRandomValues(bytes);
  const now = Date.now();

  // Timestamp (48 bits)
  bytes[0] = (now / 0x10000000000) & 0xff;
  bytes[1] = (now / 0x100000000) & 0xff;
  bytes[2] = (now / 0x1000000) & 0xff;
  bytes[3] = (now / 0x10000) & 0xff;
  bytes[4] = (now / 0x100) & 0xff;
  bytes[5] = now & 0xff;

  // Version 7 (0b0111)
  bytes[6] = (bytes[6] & 0x0f) | 0x70;
  // Variant RFC 4122 (0b10)
  bytes[8] = (bytes[8] & 0x3f) | 0x80;

  return [...bytes].map((b, i) => 
    ([4, 6, 8, 10].includes(i) ? '-' : '') + b.toString(16).padStart(2, '0')
  ).join('');
}

UUIDv7 stores the 48-bit timestamp in the leading octets, allowing B-tree database indexes to append sequentially without page splits.

よくある質問(FAQ)

規格標準 FAQ

Why is UUIDv7 better than UUIDv4 for database primary keys?↓
UUIDv4 values are randomly distributed. Inserting random IDs into a PostgreSQL or MySQL B-tree index causes random disk writes and continuous page splits. UUIDv7 is chronologically sequential, resulting in up to 4x faster database write performance.
Authoritative Sourcing & Verification

References & Primary Sources

Every source below directly substantiates technical statements and protocol behaviors explained in UUIDバージョン別リファレンス(RFC 4122 / RFC 9562準拠). Curious-Techie prioritizes official Internet standards (IETF RFCs, W3C Recommendations, WHATWG specifications) and established security bodies (OWASP, NIST). Zero sponsored or secondary links.

  1. [1]IETFPrimary SpecificationRFC 9562 • Section 5 (UUID Versions 4, 7)
    Verified Primary Source
    Technical Claim Supported:

    Defines 128-bit UUID generation formats, replacing RFC 4122 and standardizing Version 4 (random) and Version 7 (Unix epoch time-ordered) identifiers.