码迷,mamicode.com
首页 > 其他好文 > 详细

关联查询之速度优化

时间:2017-04-06 17:03:13      阅读:179      评论:0      收藏:0      [点我收藏+]

标签:部分   优化   查询   关联表   关联查询   select   table   中间   into   

在有些关联表的数据比较多的情况,可以先筛选出一部分临时表。然后用临时表关联。优化速度从15s提升到3s

形式如

select * into #tempTable1 from Table1 where CurrentVersion_SID=@temp_versionID select * into #tempTable2 from Table2 where CurrentVersion_SID=@temp_versionID select * into #tempTable3 from Table3 where CurrentVersion_SID=@temp_versionID select * into #tempTable4 from Table4 where CurrentVersion_SID=@temp_versionID select * into #tempTable5 from Table5 where CurrentVersion_SID=@temp_versionID

中间各种关联查询

DROP TABLE #tempTable1 DROP TABLE #tempTable2 drop table #tempTable3 drop table #tempTable4 drop table #tempTable5 drop table #tempTable6 drop table #tempTable7

关联查询之速度优化

标签:部分   优化   查询   关联表   关联查询   select   table   中间   into   

原文地址:http://www.cnblogs.com/yanshaoxiong/p/6674297.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!