oracle如何加快语句执行,一条sql语句,执行太慢了,请问下如何优化

当前位置:我的异常网» Oracle开发 » 一条sql语句,执行太慢了,请问下如何优化

一条sql语句,执行太慢了,请问下如何优化

www.myexceptions.net  网友分享于:2013-02-24  浏览:76次

一条sql语句,执行太慢了,请教下怎么优化

一条sql语句,执行太慢了,请教下怎么优化。主要是里面有31条子查询,子查询里面又有联合查询,所以才比较慢。

请教一下改怎么优化啊?

语句如下,由于csdn限制发帖字数,我只写了到as   d7,其实后面还有一直要到as   d31,所以不慢才怪呢,但是不知道该怎么优化一下呢

select   HRM_KQMONTH.*,((select   case   when   ctype= '04 '   then   (select   symbol   from   hrm_setdata   where   TID   =   'QJ '   and   did=hrm_kqDay.qtype)   else   (select   symbol   from   hrm_setdata   where   TID   =   'KQ '   and   did=hrm_kqDay.ctype)   end   from   hrm_kqDay   where   KSTATUS= 'T '   and   to_char(KDate, 'yyyy ')= '2007 '   and   to_char(KDate, 'mm ')= '08 '   and   to_char(kDate, 'dd ')= '01 '   and   PersonID=HRM_KQMONTH.personid))   as   d1,((select   case   when   ctype= '04 '   then   (select   symbol   from   hrm_setdata   where   TID   =   'QJ '   and   did=hrm_kqDay.qtype)   else   (select   symbol   from   hrm_setdata   where   TID   =   'KQ '   and   did=hrm_kqDay.ctype)   end   from   hrm_kqDay   where   KSTATUS= 'T '   and   to_char(KDate, 'yyyy ')= '2007 '   and   to_char(KDate, 'mm ')= '08 '   and   to_char(kDate, 'dd ')= '02 '   and   PersonID=HRM_KQMONTH.personid))   as   d2,((select   case   when   ctype= '04 '   then   (select   symbol   from   hrm_setdata   where   TID   =   'QJ '   and   did=hrm_kqDay.qtype)   else   (select   symbol   from   hrm_setdata   where   TID   =   'KQ '   and   did=hrm_kqDay.ctype)   end   from   hrm_kqDay   where   KSTATUS= 'T '   and   to_char(KDate, 'yyyy ')= '2007 '   and   to_char(KDate, 'mm ')= '08 '   and   to_char(kDate, 'dd ')= '03 '   and   PersonID=HRM_KQMONTH.personid))   as   d3,((select   case   when   ctype= '04 '   then   (select   symbol   from   hrm_setdata   where   TID   =   'QJ '   and   did=hrm_kqDay.qtype)   else   (select   symbol   from   hrm_setdata   where   TID   =   'KQ '   and   did=hrm_kqDay.ctype)   end   from   hrm_kqDay   where   KSTATUS= 'T '   and   to_char(KDate, 'yyyy ')= '2007 '   and   to_char(KDate, 'mm ')= '08 '   and   to_char(kDate, 'dd ')= '04 '   and   PersonID=HRM_KQMONTH.personid))   as   d4,((select   case   when   ctype= '04 '   then   (select   symbol   from   hrm_setdata   where   TID   =   'QJ '   and   did=hrm_kqDay.qtype)   else   (select   symbol   from   hrm_setdata   where   TID   =   'KQ '   and   did=hrm_kqDay.ctype)   end   from   hrm_kqDay   where   KSTATUS= 'T '   and   to_char(KDate, 'yyyy ')= '2007 '   and   to_char(KDate, 'mm ')= '08 '   and   to_char(kDate, 'dd ')= '05 '   and   PersonID=HRM_KQMONTH.personid))   as   d5,((select   case   when   ctype= '04 '   then   (select   symbol   from   hrm_setdata   where   TID   =   'QJ '   and   did=hrm_kqDay.qtype)   else   (select   symbol   from   hrm_setdata   where   TID   =   'KQ '   and   did=hrm_kqDay.ctype)   end   from   hrm_kqDay   where   KSTATUS= 'T '   and   to_char(KDate, 'yyyy ')= '2007 '   and   to_char(KDate, 'mm ')= '08 '   and   to_char(kDate, 'dd ')= '06 '   and   PersonID=HRM_KQMONTH.personid))   as   d6,((select   case   when   ctype= '04 '   then   (select   symbol   from   hrm_setdata   where   TID   =   'QJ '   and   did=hrm_kqDay.qtype)   else   (select   symbol   from   hrm_setdata   where   TID   =   'KQ '   and   did=hrm_kqDay.ctype)   end   from   hrm_kqDay   where   KSTATUS= 'T '   and   to_char(KDate, 'yyyy ')= '2007 '   and   to_char(KDate, 'mm ')= '08 '   and   to_char(kDate, 'dd ')= '07 '   and   PersonID=HRM_KQMONTH.personid))   as   d7,(select   SortID   from   HRM_PERSONNEL   where   UserID   =   HRM_KQMONTH.UserID)   as   SortID   from   HRM_KQMONTH   where   1=1   and   KYEAR=2007   and   KMONTH=8   and   (KSTATUS=   '3 '   or   KSTATUS=   '2 ')

文章评论

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值