Unique identifier (guid) as primary key in database design

后端 未结 5 1030
一向
一向 2020-12-02 19:13

Our data resides in a SQL Server 2008 database, there will be a lot queries and joinings between tables. We have this argument inside the team, some are arguing use of integ

5条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-02 19:46

    The major advantage of using GUIDs is that they are unique across all space and time.

    The main disadvantage to using GUIDs as key values is that they are BIG. At 16 bytes a pop, they are one of the largest datatypes in SQL Server. Indexes built on GUIDs are going to be larger and slower than indexes built on IDENTITY columns, which are usually ints (4 bytes).

    So they are a good solution for the cases where you need to merge data from several sources

    Source : http://www.sqlteam.com/article/uniqueidentifier-vs-identity

提交回复
热议问题