Home » RDBMS Server » Server Administration » Unnecessary Indices
Unnecessary Indices [message #52652] Mon, 05 August 2002 02:55 Go to next message
Andrew Ballance
Messages: 3
Registered: August 2002
Junior Member
OK you X$ gurus...
I inherited a system with some nasty indexing. This has now been completely revisited and I've virtually ended up creating one replacement index for every old one. But before I get rid of the old ones, I want to make sure that they are not being used.
Where can I tell what indexe are being used? It needn't necessarily tell me what SQL the usage was associated with, although that would be nice.
I've had a rummage around the v$ views, but to no avail. I can only imagine that somewhere in the quagmire of x$ views, there is something which will give me this information.
Thanks...
Re: Unnecessary Indices [message #52670 is a reply to message #52652] Mon, 05 August 2002 22:46 Go to previous message
Maaher
Messages: 7065
Registered: December 2001
Senior Member
What version are you running? Oracle9i has some built-in functionalities for that:
From the online documentation
Monitoring Index Usage
Oracle provides a means of monitoring indexes to determine if they are being used or not used. If it is determined that an index is not being used, then it can be dropped, thus eliminating unnecessary statement overhead.

To start monitoring an index's usage, issue this statement:

ALTER INDEX index MONITORING USAGE;

Later, issue the following statement to stop the monitoring:

ALTER INDEX index NOMONITORING USAGE;

The view V$OBJECT_USAGE can be queried for the index being monitored to see if the index has been used. The view contains a USED column whose value is YES or NO, depending upon if the index has been used within the time period being monitored. The view also contains the start and stop times of the monitoring period, and a MONITORING column (YES/NO) to indicate if usage monitoring is currently active.

Each time that you specify MONITORING USAGE, the V$OBJECT_USAGE view is reset for the specified index. The previous usage information is cleared or reset, and a new start time is recorded. When you specify NOMONITORING USAGE, no further monitoring is performed, and the end time is recorded for the monitoring period. Until the next ALTER INDEX ... MONITORING USAGE statement is issued, the view information is left unchanged.


For Oracle 8i (haven't verified for 8.0.x), you can issue the following SQL:
column owner format a20 trunc
column segment_name format a30 trunc
select distinct b.owner, b.segment_name
  from x$bh a, dba_extents b
 where
 b.file_id=a.dbarfil and
 a.dbablk between b.block_id and b.block_id+blocks-1 and
 segment_type='INDEX' and
 b.owner not in ('SYS','SYSTEM')


HTH,
MHE
Previous Topic: Windows XP
Next Topic: Database not starting up at startup
Goto Forum:
  


Current Time: Thu Sep 19 13:27:24 CDT 2024