且构网

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

Azure SQL数据库中的主键

更新时间:2023-02-08 15:46:25

考虑以下内容

  1. Sql Azure需要群集索引来执行复制.注意,索引不必是唯一的. http://blogs.msdn.com/b/sqlazure/archive/2010/05/12/10011257.aspx

聚簇索引的优势在于,索引的范围查询是通过最少的寻道来***执行的.

The advantage of a clustered index is that range queries on the index are performed optimally with minimum seeks.

聚集索引的缺点是,如果以不按顺序的顺序添加数据,则可能会发生页面拆分,并且插入速度可能会相对较慢.

The disadvantages of a clustered index is that, if data is added in out of sequence order, page split may occur and inserts may be relatively slower.

参考以上内容,我建议以下内容

Referencing the above, I suggest the following

  1. 如果您拥有真实的密钥范围,则需要查询,例如日期,序号等
  1. If you have a real key range you need to query upon, for example date, sequential number etc
  1. 为该键创建一个(唯一/非唯一)聚集索引.
  2. 使用域生成的GUID创建附加的唯一索引.

  • 如果不存在真正的键范围,则只需使用域生成的GUID创建群集的唯一索引.(添加伪造的不需要的聚簇索引的开销比提供帮助更多的是障碍.)