sql查询太慢了
hcp_pjjg表里面1000W条数据
统计10万条数据就要1分钟多
我给pjrq 和 zfbz建了索引, 但是查看执行计划,还走的全表扫描
希望大家给我指点一下
感谢!!
SQL:
select org.organcode,org.organgrade,jg.pjjg_dm,nvl(count(*),0) num, count(case when (jg.pjjg_dm > '3' and (jg.state = '0' or jg.state is null)) then 1 else null end) undisposed
from hcp_pjjg jg,org_relation_js r,org_organ org
where r.organcode = jg.swjg_dm
and r.parentorgancode = org.organcode
and jg.pjrq >= to_date('2020-12-05' ||' 00:00:00','yyyy-mm-dd hh24:mi:ss' )
and jg.pjrq <= to_date('2021-01-28' ||' 23:59:59','yyyy-mm-dd hh24:mi:ss' )
and jg.zfbz='N'
and org.parentorgancode = '14100000000'
group by jg.pjjg_dm,org.organgrade,org.organcode
order by org.organcode, org.organgrade
执行计划