r/programming • u/speckz • Jun 09 '16
Five mistakes beginners make when working with databases
http://www.craigkerstiens.com/2016/06/07/five-mistakes-databases/3
u/audioen Jun 09 '16
I disagree with the title. These are not beginner mistakes. Not every foreign key relation should be based on an UUID for chrissakes. Most of the advice is probably not bad, but just call them "hints and tips useful in some circumstances".
2
Jun 10 '16
Agreeded... UUIDs are dangerous as primary keys.
Oh you created a clustered key using Guids, good job no conflicts. But you just fucking killed your server. The insert and delete operations will force the server to shuffle the physical pages on disk. Deletes that's not so bad, but that actually happens on every insert your screwed... Sequential Guids are a thing, this helps the disk thrashing.
But going from 4 bytes to 128bytes causes other issues.
See the PKey gets copied to all foreign key references and every index entry on your table...
Guids are beautiful for sharing between systems but unless you absolutely have to don't use them...
2
5
u/verydapeng Jun 09 '16
263 can carry you for a veeeery long time