• alanspeckman (9/12/2012)


    Is it ever considered a best practice to use a UniqueIdentifier(GUID) as a primary key?

    ...

    Nowadays, it's not considered as the best practice. However, there are cases where the use of GUID's for PK is justified. Please note, usually in these cases other columns/keys would be selected for table clustered index (PK is not clustered).

    Old days, back when for insert operation Sybase/SQLServer used to lock whole pages, it was a practice sometime to use GUID's (or other random numbers) for PK and having clustered index on it for tables which were subject for often simultaneous inserts from concurrent users (lets say Call Centre systems for example).

    Also, note the Jeff M post, GUID's generated by SQL have higher probability of re-occurrence when generated by two different machines as they now Type-2 instead of Type-1. That will give you an idea where is justifiable to have GUID's as PK - it's only now viable option if you really need to generate key in application layer. There you can still generate type-1 GUIDs.

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]