- 爱易网页
 
                        - 
                            Oracle教程
 
                        - 跪求解决sql耗费CPU过高的方法! 
 
                         
                    
                    
                    日期:2014-05-17  浏览次数:20971 次 
                    
                        
                         跪求解决sql消耗CPU过高的方法!!
1:sql语句:
select cl.id,
        cl.login_name,
        cl.staffId,
        null,
        (select count(tcl.id)
           from call_list_2011112800000656 tcl
          where tcl.task_fk = t.id
            and tcl.cl_handled_by_fk = cl.staffId
            and tcl.handled_grp_fk is null) totalcounts,
        GETCREYTIME('YYYY-MM-DD', cl.creyTime) creyTime,
        (select count(cl.id)
           from call_list_2011112800000656 tcl
          where tcl.task_fk = cl.id
            and tcl.cl_handled_by_fk = cl.staffId
            and tcl.handled_grp_fk is null
            and to_date('2012-03-22 00:00:00', 'yyyy-mm-dd hh24:mi:ss') <=
                tcl.called_time
            and to_date('2012-03-22 23:59:59', 'yyyy-mm-dd hh24:mi:ss') >=
                tcl.called_time
            and to_char(tcl.called_time, 'YYYY-MM-DD') = cl.creyTime
            and tcl.status_fk = '4') jxcounts,
        (select count(cl.id)
           from call_list_2011112800000656 tcl
          where tcl.task_fk = cl.id
            and tcl.cl_handled_by_fk = cl.staffId
            and tcl.handled_grp_fk is null
            and to_date('2012-03-22 00:00:00', 'yyyy-mm-dd hh24:mi:ss') <=
                tcl.called_time
            and to_date('2012-03-22 23:59:59', 'yyyy-mm-dd hh24:mi:ss') >=
                tcl.called_time
            and to_char(tcl.called_time, 'YYYY-MM-DD') = cl.creyTime
            and tcl.status_fk = '3') yycounts,
        (select count(cl.id)
           from call_list_2011112800000656 tcl
          where tcl.task_fk = cl.id
            and tcl.cl_handled_by_fk = cl.staffId
            and tcl.handled_grp_fk is null
            and to_date('2012-03-22 00:00:00', 'yyyy-mm-dd hh24:mi:ss') <=
                tcl.called_time
            and to_date('2012-03-22 23:59:59', 'yyyy-mm-dd hh24:mi:ss') >=
                tcl.called_time
            and to_char(tcl.called_time, 'YYYY-MM-DD') = cl.creyTime
            and tcl.status_fk = '2'
            and tcl.call_result_fk = '成功') wccounts,
        (select count(tcl.id)
           from qnaire_result qr, call_list_2011112800000656 tcl
          where qr.responser_id = tcl.id
            and tcl.status_fk in ('2', '3', '4', '6')
            and tcl.task_fk = cl.id
            and tcl.cl_handled_by_fk = cl.staffId
            and tcl.handled_grp_fk is null
            and to_date('2012-03-22 00:00:00', 'yyyy-mm-dd hh24:mi:ss') <=
                tcl.called_time
            and to_date('2012-03-22 23:59:59', 'yyyy-mm-dd hh24:mi:ss') >=
                tcl.called_time
            and to_char(tcl.called_time, 'YYYY-MM-DD') = cl.creyTime
            and qr.result_status = 'GiveUp') Giveup,
        (select count(tcl.id)
           from qnaire_result qr, call_list_2011112800000656 tcl
          where qr.responser_id = tcl.id
            and tcl.status_fk in ('2', '3', '4', '6')
            and tcl.task_fk = cl.id
            and tcl.cl_handled_by_fk = cl.staffId
            and tcl.handled_grp_fk is null
            and to_date('2012-03-22 00:00:00', 'yyyy-mm-dd hh24:mi:ss') <=
                tcl.called_time
            and to_date('2012-03-22 23:59:59', 'yyyy-mm-dd hh24:mi:ss') >=
                tcl.called_time
            and to_char(tcl.called_time, 'YYYY-MM-DD') = cl.creyTime