Free Online Developer Tools - ULID, UUID, NanoID, CUID, Snowflake ID, JWT Decoder, Base64, JSON Formatter & More

工具菜单

数据库写入测试

在浏览器中比较按时间排序的 ID(ULID 或 UUID v7)与随机 UUID v4 的 IndexedDB 写入速度。仅为本地测量,不是已发布的实验室结果。

Database Index Insertion Benchmark

Compare database index writing performance between Sequential IDs (ULIDs / UUID v7) and Random IDs (UUID v4) using IndexedDB.

Time-Sorted Sequential IDs (ULID / UUID v7)

Idle
总时间:—
平均写入速度:—

Unsorted Random IDs (UUID v4)

Idle
总时间:—
平均写入速度:—

Index Insertion Cost Curve

This graph plots transaction latency (ms) for consecutive database insert operations. Notice how random inserts trigger B-Tree page splits, causing latency spikes.

200ms150ms100ms50ms0ms
暂无数据,请运行基准测试以生成图表。
时间有序 ID
随机无序 ID

Why is there a performance difference?

Modern databases (such as IndexedDB, SQLite, PostgreSQL, and MySQL) store primary keys inside a B-Tree or B+Tree index structure. When you insert sequential IDs (ULIDs, UUID v7), new records are always appended to the right-most edge of the index, requiring zero re-balancing. In contrast, random IDs (UUID v4) must be inserted at arbitrary nodes, forcing the database to frequently split data pages, move physical sectors, and fragment the index, resulting in slow writes and high storage space overhead.

请作者喝杯咖啡,支持开发更多好用的工具