I noticed that you have Stripe-like IDs like `exp_...
# announcements
f
I noticed that you have Stripe-like IDs like
exp_3bwgdd13ks7m2a9z
and
met_3bwgdd13ks7gmy31
and I was curious: What’s your internal database? Do you use a SQL database and generate these random IDs and use them as primary keys?
We’re planning on migrating our database IDs from auto-incrementing integers to something like UUIDs, and I really like your approach so I would love to know a little about the implementation 😄
Did you also think about the performance implications of using string primary keys? Do you sort by dates or have specific indices? Also would love to hear your thoughts on that!
f
We're using MongoDB and the uniqid nodejs library. The prefixes are nice in the case there's a log entry or something that just has an id you can identify what it's from. We have separate date fields for sorting, although the string ids do generally increase since the first few bits are a timestamp.
The indexes for string ids take up more space, but performance is fine. It's also much easier to add sharding down the road as you scale than if you use auto increments.