日期:2014-05-17  浏览次数:20959 次

一个sql查询20多秒,表最多才8000数据,求优化。
select a.*,b.*,to_char(a.launch_time,'yyyy-MM-dd hh24:mi:ss') l_time,e.ename,ed.dictname,d.pathname servicecatalogname,
      b.applicant,b.applicant_com,t.customerorganname,(select tmp.uname  from (select row_number() 
      over(partition by  m.instance_id order by m.task_log_id) gid,m.user_name uname,m.processinstid  from bpm_rtm_log_task m where
       m.process_id= 'cn.net.sinodata.sdbomc.itsm.workflow.genericservice.genericservice') tmp 
               where  tmp.gid=2 and a.processinstid = tmp.processinstid)
        from bpm_rtm_process_instance a,
             bpm_biz_itsm_genericservice b,
             itsm_dict_servicecatalog d,
             itsm_dict_gs_emergency e,
               eos_dict_entry ed,
               (select t.customeruserid,
               t.customerid,
               t.customerusername,
               t.customeruserorgan,
               t.customeruserphone2,
               t.customerusermail,
               t.customerusermsn,
               t.customeruserqq,
               t.createname,
               t.createtime,
               t.lastupdatename,
               t.lastupdatetime,
               t.helpdeskapplyrole,
               t.headername,
               t.headerid,
               b.customerorganname
               
          from itsm_dict_customer_user t, itsm_dict_customer_organ b
         where t.customeruserorgan = b.customerorganid(+)) t
        
       where a.processinstid = b.processinstid_
         and ed.dicttypeid = 'BPM_CFG_INST_STATUS'