Tuesday, June 24, 2008

Monitoring Index Usage

1. Enable monitoring

ALTER INDEX [index_name] MONITORING USAGE;

2. View the infomation





col owner format a10
col index_name format a20
col monitoring format a10
col used format a6
select
u.name "owner",
io.name "index_name",
-- t.name "table_name",
decode(bitand(i.flags, 65536), 0, 'no', 'yes') "monitoring",
decode(bitand(nvl(ou.flags,0), 1), 0, 'no', 'yes') "used",
ou.start_monitoring "start_monitoring",
ou.end_monitoring "end_monitoring"
from
sys.obj$ io,
sys.obj$ t,
sys.ind$ i,
sys.object_usage ou,
sys.user$ u
where
t.obj# = i.bo#
and
io.owner# = u.user#
and
io.obj# = i.obj#
and
u.name not in ('sys','system')
and
i.obj# = ou.obj#(+)
and t.name='TAB';




Note: v$object_usage has to be queried by connecting as specific schema user.
The above query can show info for indexes under different schema.

3. Check whether the index is monitorred or not


SELECT index_name,
table_name,
monitoring,
used,
start_monitoring,
end_monitoring
FROM v$object_usage
WHERE index_name = [index_name]
and table_name= [table_name];

No comments: