从Oracle 9i开始,可以监控Oracle索引的使用情况
具体方法如下:
alter index
对某个INDEX开启监控后,就可以观察该INDEX是否被使用:
select index_name,monitoring,used,start_monitoring,end_monitoring from v$object_usage;
INDEX_NAME MONITORING USED START_MONITORING END_MONITORING
----------------------------------------------------------------------------------------
AA NO YES 06/04/2006 12:02:38 06/05/2006 13:47:39
AA1 NO YES 06/04/2006 12:02:40 06/05/2006 13:47:39
要注意的是
由于V$OBJECT_USAGE视图限制了只显示当前用户下被监控的索引的情况
因此,通过其他用户登录数据库,将无法看到
如果要查看所有用户下的被监控的索引的情况,使用如下SQL:
select
u.name owner,
io.name index_name,
t.name table_name,
decode(bitand(i.flags, 65536), 0, 'NO', 'YES') monitoring,
decode(bitand(ou.flags, 1), 0, 'NO', 'YES') used,
ou.start_monitoring start_monitoring,
ou.end_monitoring end_monitoring
from sys.user$ u,
sys.obj$ io,
sys.obj$ t,
sys.ind$ i,
sys.object_usage ou
where i.obj# = ou.obj#
and io.obj# = ou.obj#
and t.obj# = i.bo#
and u.user# = io.owner#;
如果要取消对索引使用情况的监控,使用下列SQL:
alter index
要注意的是:索引使用情况监控,会增加部分系统开销。
source :http://space.itpub.net/13177610/viewspace-686392
[@more@]来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/7583803/viewspace-1046065/ ,如需转载,请注明出处,否则将追究法律责任。