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
----慢------------------
(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
相关文章推荐
- Oracle 性能测试一:嵌套SQL的查询速度比较分析(初级)
- Oracle 性能测试一:嵌套SQL的查询速度比较分析(初级)
- oracle查看执行最慢与查询次数最多的sql语句
- sql语句查询经纬度范围 Oracle
- ORACLE分页查询SQL语句
- Oracle常用sql语句(二)之组函数、多表查询
- Oracle常用sql语句(三)之子查询
- oracle 查询重复数据并且删除, 只保留一条数据的SQL语句
- 如何使用Oracle查询并删除重复记录的SQL语句
- Oracle中的SQL基础查询语句--上(值得一看,例题非常多,也很清晰)
- sql语句中decode()函数的嵌套(oracle)
- Oracle分组查询结果SQL语句
- SQL语句执行顺序以及oracle基本查询优化
- 查询Oracle正在执行的sql语句
- oracle SQL语句之子查询
- 查询Oracle正在执行的sql语句
- 解析Oracle中sql语句的复杂查询
- Oracle常用sql语句(二)之组函数、多表查询
- Oracle clob类型的字段作为查询条件的sql语句写法