To `cuid()` or to `autoincrement()` that is the qu...
# orm-help
s
To
cuid()
or to
autoincrement()
that is the question... Assuming Postgres is being used, how do you normally go about choosing one for your id field? Imagine you need to explain the choice to a total DB n00b, how would you guide that person to make a choice? Thoughts?
r
Hey Simon šŸ‘‹ If you're using Postgres, it won't matter in terms of performance if you're using
uuid
or
int
with autoincrement. You can use whatever you prefer in this case actually. You can stick to
int
and be totally fine šŸ™‚
s
Thanks Ryan. I'm more considering the pro/cons of each from a systems architecture standpoint. Two things that jump out at me are: • Sequential IDs for public-facing stuff, in terms of users being able to increment the number to browse assets. Maybe that's one consideration • Per-table uniqueness vs global uniqueness, perhaps with regards to future migrations or table changes merging data or something (not too sure if this is a real-world concern or not)
As a counter-argument to #1, I guess cuid exposes the record creation time, whereas autoincrement integer does not. I guess it's a tradeoff with what, if any matters, when exposing IDs publicly in a URL or whatever.
w
so what did you choose in the end. im debating on the same thing