Inspecting a rather critical database that is used by some software on my system, I found that one of the tables had a primary key on the column
Id is calculated using
checksum(newid()). This makes me feel uneasy; the
newids are guaranteed to be unique, but by applying the checksum (to a 32-bit integer, presumably for performance reasons?), you have some chance that you get a collision (with 1M rows in the table, I'd put that chance at around 1:4000, too much for my liking).
- Am I missing some crucial bit of information that says the above is actually okay?
- If not - what happens if the application tries to insert a new row into the table and the
checksum(newid())gives a primary key that already exists? Will my table blow up? Will the insert fail and leave it up to the application what to do with it?