Hacker News new | ask | show | jobs
by daleholborow 2964 days ago
There are additional arguments against using ints as ids in the database, if you ever plan to shard etc, as in "you'd still have to do a lot of work to migration data from an integer-key-based-system to something distributed". Various articles describe this. Keep in mind that many RDBMS systems now support some concept of a "sequential guid" - but keep in mind that they all store these in different ways. Plug: here's some code I pulled together, with links to the reference material, that will generate sequential guids for various databases:

https://github.com/daleholborow/iayos.sequentialguid

Speaking from personal experience, in theory I would always choose a (sequential)GUID as PK.. BUT... they ARE a pain in the bollocks to work with when you are developing and writing sql by hand to query data. E.g.

a) select * from Thingies where Id = 5

vs

b) select * from Thingies where Id = '12331-432Aafds-32424-df'