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

sql-server – 堆上的非聚簇索引与聚簇索引的性能

发布时间:2021-01-03 04:46:48 所属栏目:编程 来源:网络整理
导读:This 2007 White Paper较量了组织为聚簇索引的表上的单个select / insert / delete / update和range select语句的机能与组织为具有与CI表沟通的键列上的非聚簇索引的堆的表的机能. 凡是,聚簇索引选项在测试中示意更好,由于只必要维护一个布局,由于不必要书签

cmd.CommandText = "delete clust where group between @id and @id+1000";

  • 751 Rows have > 0 CPU and affect more than 0 rows
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

End of Update on 9 Mar 2011.

INSERT基准测试

基准测试的最后一部门是插入语句的执行.

插入堆/ clust(…)
值(…),
(…),
(……)

这个堆基准测试的功效:

rows  reads CPU   Elapsed 
----- ----- ----- -------- 
6     38    0ms   31ms

Update on 9 Mar 2011:

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;
  • 912 statements have > 0 CPU
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

End of Update on 9 Mar 2011.

这个clust基准的功效:

rows  reads CPU   Elapsed 
----- ----- ----- -------- 
6     50    0ms   18ms

Update on 9 Mar 2011:

string str = @"insert into clust (group,1000);

                    cmd.CommandText = str;
  • 946 statements have > 0 CPU
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

End of Update on 9 Mar 2011.

结论

固然行使集群& amp;会见表时会有更多的逻辑读取.非聚积索引(行使非聚簇索引时)机能功效为:

> SELECT语句具有可比性
>行使聚簇索引时,UPDATE语句更快
>行使聚簇索引,DELETE语句更快
>行使聚簇索引时,INSERT语句更快

虽然,我的基准测试对付特定范例的表以及很是有限的查询集很是有限,但我以为基于这些信息我们已经可以开始说,在表上建设聚簇索引险些老是更好.

Update on 9 Mar 2011:

正如我们从增进的功效中看到的那样,有限测试的结论在每种环境下都不正确.

功效此刻表白,受益于聚簇索引的独一语句是update语句.行使聚簇索引的表上的其他语句约慢30%.

一些特另外图表,个中我绘制了堆与clust的每个查询的加权一连时刻.

正如您所看到的,insert语句的机能设置文件很是风趣.尖峰是由一些数据点引起的,这些数据点必要更长的时刻才气完成.

End of Update on 9 Mar 2011.

(编辑:湖南网)

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

热点阅读