加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MsSql教程 > 正文

sql-server-2005 – newid()vs newsequentialid()有什么区别/利

发布时间:2020-12-12 16:19:51 所属栏目:MsSql教程 来源:网络整理
导读:在所有主键都是GUID的数据库中,使用newid()和newsequentialid()作为“默认值或绑定”的差异/含义和/或优缺点是什么. 我唯一不同的是,newid()创建一个新的随机GUID而不是newsequentialid()创建一个新的GUID基于表中的最后一个增量的方式. 解决方法 据了解,当您
在所有主键都是GUID的数据库中,使用newid()和newsequentialid()作为“默认值或绑定”的差异/含义和/或优缺点是什么.

我唯一不同的是,newid()创建一个新的随机GUID而不是newsequentialid()创建一个新的GUID基于表中的最后一个增量的方式.

解决方法

据了解,当您在DB中执行插入操作时,将以相对于表中其他PK的顺序插入.通过正常的指导,这可以在桌子的任何地方.一个newsequentialid()将始终添加到表的末尾.

因此插入物的性能得到改善.

This site解释了两种不同方法之间的区别和基准.

更新 – 引用的博客文章已被移动.该链接现在指的是web.archive.org链接.这是关键外卖:

Most striking is the number of writes required by the NEWID system function. This,coupled with the average page density of 69%,is evidence of the page splitting caused by the random distribution of inserts at the leaf level. As soon as a page fills up,it needs to be split into 2 pages of 50% each for the insert to complete. Not only has page splitting resulted in poor page density,it has fragmented the data pages quite badly (there is a 99% probability that the next data page is not next to the current one). In our tests the most likely place for a free page required for the page split is at the end of the table irrespective of where the row is being inserted. Therefore to read the rows in order the scan needs to keep jumping back and forth between widely distributed split pages,hence the appalling fragmentation.

– 斯特凡德尔马科

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读