![](/img/trans.png)
[英]How can I know if Oracle Diagnostics pack and the Oracle Tuning pack are installed with an Oracle installation?
[英]How can I reduce time by tuning Oracle SQL?
select grirno,grirdate
from grirmain
where grirno not in
(select grirno
from grir_pass
where ins_check is not null
and grirdate > '01-apr-2013'
)
and grirno is not null
and chkuser is not null
and grirdate >'01-apr-2013'
order by to_number(substr(GRIRNO,instr(GRIRNO,'/',1,1)+1,(instr(GRIRNO,'/',1,2)-instr(GRIRNO,'/',1,1)-1))) desc
我建議將查詢寫為:
select m.grirno, m.grirdate
from grirmain m
where not exists (select 1
from grir_pass p
where p.ins_check is not null and
p.grirdate > date '2013-04-01' and
p.grirno = m.grirno
) and
m.grirno is not null and
m.chkuser is not null and
m.grirdate > '2013-04-01'
order by to_number(substr(GRIRNO,instr(GRIRNO,'/',1,1)+1,(instr(GRIRNO,'/',1,2)-instr(GRIRNO,'/',1,1)-1))) desc;
您無能為力,但您可以在grir_pass(grirno, grirdate, ins_check)
上添加索引。 grirmain(grirdate, chkuser, grirno)
上的索引可能會有所幫助,但這不太可能——您的日期范圍非常廣泛。
筆記:
NULL
值not in
則not in
不會執行您期望的操作。 因此,強烈建議not exists
。date
關鍵字,因此日期常量不依賴於位置設置。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.