我唯一不同的是,newid()创建一个新的随机GUID而不是newsequentialid()创建一个新的GUID基于表中的最后一个增量的方式.
解决方法
因此插入物的性能得到改善.
更新 – 引用的博客文章已被移动.该链接现在指的是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.
– 斯特凡德尔马科