求上面SQL优化,表的连接太多了
求下面SQL优化,表的连接太多了。
目前执行时间太长了3.563s 2000多条数据
------解决方案--------------------
你这一行莫名其妙啊
(select tasksuggestion from claimTasks where tasktype='ZJPD' and taskid=a.claimno) ptasksuggestion
你到底想要什么功能啊
------解决方案--------------------
select a.id,
a.claimno ,
a.username ,
a.appealreason ,
a.appealstatus,
a.appealResult,
b.tasksuggestion ,
b.updater ,
(select tasksuggestion from claimTasks where tasktype='ZJPD' and taskid=a.claimno) ptasksuggestion
from
appealInfo a ,
claimTasks b
where
b.tasktype='SSPD' and a.claimno=b.taskid and
appealFlag='1' and 1=1
order by id desc
目前执行时间太长了3.563s 2000多条数据
------解决方案--------------------
你这一行莫名其妙啊
(select tasksuggestion from claimTasks where tasktype='ZJPD' and taskid=a.claimno) ptasksuggestion
你到底想要什么功能啊
------解决方案--------------------
SELECT A.ID,
A.CLAIMNO,
A.USERNAME,
A.APPEALREASON,
A.APPEALSTATUS,
A.APPEALRESULT,
B.TASKSUGGESTION,
B.UPDATER,
-- (select tasksuggestion from claimTasks where tasktype='ZJPD' and taskid=a.claimno) ptasksuggestion
--以上相对占用资源,可改成decode的写法
DECODE(B.TASKTYPE, 'ZJPD', B.TASKSUGGESTION)
FROM APPEALINFO A, CLAIMTASKS B
WHERE B.TASKTYPE = 'SSPD'
AND A.CLAIMNO = B.TASKID
AND APPEALFLAG = '1'
AND 1 = 1
ORDER BY ID DESC