各位大神好,我是新人,下面這條陳述句用時較長:有什么建議能優化一下嗎??主要時間耗時在了子查詢的 u.userid = t.talkuserid 這一陳述句中。謝謝大家
select u.*,
(select deptname from EADEPT d where d.deptid = u.deptid) as deptname,
e.roleid,
e.authorizeid,
r.rolename,
c.suggestion as propose,
c.talkresultscore as talksituation,
c.psyexaminescores as checkpsyscore,
c.priexcepscores as checkpriscore,
c.psyexaminesum as checkpsysum,
c.priexcepsum as checkprisum,
c.psyexaminefinish as checkpsyfinish,
c.priexcepfinish as checkprifinish,
(select count(*) from talk_plan t inner join (select offenderid from offender_info) o on t.offenderid =o.offenderid
where u.userid = t.talkuserid AND
t.talktime >= 1451577600000
AND t.talktime <= 1483199999000
and t.state in (10, 20)) as countstalk,
(select count(*) from talk_plan t left join (select offenderid,zklb from offender_info) o on t.offenderid =o.offenderid
where t.state in (10, 20)
and u.userid = t.talkuserid
and (o.zklb in ('1', '2', '3') or appointsign = '1' or plantype = 4)) as alimportanttalk,
(select count(*) from talk_plan t left join (select offenderid,zklb from offender_info) o on t.offenderid =o.offenderid
where t.state in (10, 20, 1)
and u.userid = t.talkuserid
and (o.zklb in ('1', '2', '3') or appointsign = '1' or plantype = 4)) as alltalkcount
from eauser u
inner join (select roleid,authorizeid,userid from eauserauthorize) e on e.userid = u.userid
left join (select roleid,rolename from earole) r on e.roleid = r.roleid
left join checkuserscore c on u.userid = c.userid and c.checkscoretime =1483199999000
where 1 = 1
AND e.roleid in(10000120, 10000124, 10000126, 10000127, 10000128)
uj5u.com熱心網友回復:
求各位大神幫助uj5u.com熱心網友回復:
重點看看u.userid = t.talkuserid對應表的資料量,走的什么連接NL,HASH
走對應的索引了沒
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/116386.html
標籤:基礎和管理
上一篇:Oracle 的安裝
