您的位置:首页 > 数据库 > Oracle

oracle sql 语句嵌套子查询 查询速度慢

2017-09-13 10:12 651 查看
select

       ----慢------------------

        (select count(*)

          from (select pe.personid, pe.pgd_sheetid

          --------select * from WXU_NN_T_PG_PERSON t where t.flag != '4'  全表扫描  效率慢

                  from (select * from WXU_NN_T_PG_PERSON t where t.flag != '4') pe

                 group by pe.personid, pe.pgd_sheetid) y

         where y.pgd_sheetid = p.id) zyrs,

       ------快------------

       (select count(distinct t.personid)

          from WXU_NN_T_PG_PERSON t

         WHERE t.flag != '4'

           and t.pgd_sheetid = p.id) zyrs2

  from wxu_t_tc_import t1,

       wxu_t_tc_wc     t2,

       wxu_t_sdsq      t3,

       SYS_T_ORG       s,

       wxu_t_jxssq     t4,

       wxu_nn_t_pg     p

 where 1 = 1

   and t1.isdiscard = '0'

   and t1.id = t2.wxid(+)

   and t1.id = t3.TCID(+)

   and t1.id = t4.TCID(+)

   and (t1.zrgqid = s.id or (t1.zrgqid is null and t1.phzrgqid = s.id))

   and t1.id = p.tcid(+)

   and (t1.pipeistate = '2' or t1.pipeistate is null)

   and (t1.sgtype != '-1' or t1.sgtype is null)

   and (s.orgnum like '01021003%' or exists

        (select 0

           from wxu_t_tc_plan tp, SYS_T_ORG s1, wxu_t_tc_import_week tw

          where tw.id = t1.planid

            and tp.id = tw.planid

            and s1.id = tp.zycj_orgid

            and '01021003' like s1.orgnum || '%'))

   and t1.workdate >= '2017-08-12'

   and t1.workdate <= '2017-09-13'

   and t1.plantype != '2'
 order by t1.workdate, t1.seq
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  sql oracle select 查询慢