3 ms·
would you still keep a uniqueness constraint on the uuid/ulid column?
by perfmode 2y ago
would you still keep a uniqueness constraint on the uuid/ulid column?
- 9dev 2y agoI wouldn’t, it’s redundant for all intents and purposes unless you’re Google, which you are not. UUIDs/ULIDs provide strong uniqueness guarantees on their own.
- dxdm 2y agoYes, I'd keep a uniqueness constraint, because it prevents bugs from inserting the same value more than once. From concurrency issues to broken id generation, I've seen it happen before. So unless there are other considerations, having the database enforce uniqueness is a good thing in my book.
- kreetx 2y agoDepends on how many new U(U/L)IDs you insert, but when it's part of an index anyway then I personally would, as the performance penalty would be small (much smaller than anything else you do).
- vbezhenar 2y agoOf course. Index for this column is inevitable and with index, uniqueness basically free and protects from programmer errors.