sql-server – 堆上的非聚簇索引与聚簇索引的性能
Counter Minimum Maximum Average Weighted --------- ------- ---------- ------- --------- RowCounts 144 69788 4648 - Cpu 15 764 56 0.01538 Reads 989 458467 30207 6.48490 Writes 2 1830 127 0.02694 Duration 0.2938 2512.1968 24.3714 0.00555
INSERT基准测试 基准测试的最后一部分是插入语句的执行. 插入堆/ clust(…) 这个堆基准测试的结果: rows reads CPU Elapsed ----- ----- ----- -------- 6 38 0ms 31ms
string str = @"insert into heap (group,currency,year,period,domain_id,mtdAmount,ytdAmount,amount,ytd_restated,restated,auditDate,auditUser) values"; for (int x = 0; x < 999; x++) { str += string.Format(@"(@id + {0},'EUR',2012,2,100,1000 + @id,1000,current_timestamp,'test'),",x); } str += string.Format(@"(@id,'CAD','test') ",1000); cmd.CommandText = str;
Counter Minimum Maximum Average Weighted --------- ------- ---------- ------- --------- RowCounts 1000 1000 1000 - Cpu 15 2138 25 0.02500 Reads 5212 7069 6328 6.32837 Writes 16 34 22 0.02222 Duration 1.6336 293.2132 4.4009 0.00440
这个clust基准的结果: rows reads CPU Elapsed ----- ----- ----- -------- 6 50 0ms 18ms
string str = @"insert into clust (group,1000); cmd.CommandText = str;
Counter Minimum Maximum Average Weighted --------- ------- ---------- ------- --------- RowCounts 1000 1000 1000 - Cpu 15 2403 21 0.02157 Reads 6810 8997 8412 8.41223 Writes 16 25 19 0.01942 Duration 1.5375 268.2571 6.1463 0.00614
结论 虽然使用集群& amp;访问表时会有更多的逻辑读取.非聚集索引(使用非聚簇索引时)性能结果为: > SELECT语句具有可比性 当然,我的基准测试对于特定类型的表以及非常有限的查询集非常有限,但我认为基于这些信息我们已经可以开始说,在表上创建聚簇索引几乎总是更好.
正如我们从增加的结果中看到的那样,有限测试的结论在每种情况下都不正确. 结果现在表明,受益于聚簇索引的唯一语句是update语句.使用聚簇索引的表上的其他语句约慢30%. 一些额外的图表,其中我绘制了堆与clust的每个查询的加权持续时间. 正如您所看到的,insert语句的性能配置文件非常有趣.尖峰是由一些数据点引起的,这些数据点需要更长的时间才能完成.
(编辑:晋中站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |