首页 > 数据库技术 > 详细

SqlServer性能优化索引(五)

时间:2016-12-29 07:40:45      阅读:344      评论:0      收藏:0      [点我收藏+]

导入表结构:

select * into ProductCategory from AdventureWorksDW2014.dbo.DimProductCategory
select * into Product from AdventureWorksDW2014.dbo.DimProduct

 

开启磁盘io:

set statistics io on
select EnglishProductName,StandardCost,Color,Size,Weight from Product
where size>‘M‘--0.189 io:251
set statistics io off

 技术分享

 

非聚簇索引:

创建的语句:
create nonclustered index nc_product_size on product(size)

 再次执行上面的查询代码(提高了三倍):

set statistics io on
select EnglishProductName,StandardCost,Color,Size,Weight from Product
where size>‘M‘   --0.054 io:19
set statistics io off

 技术分享

建立覆盖索引:

create nonclustered index nc_product_size1 on product(size) include(EnglishProductName,
StandardCost,Color,Weight)

再次执行上述语句:

set statistics io on
select EnglishProductName,StandardCost,Color,Size,Weight from Product
where size>‘M‘   --0.003 io:2
set statistics io off

 数据库会自动选择索引:

技术分享

技术分享

 

SqlServer性能优化索引(五)

原文:http://www.cnblogs.com/sunliyuan/p/6231085.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!