What are the trade-offs of using a UUID versus an auto-incrementing integer as a primary key in a distributed system?

Last updated 3 July 2026

  • Auto-increment integers are small and keep B-tree inserts sequential, but need cross-node coordination that creates a bottleneck or single point of failure (and they are guessable).

  • UUIDs can be generated on any node without coordination, but are 16 bytes and random v4 values cause index page splits and poor cache locality.

  • Time-ordered IDs (UUIDv7, ULID, Snowflake) give coordination-free generation with sequential inserts, ideal for distributed writes.

  • https://planetscale.com/blog/the-problem-with-using-a-uuid-primary-key-in-mysql
  • https://bit-magic.medium.com/uuid-vs-auto-increment-primary-key-what-breaks-at-scale-d115ea9a4736
  • https://www.bytebase.com/blog/choose-primary-key-uuid-or-auto-increment/
  • https://www.bytebase.com/blog/how-to-choose-database-uuid/
  • https://docs.cockroachlabs.com/docs/stable/performance-best-practices-overview
  • https://www.cockroachlabs.com/blog/how-to-choose-a-primary-key/
  • https://www.cockroachlabs.com/blog/how-to-choose-db-index-keys/
  • https://dev.to/gigaherz/uuid-vs-ulid-vs-integer-ids-a-technical-guide-for-modern-systems-2afm
All SQL interview questions