Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> [integers] can’t be distributed like UUIDs

They can, to an extent. The use of integers as a primary key has been a solved problem for quite some time, usually by either interleaving distribution among servers, or a coordinator handing chunks out.

If you mean enabling the ability to do joins across physical databases, my counter to that is it’s an unsupported method by any RDBMS, and should be discouraged. You can’t have foreign key constraints across DBs, and without those, I in no way trust the application to consistently do the right thing and maintain referential integrity. I’ve seen too many instances of it going wrong.

The only way I can see it working is something involving Postgres’ FDW, but I’m still not convinced that could maintain atomic updates on its own; maybe with a Pub/Sub in addition? This rapidly gets hideously complicated. Just design good, normalized schema that can maintain performance at scale. Then when/if it doesn’t, shard with something that handles the logic for you and is tested, like Vitess or Citus.



For example, imagine a client that can generate a UUID and at a later time save that to remote database.

Or imagine two separate databases that get merged.


> For example, imagine a client that can generate a UUID and at a later time save that to remote database.

DBs can return inserted data to you; Postgres and SQLite can return the entire row, and MySQL can return the last generated auto-increment ID.

> Or imagine two separate databases that get merged.

This is sometimes a legitimate need, yes, but it does make me smirk a bit since it goes against the concept of microservices owning their own domain (which I never thought was a great idea for most). However, it’s also quite possible to merge DBs that used integers. Depending on the amount of tables and their relationships (or rather, lack of formally defined ones) it may be challenging, but nothing that can’t be handled.

I mostly just question the desire to dramatically harm DB performance (in the case of UUIDv4) for the sake of undoing future problems more easily.


An example of the latter is when I worked with healthcare systems.

It was not uncommon for systems to merge datasets, either due to literal M&A or to share records and coordinate care.

A globally unique ID was important, despite not having a globally centralized system.


> DBs can return inserted data to you; Postgres and SQLite can return the entire row, and MySQL can return the last generated auto-increment ID.

Assuming you can+want to talk to a database right then.

The useful part of UUIDs is that they can be generated anywhere, locally, remotely, same DB, separate DB, online, offline, and never change.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: