Using GUIDs in Primary Keys / Clusted Indexes

后端 未结 4 1291
孤独总比滥情好
孤独总比滥情好 2021-01-05 02:57

I\'m fairly well versed in SQL server performace but I constanly have to argue down the idea that GUIDs should be used as the default type for Clusterd Primary Keys.

<
4条回答
  •  醉话见心
    2021-01-05 03:18

    With such a low inserts per day, I doubt that page splitting should be a significant factor. The real question is how does 5,000 compares with the existing row count, as this would be the main information needed to decide on an appropriate initial fill factor to deffer splits.

    This said, I'm personally not a big fan of GUIDs. I understand that they can serve well in some contexts but in many cases they are just "in the way" [of efficiency, of ease of use, of ...]

    I find the following questions useful to narrow down on deciding whether GUID should be used or not.

    • Will the PK be shared/published ? (i.e. will it be used beyond its internal use within SQL, will applications need these keys in a somewhat persistent fashion? Will users somehow see these keys?
    • Could the PK be used to help merge disparate data sources ?
    • Does the table have a primary -possibly composite- made from column(s) in the data ? What is the size of this possible this key
    • How do the primary keys sort? If composite, are the first few columns selective ?

提交回复
热议问题