SQLSERVER查询速度很慢的一种解决方案
发布时间:2020-12-12 12:40:55 所属栏目:MsSql教程 来源:网络整理
导读:今天数据库一条查询语句很慢,如下 select a.fld1,sum(b.fld2),b.fld3 from table1 a left join table2 b on a.fld1=b.fld1 where 条件 group by a.fld1,b.fld3 测试得到,若不进行汇总,速度很快,但一旦加入汇总,则非常慢,修改如下: select a.fld1,b.fl
今天数据库一条查询语句很慢,如下 select a.fld1,sum(b.fld2),b.fld3 from table1 a left join table2 b on a.fld1=b.fld1 where 条件 group by a.fld1,b.fld3 测试得到,若不进行汇总,速度很快,但一旦加入汇总,则非常慢,修改如下: select a.fld1,b.fld2,b.fld3 into #t1 from table1 a left join table2 b on a.fld1=b.fld1 where 条件 select fld1,sum(fld2),fld3 from #t1 group by a.fld1,b.fld3 修改后速度非常快! (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |