身份插入 - 性能
我有一种解决方案,在其中插入使用 GUID 而不是标识的行。 Guid 是用 c# 生成的。
我有另一个解决方案,其中表、索引等是相同的,但我使用身份而不是 GUID,并让 Sql 服务器生成它们。
在后一种情况下,我遇到了性能问题......有想法吗?
编辑
我真的很抱歉!我回到家安装了分析器,发现我正在比较苹果和梨......我这边很想念。我正在调用不同的sql。现在持续时间大致相同。
I have one solution where I insert rows where I use GUIDs instead of an Identity. The Guid is generated in c#.
I have another solution where the table, indexes etc are identical, but instead of GUIDs I use identities and let Sql-server generate them.
In the later case I get a performance issue.... Ideas?
EDIT
I really am sorry! I got home installed the profiler and saw that I was comparing apples and pears.... A big miss from my side. I was invoking different sql's. Now the duration is about the same.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
老实说,我希望性能问题与 guid 作为身份有关。当您使用 guid 时,如果您使用 newid() 而不是 newsequentialid(),则可能会出现页面拆分,因为新记录被插入到表的中间而不是末尾。
I honestly would expect the performance issue to be with the guid as the identity. When you use guids, if you use newid() instead of newsequentialid()you have the potential for page splits because of the new record being inserted into the middle of the table instead of the end.
为了帮助您解决问题,我们首先需要有关您的配置和性能指标的更多信息。
环境:
性能:
初始假设/推测:
在执行标识插入时,您可能会看到页面争用,因为索引中的前导列不断增加,竞争资源将是 B 树中的最后一个页面。
当然,这只是一个理论,直到我们从您那里得到更多详细信息之前。
In order to assist you with your question, we first need more information about your configuration and performance metrics.
Environment:
Performance:
Initial Hypothesis/Speculation:
You may be seeing page contention when performing identity inserts, as the leading column in the index is continually increasing, the contending resource will be the last page in the B-Tree.
This is of course only a theory until we have more details from you to work with.