Hacker News new | ask | show | jobs
by gnu8 1134 days ago
> They are awful as keys – being strings, comparisons are dramatically slower than with integers. And even if your database has a UUID type, it’s still worse because the identifier doesn’t fit into a machine word.

I’m just a bit confused, a UUID is made up of hexadecimal digits, so why would it be stored as a string? It’s also 128 bits long, so it should fit into two words, excluding whatever overhead the DBMS puts on the data type, which is really their problem to worry about.

2 comments

This is a non-uncommon mistake. People, such as the author, seem to think that the UUID is a hex string containing dashes, since that is the format that they most frequently see them represented.

You are correct that a UUID is a 128 bit identifier, and so, fits in 128 bits.

Apparently Stripe stores its keys as strings, though not the usual UUID string representation.
I'm like 90% sure Stripe started on MongoDB (may still be using Mongo?). That might have something to do with it.
A company which handles money as its primary business is using MongoDB? Hopefully the actual dollars are always handled in a “realSQL” DB with proper transaction isolation.
I recalled that specifically because I remember having the same reaction when I found it out (I think? I have a distinct memory of learning this) back in 2012 or something.