Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

305
Views
Using a UUID as a primary key for small SQL tables

I've read that UUIDs are typically not recommended as a primary key due to size and performance issues on large data sets.

However, would it be detrimental at all to use it on a few of the top level organizational tables? E.g. Organization or Branch, where there are only a handful of entries?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

I would recommend that you use serial instead of UUIDs. Why are integers preferable to UUIDs?

  • They occupy less space. This is a marginal consideration in the base table, but a bigger issue for foreign keys.
  • Integers are easier to read and remember.

In many databases, tables are physically ordered using primary keys. In such databases, new inserts on a UUID will almost always go "between" records, which is expensive. However, Postgres does not support clustered indexes so the underlying data is not ordered.

There are downsides to integers:

  • There are a finite number, although big ints pretty much solve that problem.
  • They encode order-of-insertion information. Actually, this can be a positive or a negative.

Other than space usage, I don't think there is much harm in using UUIDs on a static table. I strongly prefer integers, only resorting to UUIDs in situations where an integer would be difficult to calculate.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!