jsp写的网页,查询非常慢,tomca日志如下:
1653','1605','970','1604','1663','1609','1608','1624','1625')) and ajjbxx.ndh*=
t_ajdjxx.ndh and ajjbxx.ajzh*=t_ajdjxx.ajzh and ajjbxx.ajbh*=t_ajdjxx.ajbh ) a
s ajjbxx, (select pid,max(case when convert(int,b.jflb)=0 then s else 0 end ) as
sumzl0,max(case when convert(int,b.jflb)=1 then s convert(int,b.jflb) else 0 en
d) as sumzl1, max(case when convert(int,b.jflb)=2 then s else 0 end) as sumzl2,
max(case when convert(int,b.jflb)=3 then s else 0 end ) as sumzl3,max(case when
convert(int,b.jflb)=4 then s else 0 end) as sumzl4,max(case when convert(int,b.
jflb)=5 then s else 0 end) as sumzl5,max(case when convert(int,b.jflb)=6 then s
else 0 end ) as sumzl6,max(case when convert(int,b.jflb)=7 then s else 0 e
nd ) as sumzl7, max(case when convert(int,b.jflb)=8 then s else 0 end ) as sumzl
8,max(case when convert(int,b.jflb)=9 then s else 0 end ) as sumzl9, max(case wh
en convert(int,b.jflb)=10 then s else 0 end ) as sumzl10,max(case when conver
t(int,b.jflb)=11 then s else 0 end ) as sumzl11,max(case when convert(int,b.jflb
)=12 then s else 0 end ) as sumzl12,max(case when convert(int,b.jflb)=13 then s
else 0 end) as sumzl13 from(select pid,jflb,sum(convert(int,jfje)) as s FROM (s
elect * from t_ssfxx where flag <>'1' or flag is null) GROUP BY pid) as b) as b
where b.pid=*ajjbxx.id Order By convert(numeric,(case when sign(charindex('-
'
------解决方案--------------------
------解决方案--------------------查询的数据有多少,有没有对SQL语句进行优化。
------解决方案--------------------这个要说的就多了,,,数据库理论上有七原则。。。
------解决方案--------------------应该是你的sql写的太复杂了,在数据库上建存储过程吧
最简单的sql优化方法是建立索引,并且使用索引
------解决方案--------------------索引顶