Re:SQL Keys in Depth
by needusername on Tuesday January 09, 2018 @02:47AM
(#16104324)
What was your reason for not using database sequences?
Re:SQL Keys in Depth
by manigandham on Monday January 22, 2018 @02:16PM
(#16207042)
It was in my original post:
>> This means plenty of ID space, maintains rough numeric ordering, allows ID creation without a roundtrip for every insert, is easily portable across different databases, and produces unique IDs for every row in the database which greatly simplifies everything from caching to replication.
It's actually not Hi/Lo but similar. You can also add another column to that table if you want multiple "sequences" but we like to keep it simple and with bigints, you'll never realistically run out.
If you're using an ORM, you might need some extra work but most of the time they are smart enough to use an existing ID if the object already has one rather than try to get one from the database.