且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

SQL Server 中唯一标识符 ID 列上的聚集主键

更新时间:2023-02-07 14:07:20

GUID 因为它们实际上是随机值(这会破坏"聚集索引),所以它们对于性能来说很糟糕,而且它们对于索引来说很糟糕,因为条目较少适合单个页面/范围(SQL Server 术语).SQL Server 2005 引入了 newsequentialid() 这有助于解决第一个问题.

GUIDs as they are are terrible for performance since they are effectively random values (this "breaks" clustered index), and they are awful for indexes, since less entries fit on a single page/extent (SQL Server terms). SQL Server 2005 introduces newsequentialid() which helps solving first problem.