hcp_pjjg表400W資料
查詢耗時3秒左右
select jg.pjqd_dm,
(select sjlymc from dm_hcp_sjly where sjly_dm = jg.sjly) sjly,
jg.pjjg_dm,
nvl(count(*),0) num
from hcp_pjjg jg,org_organ org, org_relation_js r
where r.organcode = jg.swjg_dm
and r.parentorgancode = org.organcode
and org.organcode = '14100000000'
and trunc(jg.pjrq) >= to_date('2020-11-01','yyyy-mm-dd' )
and trunc(jg.pjrq) <= to_date('2020-11-16','yyyy-mm-dd' )
and jg.zfbz='N'
group by jg.pjqd_dm,jg.sjly,jg.pjjg_dm
如果是下面這樣, 查詢耗時50ms左右
感覺可能是group by造成的
select jg.pjqd_dm,
jg.sjly,
jg.pjjg_dm
from hcp_pjjg jg,org_organ org, org_relation_js r
where r.organcode = jg.swjg_dm
and r.parentorgancode = org.organcode
and org.organcode = '14100000000'
and trunc(jg.pjrq) >= to_date('2020-11-01','yyyy-mm-dd' )
and trunc(jg.pjrq) <= to_date('2020-11-16','yyyy-mm-dd' )
and jg.zfbz='N'
怎么優化??
uj5u.com熱心網友回復:
uj5u.com熱心網友回復:
執行計劃
uj5u.com熱心網友回復:
1、在未 group by 之前的那個陳述句,3 秒只展示了第一頁資料,還是展示了所有的資料行 ?2、 and trunc(jg.pjrq) >= to_date('2020-11-01','yyyy-mm-dd' ) and trunc(jg.pjrq) <= to_date('2020-11-16','yyyy-mm-dd' )
這個陳述句,去掉 計算列的 邏輯。
3、 把兩張表完整的建表陳述句貼出來,索引情況也貼出來。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/223109.html
標籤:基礎和管理
