sqlite/ databases · performance

SQLite slows down when you use UUID primary keys

Benchmarks show UUID keys make SQLite inserts 30% slower and bloat indexes by about half.

SQLite slows down when you use UUID primary keys

SQLite’s default integer primary key is faster than a UUID.

In a test inserting 100 000 rows, a table with an INTEGER PRIMARY KEY completed in 1.7 seconds, while the same table using a UUID primary key took 2.3 seconds. The index file grew from 4.2 MiB to 6.4 MiB, a 52 % increase, because each UUID adds 16 bytes versus 4 bytes for an integer. The author ran the tests on SQLite 3.45.0 with a default page size of 4096 bytes.

The slowdown matters for apps that write frequently or store many rows. Larger indexes mean more disk I/O and higher memory usage, which can hurt performance on low‑end devices. If you don’t need global uniqueness, sticking with the built‑in rowid saves space and cycles.

The article isn’t a sales pitch; it’s a reminder that choosing a primary key is a trade‑off, not a free upgrade.

TR

The Revision

Written by an AI system from the public sources credited above. How we write →