News for hackers. Stuff that matters.
Re:Avoid UUIDv4 Primary Keys by dpark on Monday December 15, 2025 @01:35PM (#46278451)
This came up in the last two threads I read about uuidv7.

This is simply not a meaningful statement. Any ID you expose externally is also an internal ID. Any ID you do not expose is internal-only.

If you expose data in a repeatable way, you still have to choose what IDs to expose, whether that’s the primary key or a secondary key. (In some cases you can avoid exposing keys at all, but those are narrow cases.)

Re:Avoid UUIDv4 Primary Keys by konart on Monday December 15, 2025 @02:04PM (#46278826)
You have one ID as a primary key. It is used for building relations in your database.

The second ID has nothing to do with internal structure of your data. It is just another field.

You can change your structure however you want (or type of your "internal" IDs) and you don't have to worry about an external consumer. They still get their artificial ID.

Re:Avoid UUIDv4 Primary Keys by dpark on Monday December 15, 2025 @02:16PM (#46279008)
So what you meant is not to expose the primary key?

That’s a more reasonable statement but I still don’t agree. This feels like one of those “best practices” that people apply without thinking and create pointless complexity.

Don’t expose your primary key if there is a reason to separate your primary key from the externally-exposed key. If your primary key is the form that you want to expose, then you should just expose the primary key. e.g. If your primary key is a UUID, and you create a separate UUID just to expose publicly, you have most likely added useless complexity to your system.

Re:Avoid UUIDv4 Primary Keys by whynotminot on Monday December 15, 2025 @06:31PM (#46282510)
> create pointless complexity

My exact thought.

A lot else has failed in your system, from access control to API design, if this becomes a problem. Security by obscurity isn’t the answer.

If the only thing between an attacker and your DB is that they can’t guess the IDs you’re already in some serious trouble.