170 points by emschwartz 1 day ago | 99 comments | View on ycombinator
gvkhna 43 minutes ago |
blopker 1 day ago |
For a single database, bigints are smaller and faster, with less footguns.
UUIDs can be nice for an opaque public ID, however I'd still prefer something like a Sqid for space and usability.
adityaathalye 1 day ago |
I read this post more as an illustration of the *value* of UUIDv7 as primary key, over integer primary keys, in lieu of minimal loss of read/write performance, and marginally more data on disk bloat.
SQLite's automatic integer rowID primary key is a no-brainer, when the SQLite application is local-only, such as application storage format (mobile and desktop). Or is never intended to grow beyond a single server instance. Basically, where each SQLite file is private to a singular instance of the application.
However, if there is even an outside chance of needing to cooperate across application instances, e.g. the minimal limit case of a personal knowledge base that should seamlessly sync across a person's devices, as well as a hosted service, then a high-quality sequential random ID starts to make a lot more sense. (No-brainer arbitrary table merges / splits / remerges, de-duplication, etc.)
Random ID primary key is a bad idea period, whether it be the UU kind or the SQ kind, or any other kind. As far as my DB knowledge goes, this class of ID destroys all tree-algorithms, and we are stuck with the fact that there is no practically better way, than an appropriate tree-structure, to group and organise a meaningful amount of data, efficiently and effectively.
jdthedisciple 1 day ago |
UUID v7 so far seems like the best solution if you want UUID benefits and ordering.
sedatk about 22 hours ago |
So, UUIDv4 as a PK on a clustered index can be perfectly feasible for cases where you want to avoid disclosing stuff and row insertion performance isn’t that important.
andersmurphy 1 day ago |
bambax 1 day ago |
ItsBob 1 day ago |
The Integer id is used for joins and looks ups and such but that's it. If I need to send anything to the frontend or outside of the app/DB then that's the UUID.
w10-1 1 day ago |
How much trouble does SQLite reysing rowid's actually cause?
ac50hz 1 day ago |
pyuser583 1 day ago |
dumbledorf 1 day ago |
yepyoukno 1 day ago |
kjgkjhfkjf 1 day ago |
cropcirclbureau 1 day ago |
michaelcampbell 1 day ago |
knightops_dev about 22 hours ago |
undefined about 23 hours ago |
wood_spirit 1 day ago |
But a Url62 as a url safe public id from the pk is simple and straightforward to use and comes with few risks of leak issues. Wish postgres had native base62 encoding for url62 now that it has uuidv7 native.