用不了hash_jon,求高手。。

[复制链接]
查看11 | 回复8 | 2011-11-1 16:26:29 | 显示全部楼层 |阅读模式
我的执行计划:如图。
sql语句:select distinct t.fpatientid pId,

card.fcardno,

t.fcardseqno cardSeqNo,

t.fpatientno mzPNo,

pinfo.fname name,

hisbase.GetHzPYCap(nvl(pinfo.fname, ' ')) PY,

pinfo.fsex sex,

case

when pinfo.fbirthday is not null then

case

when floor((sysdate - pinfo.fbirthday) / 365.25) >= 18 then

floor((sysdate - pinfo.fbirthday) / 365.25) || '岁'

else

case

when floor((sysdate - pinfo.fbirthday) / 365.25) = 1 then

floor((sysdate - pinfo.fbirthday) / 365.25) || '岁' ||

(floor((sysdate - pinfo.fbirthday) / 365.25 * 12) -

floor((sysdate - pinfo.fbirthday) / 365.25) * 12) || '月'

else

floor((sysdate - pinfo.fbirthday) / 365.25 * 12) || '月' ||

floor(floor((sysdate - pinfo.fbirthday) / 365.25 * 12 *

30.4375) -

floor((sysdate - pinfo.fbirthday) / 365.25 * 12) *

30.4375) || '天'

end

end

else

pinfo.fage

end age,

t.flbh lbh,

t.freglsh regMzlsh,

t.fregno regNo,

to_char(rp.frpdate, 'YYYY-MM-DD HH24:MI:SS') examTime,

t.fpatienttype patientType,

t.fstate examState,

t.fkh kh,

k.fks ks,

t.fysh ysh,

p.fname ys,

1 dataSouce,

pinfo.FTELNUMBER ftele,

pinfo.FHOMEPLACE faddr,

t.faccountid,

0 ftid,

0 QueNo
from mzdoctor.Tpatient t
Left Join hisbase.tkssz k
On t.fkh = k.fkh
Left Join hisbase.tperson p
On t.fysh = p.ftybh
Left Join Mzcard.tpersoninfo pinfo
on t.FACCOUNTID = pinfo.FACCOUNTID
Left Join Mzcard.tcardinfo card
on t.FACCOUNTID = card.FACCOUNTID
left join mzdoctor.tprpmain rp
on t.fpatientid = rp.fpid
left join mzdoctor.tprpgrp rpgrp
on rp.frpid = rpgrp.frpid
left join hisbase.tdrugmode m
on rpgrp.fdrugmodecode = m.fdrugmodecode
left join mzdoctor.tprpdetail rpmx
on rp.frpid = rpmx.frpid
left join hisbase.tdrugcode d
on rpmx.fitemcode = d.fmcode
and rpmx.fitemflag = 0
where 1 = 1
and rp.frpdate > sysdate - 3 * 1440 / (24 * 60)
and (m.fisinjection = 1)
and (rp.Ffeestate = 2)
order by examTime desc

nested loops outer 太耗资源,我想改成hash join。请问怎么来修改?
或者哪位能给点优化的建议。

回复

使用道具 举报

千问 | 2011-11-1 16:26:29 | 显示全部楼层

回答你的问题之前,请问: 你是如何确定,在你的sql中,hash join比nest loop快的?
回复

使用道具 举报

千问 | 2011-11-1 16:26:29 | 显示全部楼层
/ 365.25 这种算法
回复

使用道具 举报

千问 | 2011-11-1 16:26:29 | 显示全部楼层
hash join和 nested loop
有什么区别啊?
回复

使用道具 举报

千问 | 2011-11-1 16:26:29 | 显示全部楼层
里面nested loop耗费太大,我就想用hash join来测试下会不会快些。
回复

使用道具 举报

千问 | 2011-11-1 16:26:29 | 显示全部楼层
〇〇 发表于 2012-2-17 18:44
/ 365.25 这种算法

啥意思
回复

使用道具 举报

千问 | 2011-11-1 16:26:29 | 显示全部楼层
jym2002 发表于 2012-2-21 17:06
啥意思

就是算年龄的办法有些奇怪
回复

使用道具 举报

千问 | 2011-11-1 16:26:29 | 显示全部楼层
〇〇 发表于 2012-2-21 17:10
就是算年龄的办法有些奇怪

。。。
没仔细看 LZ的sql
回复

使用道具 举报

千问 | 2011-11-1 16:26:29 | 显示全部楼层
求解中。。。有没有优化的建议。。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行