TL;DR
Using random UUIDs as primary keys in SQLite can cause significant performance degradation due to how they disrupt B-tree balancing. Alternatives like UUID7 or different table structures may mitigate these issues.
Recent performance benchmarks reveal that using random UUIDs as primary keys in SQLite can cause up to 16 times slower insert speeds compared to integer primary keys, highlighting a significant drawback for developers relying on UUIDs for distributed systems.
Benchmarks conducted on June 5, 2026, demonstrate that inserting 10 million rows with UUID4 primary keys in SQLite is substantially slower than using integer primary keys, primarily due to the unordered nature of UUID4 which forces frequent re-balancing of the B-tree index.
The performance drop is linked to the way UUID4’s randomness causes the B-tree to constantly rebalance as new entries are inserted in random order, increasing disk I/O and CPU usage. In contrast, integer primary keys, which are sequential, allow for more efficient insertions.
Alternative UUID versions, such as UUID7, which are time-ordered, show improved performance but still lag behind integer keys. Using UUIDs with the implicit rowid (which is sequential) results in faster inserts but introduces other trade-offs like increased index overhead.
Why It Matters
This issue is relevant for developers designing distributed or scalable systems that rely on UUIDs for unique identification, as performance bottlenecks could impact application responsiveness and scalability.
Understanding the limitations of UUID primary keys in SQLite helps inform better database schema choices, especially in high-write environments where efficiency is critical.

Mastering SQLite with Python: From Basics to Advanced Techniques
As an affiliate, we earn on qualifying purchases.
As an affiliate, we earn on qualifying purchases.
Background
UUIDs are widely used in distributed systems for generating unique identifiers without coordination. However, their impact on database performance, especially in systems like SQLite that use B-tree structures, has been less understood until recent benchmarking efforts.
Previous assumptions suggested UUIDs are neutral in performance, but recent tests show that their randomness can cause significant inefficiencies in insert-heavy workloads.
“The unordered nature of UUID4 causes frequent re-balancing of the B-tree, leading to substantial performance degradation.”
— source author
“Switching to time-ordered UUIDs like UUID7 can improve performance but does not fully match the efficiency of integer primary keys.”
— database researcher
UUID7 generator for developers
As an affiliate, we earn on qualifying purchases.
As an affiliate, we earn on qualifying purchases.
What Remains Unclear
It remains unclear how widespread these performance issues are across different hardware configurations and database workloads. The benchmarks focus on bulk insert operations; effects on other operations like updates and deletes are still being studied.
high-performance primary key solutions for SQLite
As an affiliate, we earn on qualifying purchases.
As an affiliate, we earn on qualifying purchases.
What’s Next
Further research is expected to evaluate the performance of UUIDs in various real-world scenarios, including mixed read/write workloads and different table structures. Developers are advised to consider alternative primary key strategies for high-performance applications.

SQL That Scales: Queries, Indexes, and Performance You Can Prove
As an affiliate, we earn on qualifying purchases.
As an affiliate, we earn on qualifying purchases.
Key Questions
Why do UUIDs slow down SQLite insert performance?
Because UUID4’s randomness causes the B-tree to frequently rebalance during insertions, increasing disk I/O and CPU usage, which slows down overall performance.
Are there better alternatives to UUID4 in SQLite?
Yes, UUID7, which is time-ordered, reduces randomness and improves insert speeds, but it still may not match the efficiency of sequential integer keys.
Should I avoid UUIDs altogether in high-performance SQLite applications?
Not necessarily, but developers should be aware of the performance trade-offs and consider using time-ordered UUIDs or other primary key strategies for demanding workloads.
Does this issue affect other databases besides SQLite?
Yes, the performance implications of random UUIDs extend to other databases that use clustered indexes, especially those relying on B-tree structures.
Source: Hacker News