51Testing软件测试论坛

标题: sql server---sql语句优化 [打印本页]

作者: xg3396    时间: 2008-11-16 11:38
标题: sql server---sql语句优化
select distinct * from  (select b.branchcode,c.name,b.AgentCode,b.AgentName,  a.AlarmYM,a.AlarmBatchNo,a.ContNo,a.RiskCode,  a.StartVisitDate,   (select codename from ldcode where codetype='PreviewType' and a.AlarmIndexType=code ) as PreviewType, a.VisitResult,a.TreatResult,   (select Codename from ldcode  where  CodeType='instype' and a.TreatResult  = Code) as instype,a.TreatViews ,a.AlarmIndexType    from LACheckVisit a left outer join LAAgentInfo b on a.AgentCode=b.AgentCode  left outer join LABranchGroupInfo c on a.branchcode=c.AgentGroup    where 1=1   and exists (select 1 from lacompanyinfo where b.BranchCode=branchcode  and citycomcode='340400'  )  and a.AlarmYM='200810'  and a.AlarmBatchNo='1'  ) as result
执行该语句的时候,消耗cpu75%,哪位大哥帮忙分析一下,有优化的余地没? 谢谢
作者: xg3396    时间: 2008-11-16 11:39
小弟 在线等待,谢谢  十万火急




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2