top | item 25302707

(no title)

opmac | 5 years ago

I was going to recommend this. No reason to use a special data type for the ID in your database unless you have some sort of actual constraints (like a 64 bit limit or something).

Instead just use a sequential integer (or UUID). When you need to expose it publicly, use something like hashids ^.

The main downside to straight UUIDs as primary key, is the B-tree used to store the primary key is larger if using UUIDs which are 16 bytes vs 8 for longs. In this case though the IDs are 8 bytes so this point is moot. Also the data is stored randomly on disk, which will make things like range queries slower if querying by ID (but you probably want a different index for querying anyway).

discuss

order

No comments yet.