在有些关联表的数据比较多的情况,可以先筛选出一部分临时表。然后用临时表关联。优化速度从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