|
赫赫,不小心发现了Oracle 写的not exists 和 not in 了。
就在 大名鼎鼎 的statspack里面,?/rdbms/admin/sppurge.sql
这下估计很多人都有一个很好的实例了
[php]
普通的
delete from stats$statspack_parameter sp
where instance_number = :inst_num
and dbid = :dbid
and not exists (select 1
from stats$snapshot s
where s.dbid = sp.dbid
and s.instance_number = sp.instance_number);
经过tuning的
alter session set hash_area_size=1048576;
delete --+ index_ffs(st)
from stats$sqltext st
where (hash_value, text_subset) not in
(select --+ hash_aj full(ss) no_expand
hash_value, text_subset
from stats$sql_summary ss
where ( ( snap_id < :lo_snap
or snap_id > :hi_snap
)
and dbid = :dbid
and instance_number = :inst_num
)
or ( dbid != :dbid
or instance_number != :inst_num)
);
...
[/php]
大家有空可以测试一下效率,对比一下我提到的各种转换形式 |
|