Skip to Main Content

Breadcrumb

Question and Answer

Tom Kyte

Thanks for the question.

Asked: October 05, 2003 - 4:17 pm UTC

Last updated: August 18, 2008 - 10:15 am UTC

Version: 9i

Viewed 10K+ times! This question is

You Asked

Tom,
When we use
alter index xxx monitoring usage
to start the process of monitoring and collecting index utilization, then we query v$object_usage to see if the index has been used.

What kind of DDL or DML will generate 'YES' in the 'USED' column in the view?

In another words, will 'select' statement be considered using that index? or only update....


thanks,

Cathy

and Tom said...


the column will be YES when the index is used to ACCESS the table -- be it due to an update, merge, delete or SELECT statement.

this column is not modified just because we "modified" an index entry -- that would happen with each and every insert.

this column is set when we USE the index to access the table.


Consider:

ops$tkyte@ORA920.US.ORACLE.COM> create table t ( x int,
2 constraint t_pk primary key(x) );

Table created.

ops$tkyte@ORA920.US.ORACLE.COM>
ops$tkyte@ORA920.US.ORACLE.COM> insert into t
2 select rownum
3 from all_objects
4 where rownum <= 100
5 /

100 rows created.

ops$tkyte@ORA920.US.ORACLE.COM>
ops$tkyte@ORA920.US.ORACLE.COM>
ops$tkyte@ORA920.US.ORACLE.COM> set echo off
Enter to continue

=================================================================

We'll enable monitoring on the index now

ops$tkyte@ORA920.US.ORACLE.COM>
ops$tkyte@ORA920.US.ORACLE.COM>
ops$tkyte@ORA920.US.ORACLE.COM>
ops$tkyte@ORA920.US.ORACLE.COM> select index_name,monitoring,used,start_monitoring,end_monitoring
2 from v$object_usage;

no rows selected

ops$tkyte@ORA920.US.ORACLE.COM>
ops$tkyte@ORA920.US.ORACLE.COM>
ops$tkyte@ORA920.US.ORACLE.COM> alter index t_pk monitoring usage
2 /

Index altered.

ops$tkyte@ORA920.US.ORACLE.COM>
ops$tkyte@ORA920.US.ORACLE.COM> select index_name,monitoring,used,start_monitoring,end_monitoring
2 from v$object_usage;

INDEX_NAME MONITORING USED START_MONITORING END_MONITORING
------------ ---------- ---- ------------------- -------------------
T_PK YES NO 10/05/2003 18:29:16

ops$tkyte@ORA920.US.ORACLE.COM>
ops$tkyte@ORA920.US.ORACLE.COM> set echo off
Enter to continue

=================================================================

Using RBO as we are by default, a count(*) won't use the index


ops$tkyte@ORA920.US.ORACLE.COM>
ops$tkyte@ORA920.US.ORACLE.COM>
ops$tkyte@ORA920.US.ORACLE.COM> set autotrace on explain
ops$tkyte@ORA920.US.ORACLE.COM> select count(*) from t;

COUNT(*)
----------
100


Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=CHOOSE
1 0 SORT (AGGREGATE)
2 1 TABLE ACCESS (FULL) OF 'T'



ops$tkyte@ORA920.US.ORACLE.COM> set autotrace off
ops$tkyte@ORA920.US.ORACLE.COM>
ops$tkyte@ORA920.US.ORACLE.COM> select index_name,monitoring,used,start_monitoring,end_monitoring
2 from v$object_usage;

INDEX_NAME MONITORING USED START_MONITORING END_MONITORING
------------ ---------- ---- ------------------- -------------------
T_PK YES NO 10/05/2003 18:29:16

ops$tkyte@ORA920.US.ORACLE.COM>
ops$tkyte@ORA920.US.ORACLE.COM>
ops$tkyte@ORA920.US.ORACLE.COM>
ops$tkyte@ORA920.US.ORACLE.COM> set echo off
Enter to continue

=================================================================

An insert won't either


ops$tkyte@ORA920.US.ORACLE.COM>
ops$tkyte@ORA920.US.ORACLE.COM>
ops$tkyte@ORA920.US.ORACLE.COM> insert into t values (-1);

1 row created.

ops$tkyte@ORA920.US.ORACLE.COM>
ops$tkyte@ORA920.US.ORACLE.COM> select index_name,monitoring,used,start_monitoring,end_monitoring
2 from v$object_usage;

INDEX_NAME MONITORING USED START_MONITORING END_MONITORING
------------ ---------- ---- ------------------- -------------------
T_PK YES NO 10/05/2003 18:29:16

ops$tkyte@ORA920.US.ORACLE.COM>
ops$tkyte@ORA920.US.ORACLE.COM>
ops$tkyte@ORA920.US.ORACLE.COM> set echo off
Enter to continue

=================================================================

But if we analyze the table, a count(*) will use the index
and we would have a record of it


ops$tkyte@ORA920.US.ORACLE.COM>
ops$tkyte@ORA920.US.ORACLE.COM>
ops$tkyte@ORA920.US.ORACLE.COM> analyze table t compute statistics
2 /

Table analyzed.

ops$tkyte@ORA920.US.ORACLE.COM>
ops$tkyte@ORA920.US.ORACLE.COM>
ops$tkyte@ORA920.US.ORACLE.COM> set autotrace on explain
ops$tkyte@ORA920.US.ORACLE.COM> select count(*) from t;

COUNT(*)
----------
101


Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=2 Card=1)
1 0 SORT (AGGREGATE)
2 1 INDEX (FULL SCAN) OF 'T_PK' (UNIQUE) (Cost=2 Card=101)



ops$tkyte@ORA920.US.ORACLE.COM> set autotrace off
ops$tkyte@ORA920.US.ORACLE.COM>
ops$tkyte@ORA920.US.ORACLE.COM>
ops$tkyte@ORA920.US.ORACLE.COM> select index_name,monitoring,used,start_monitoring,end_monitoring
2 from v$object_usage;

INDEX_NAME MONITORING USED START_MONITORING END_MONITORING
------------ ---------- ---- ------------------- -------------------
T_PK YES YES 10/05/2003 18:29:16

ops$tkyte@ORA920.US.ORACLE.COM>


Rating

  (22 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Very good example

A reader, May 18, 2004 - 2:39 pm UTC

Tom,
when I test it using one table in our application, I couldn' get the same result as you--the v$object_usage dictionary view doesn't show any information for that index which is enabled monitoring usage.

Please see bolow:

SQL> select index_name,table_name,column_name from all_ind_columns where table_name='INDIVIDUALS';

INDEX_NAME                     TABLE_NAME                     COLUMN_NAM
------------------------------ ------------------------------ ----------
XPKINDIVIDUALS                 INDIVIDUALS                    PTY_ID
XIF127INDIVIDUALS              INDIVIDUALS                    LANG_ID

2 rows selected.

SQL> select * from v$object_usage where table_name='INDIVIDUALS';

no rows selected

SQL> alter index core.XIF127INDIVIDUALS monitoring usage;

Index altered.

SQL> analyze table core.individuals compute statistics;

Table analyzed.


SQL> alter session set nls_date_format='DD-MON-YYYY hh24:mi:ss';

Session altered.

SQL> select table_name,last_analyzed from all_tables where table_name='INDIVIDUALS';

TABLE_NAME                     LAST_ANALYZED
------------------------------ --------------------
INDIVIDUALS                    18-MAY-2004 13:24:15

1 row selected.

SQL> set autotrace on explain
SQL> select count(*) from core.individuals where lang_id=451;

  COUNT(*)
----------
   1032694

1 row selected.


Execution Plan
----------------------------------------------------------
   0      SELECT STATEMENT Optimizer=CHOOSE (Cost=112 Card=1 Bytes=3)
   1    0   SORT (AGGREGATE)
   2    1     INDEX (FAST FULL SCAN) OF 'XIF127INDIVIDUALS' (NON-UNIQU
          E) (Cost=112 Card=158706 Bytes=476118)

SQL> set autotrace off
SQL> select * from v$object_usage where table_name='INDIVIDUALS';

no rows selected

Why I can't see it from dictionary view of v$object_usage? What could be wrong?

While I try to submit my question above, I see you have some
comment for how to submit question. So I try to use
create table/insert table to show the problem. But when I create a another small table based on that table's struction, I get the result as you--the v$object_usage dictionary view shows the information for that index which is enabled monitoring usage and table is using CBO.
:
CREATE TABLE TEST_IND
(
  PTY_ID                   NUMBER   NOT NULL,
  LANG_ID                  NUMBER,
  SALUTATION_TXT           VARCHAR2(65),
  TITLE_TXT                VARCHAR2(35),
  FIRST_NM                 VARCHAR2(35),
  MIDDLE_NM                VARCHAR2(35),
  LAST_NM                  VARCHAR2(35),
  NAME_SUFFIX_TXT          VARCHAR2(20),
  NAME_UNIQUENESS_NUM      NUMBER(2),
  EMPLOYER_NM              VARCHAR2(65),
  POSITION_AT_EMPLOYER_NM  VARCHAR2(65),
  BIRTH_DT                 DATE,
  DEATH_DT                 DATE,
  GENDER_CODE              VARCHAR2(5),
  MAIDEN_NM                VARCHAR2(80),
  LAST_UPDATE_DT           DATE                 NOT NULL,
  LAST_UPDATE_USER_ID      NUMBER               NOT NULL,
  DELETED_FLG              VARCHAR2(1)          NOT NULL
);

INSERT INTO TEST_IND ( PTY_ID, LANG_ID, SALUTATION_TXT, TITLE_TXT, FIRST_NM, MIDDLE_NM, LAST_NM,
NAME_SUFFIX_TXT, NAME_UNIQUENESS_NUM, EMPLOYER_NM, POSITION_AT_EMPLOYER_NM, BIRTH_DT, DEATH_DT,
GENDER_CODE, MAIDEN_NM, LAST_UPDATE_DT, LAST_UPDATE_USER_ID,
DELETED_FLG ) VALUES ( 
72678835, 451, 'Dear Sir or Madam', NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL
, NULL, NULL, NULL,  TO_Date( '10/29/2001 03:13:17 PM', 'MM/DD/YYYY HH:MI:SS AM')
, -1, 'N'); 

INSERT INTO TEST_IND ( PTY_ID, LANG_ID, SALUTATION_TXT, TITLE_TXT, FIRST_NM, MIDDLE_NM, LAST_NM,
NAME_SUFFIX_TXT, NAME_UNIQUENESS_NUM, EMPLOYER_NM, POSITION_AT_EMPLOYER_NM, BIRTH_DT, DEATH_DT,
GENDER_CODE, MAIDEN_NM, LAST_UPDATE_DT, LAST_UPDATE_USER_ID,
DELETED_FLG ) VALUES ( 
72678842, 451, 'Dear Miss Chuang', 'Miss', 'Christine', NULL, 'Chuang', NULL, 1, NULL
, NULL, NULL, NULL, NULL, NULL,  TO_Date( '10/30/2001 12:29:31 PM', 'MM/DD/YYYY HH:MI:SS AM')
, -1, 'N'); 

commit;


SQL> Alter table test_ind add constraint pk_test_ind primary key(pty_id);

Table altered.

SQL> CREATE INDEX XIFtest_ind ON TEST_IND
(LANG_ID);

Index created.

SQL> select * from v$object_usage where table_name='TEST_IND';

no rows selected

SQL> alter index XIFtest_ind monitoring usage;

Index altered.

SQL> select * from v$object_usage where table_name='TEST_IND';

INDEX_NAME                     TABLE_NAME                     MON USE START_MONITORING    END_MONITORING
------------------------------ ------------------------------ --- --- ------------------- -------------------
XIFTEST_IND                    TEST_IND                       YES NO  05/18/2004 13:59:18

1 row selected.
SQL> set autotrace on explain
SQL> 
SQL> select count(*) from TEST_IND where lang_id=451;


  COUNT(*)
----------
         2

1 row selected.


Execution Plan
----------------------------------------------------------
   0      SELECT STATEMENT Optimizer=CHOOSE
   1    0   SORT (AGGREGATE)
   2    1     INDEX (RANGE SCAN) OF 'XIFTEST_IND' (NON-UNIQUE)

SQL> set autotrace off
SQL> select * from v$object_usage where table_name='TEST_IND';

INDEX_NAME                     TABLE_NAME                     MON USE START_MONITORING    END_MONITORING
------------------------------ ------------------------------ --- --- ------------------- -------------------
XIFTEST_IND                    TEST_IND                       YES YES 05/18/2004 13:59:18

I have been confused about these 2 cases. Please help.

Thanks very much.

Pauline 

Tom Kyte
May 18, 2004 - 9:18 pm UTC

are you logged in as the owner of the index, someone pointed out that you need to be.

A reader, May 18, 2004 - 2:54 pm UTC

Tom,
The object 'INDIVIDUALS' actually is a materialized view.
Maybe it is the reason not showing the information from
v$object_usage even I enabled monitoring index usage for
its' index?

Pauline

A reader, May 19, 2004 - 10:44 am UTC

Thanks for the response and pointing out the problem. Actually I tried both ways by loging as my account and login as that index owner also. But when I queried V$object_usage, I always used my account
because I thought that user might not have privilege to query this dictionary view. Today when I login as that index owner to query V$object_usage, i see the entry there.

Pauline

Great information

Will, January 25, 2005 - 4:18 am UTC

Tom,

thanks for a great answer on index use: I am already applying what I've learned from this.

I'd like to ask if there is a similar method that would allow me to track usage of domain indexes. I'm using Oracle 9i.

Many thanks
Will

Tom Kyte
January 25, 2005 - 9:17 am UTC

ops$tkyte@ORA10G> alter index t_idx monitoring usage;
alter index t_idx monitoring usage
*
ERROR at line 1:
ORA-29871: invalid alter option for a domain index
 


not using this technique -- however, v$sql_plan...... you could query that and find all of the plans that reference the index .....  

How about monitoring TABLE usage

Robert, January 27, 2005 - 10:49 am UTC

Tom,

In 9.2 is there a similar method to monitor TABLE usage?
...Or would we just use V$SEGSTAT ?

Thanks,

Robert.

Tom Kyte
January 27, 2005 - 11:04 am UTC

v$segstat would be it.

or auditing.

one would hope however that the existence of a table indicates "it is used" or "it is mandatory".


Oh, REALLY?....

Robert, January 27, 2005 - 11:18 am UTC

Tom,

<QUOTE>
one would hope however that the existence of a table indicates "it is used" or
"it is mandatory".
<QUOTE>

Actually it is Oracle's FINAPPS (11i) I'm investigating! ;)

Thanks,

Robert.



Tom Kyte
January 27, 2005 - 11:22 am UTC

then it definitely falls into the "it is mandatory" category.

doesn't matter if it is not accessed, it is part of that black box that is a 3rd party application you are running.

it might not be accessed for a month, a year, whatever -- but it is part of the system.

Just like there are probably dictionary tables you don't access -- doesn't mean you could drop them or anything.



Just investigating

Robert, January 27, 2005 - 11:33 am UTC

Tom,

This Oracle Apps is a huge, complicated beast of which we are only using 5% or so.
I'm just investigating our system for table usage, etc. to better understand the activity that goes on.

Thanks,

Robert

Tom Kyte
January 27, 2005 - 11:35 am UTC

then the v$ view is definitely the place to look.

(it is a rather large schema isn't it...)

index usage

bipul, June 07, 2005 - 8:33 am UTC

Hi Tom.

v$object_usage shows if an index is used within a monitoring interval or not. But it doesn't show how many times it is used. What I am interested in finding out that how frequently an index is used?

Is there any other way without frequently querying the v$sql_plan table?

Thanks
bipul

Tom Kyte
June 07, 2005 - 8:53 am UTC

either that (v$sql_plan) or use the information in v$segment_statistics to see how much IO was performed against it which would be another measure of "how often used"

index

nee, March 16, 2006 - 3:42 am UTC

I have few indexes which I need to plan to drop but dont know the index names.
Do you think its good idea if I ON the monitoring for all indexes and which ever is not getting use then I drop those indexes?


Tom Kyte
March 16, 2006 - 11:40 am UTC

er?

you plan on dropping them
but you don't know what they are, what they are named?


Why not get a good idea what indexes are there, and why they are there?

yes you can enable monitoring, but the index might be there for a unique constraint (undroppable). The index might be used 4 times a year - you might drop it just because it isn't the end of quarter.

In short: be very careful here.

query v$object_usage from another schema

Harry Zhang, August 25, 2006 - 2:20 am UTC

Hi Tom,

How do I query v$object_usage from another schema?

SQL> conn perfstat
Enter password:
Connected.
SQL> desc ops$global.v$object_usage
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 INDEX_NAME                                NOT NULL VARCHAR2(30)
 TABLE_NAME                                NOT NULL VARCHAR2(30)
 MONITORING                                         VARCHAR2(3)
 USED                                               VARCHAR2(3)
 START_MONITORING                                   VARCHAR2(19)
 END_MONITORING                                     VARCHAR2(19)

SQL> select index_NAME, used from ops$global.v$object_usage order by used
  2  /
select index_NAME, used from ops$global.v$object_usage order by used
                                        *
ERROR at line 1:
ORA-00942: table or view does not exist



Thanks in advance 

Tom Kyte
August 27, 2006 - 8:17 pm UTC

tell me how ops$global created whatever v$object_usage is.

(but if you want sys.v_$object_usage, you would grant on that..) 

Harry Zhang, August 25, 2006 - 2:44 am UTC

Hi Tom,

Thank you for the useful information!
One more question:
When I do the analyze the index will be marked as used How do I avoid this? Thanks again!

SQL> select index_name, used from v$object_usage;

 

INDEX_NAME                     USE

------------------------------ ---

T2_ID_FK                       NO

 

SQL> EXEC DBMS_STATS.GATHER_SCHEMA_STATS( ownname=>'HARRY',METHOD_OPT => 'FOR ALL COLUMNS SIZE 1',ESTIMATE_PERCENT => NULL, CASCADE => TRUE )

 

PL/SQL procedure successfully completed.

 

SQL>  select index_name, used from v$object_usage;

 

INDEX_NAME                     USE

------------------------------ ---

T2_ID_FK                       YES

 

Tom Kyte
August 27, 2006 - 8:17 pm UTC

you won't.

clear 'USE' column, after analyze job

cosmin ioan, August 25, 2006 - 10:13 am UTC

hi Tom,
how does one clear the 'USE' column for index monitoring?

-- we have an regular analyze job which is creating a false positive on the USE column. I was looking for a way to clear this column, after analyze, a way other than updating the data dictionary table itself.. or is this the only method? :-)

thx,
Cosmin

Tom Kyte
August 27, 2006 - 8:35 pm UTC

it is a v$ table.  You will NOT be updating that.


turn it on, turn it off, turn it back on...

ops$tkyte%ORA10GR2> create table t ( x int );

Table created.

ops$tkyte%ORA10GR2> insert into t values ( 1 );

1 row created.

ops$tkyte%ORA10GR2> create index t_idx on t(x);

Index created.

ops$tkyte%ORA10GR2>
ops$tkyte%ORA10GR2> alter index t_idx monitoring usage;

Index altered.

ops$tkyte%ORA10GR2> select index_name, used from v$object_usage;

INDEX_NAME                     USE
------------------------------ ---
T_IDX                          NO

ops$tkyte%ORA10GR2> exec dbms_stats.gather_index_stats( user, 'T_IDX' );

PL/SQL procedure successfully completed.

ops$tkyte%ORA10GR2> select index_name, used from v$object_usage;

INDEX_NAME                     USE
------------------------------ ---
T_IDX                          YES

ops$tkyte%ORA10GR2> alter index t_idx nomonitoring usage;

Index altered.

ops$tkyte%ORA10GR2> alter index t_idx monitoring usage;

Index altered.

ops$tkyte%ORA10GR2> select index_name, used from v$object_usage;

INDEX_NAME                     USE
------------------------------ ---
T_IDX                          NO
 

Foreign Key index usage monitoring

Harry Zhang, August 28, 2006 - 1:59 am UTC

Hi Tom,

Is the foreign key indexes not marked monitored in the below case?

The tables c and p are child and parent tables.

---------- with fk index-------------------

SQL> alter index c_fk_i nomonitoring usage;

Index altered.

SQL> alter index c_fk_i  monitoring usage;

Index altered.

SQL> select index_name, used from v$object_usage;

INDEX_NAME                     USE
------------------------------ ---
C_FK_I                         NO

SQL> insert into c values(1);

1 row created.

SQL> declare
  pragma autonomous_transaction;  2
  3  begin
  delete from p where x = 2;  4
  5    commit;
end;  6
  7  /

PL/SQL procedure successfully completed.

SQL> select index_name, used from v$object_usage;

INDEX_NAME                     USE
------------------------------ ---
C_FK_I                         NO

---------- without fk index ------------------

SQL> drop index C_FK_I;

Index dropped.

SQL> select count(*) from c;

  COUNT(*)
----------
        11

SQL> insert into c values(1);

1 row created.

SQL> declare
  pragma autonomous_transaction;
  2    3  begin
  4    delete from p where x = 2;
  5    commit;
  6  end;
  7  /
declare
*
ERROR at line 1:
ORA-00060: deadlock detected while waiting for resource
ORA-06512: at line 4


 

Tom Kyte
August 28, 2006 - 9:03 am UTC

you did not use it as an access method to data.

If you were to use it with "on delete cascade", it would be different - then our recursive SQL will use the index as an access method and the monitoring would be tripped.

ops$tkyte%ORA10GR2> create table p ( x int primary key );
 
Table created.
 
ops$tkyte%ORA10GR2> create table c ( x references p ON DELETE CASCADE );
 
Table created.
 
ops$tkyte%ORA10GR2> insert into p values ( 1 );
 
1 row created.
 
ops$tkyte%ORA10GR2> insert into c values ( 1 );
 
1 row created.
 
ops$tkyte%ORA10GR2> commit;
 
Commit complete.
 
ops$tkyte%ORA10GR2>
ops$tkyte%ORA10GR2> create index c_idx on c(x) ;
 
Index created.
 
ops$tkyte%ORA10GR2> alter index c_idx monitoring usage;
 
Index altered.
 
ops$tkyte%ORA10GR2>
ops$tkyte%ORA10GR2> select used from v$object_usage where index_name = 'C_IDX';
 
USE
---
NO
 
ops$tkyte%ORA10GR2> delete from p where x = 1;
 
1 row deleted.
 
ops$tkyte%ORA10GR2> commit;
 
Commit complete.
 
ops$tkyte%ORA10GR2> select used from v$object_usage where index_name = 'C_IDX';
 
USE
---
YES
 

to Harry Zhang

Michel Cadot, August 28, 2006 - 9:29 am UTC

Your deadlock has no relation with monitoring.
If you execute your queries in 2 sessions, you'll see that the second one (delete from parent) is waiting on the first one (insert into child).

Why? Because when you insert into the child you get a row exclusive lock on the child table. When there is no index on the foreign key and a second transaction tries to delete a parent key, it wants to get a share lock on the child table (it is a share row exclusive if you have "on delete cascade") and so have to wait the first transaction ends.

In your case, as you are in the same session, the first transaction cannot end as it waits for the session transaction started with the "autonomous transaction" instruction which cannot end as it waits for the first to release its share lock... So deadlock.

When you have an index on the foreign key, then the second transaction does not need a share lock on the whole table but just a row share lock on the corresponding entry. So there is no wait and no deadlock if you are in the same session.

Michel

Foreign key index usage

Harry Zhang, August 28, 2006 - 10:41 pm UTC

Thanks Tom!
So for the foreign key indexes, we need to keep them although when the monitoring revealed they are not in use. And the only way to decide if we should keep them is when we need to do dml on parent tables then we need foreign indexes is it?

Tom Kyte
August 29, 2006 - 6:54 am UTC

when you delete from the parent OR you update the parent primary key. Correct.




clear 'USE' column, after analyze job

cosmin, August 31, 2006 - 6:12 pm UTC

"alter index t_idx nomonitoring usage"

ahh..."Elementary, My Dear Watson!"

...got tripped, I thought setting nomonitorining would have set the "USED" flag to "NO" as well :-)

I should have taken all the steps, through completion (issuing the "monitoring", afterwards)


How to enable and maintain history of this index's usage

Maulesh Jani, September 27, 2006 - 12:55 pm UTC

Hi,
How could i maintain the histry of this index-usage ?

Tom Kyte
September 27, 2006 - 3:58 pm UTC

define first what you personally mean by "history"

v$object_usage

Robert, May 21, 2007 - 11:33 am UTC


Tom,

We turned monitoring on our indexes 4 or 5 months ago.
There is something puzzling in v$object_usage
Several of our indexes are showing the following....

INDEX_NAME TABLE_NAME MON USE START_MONITORING END_MONITORING
------------------- ------------- --- --- ------------------- -------------------
XXXXX_BAT_DETL_N01 XXXXX_DETAIL NO YES 01/29/2007 13:37:21
XXXXX_BAT_DETL_N02 XXXXX_DETAIL NO YES 01/29/2007 13:37:21

Note that MONITORING=NO, but yet END_MONITORING is NULL ?!

How can this be?

Thanks,

Robert.


v$object_usage - remove indexes from there

Stefan Pastrilov, May 12, 2008 - 5:11 am UTC

Hello, I've read a lot but i couldn't find how to remove indexes from that view.
When I execute command "ALTER INDEX <INDEX_NAME> NOMONITORING USAGE", the corespondig column MONITORING comes 'NO' but then I want to remove the index from that table. Is that possible..or it's for history there ?
Thanks,
Best Regards,
Stefan Pastrilov
Tom Kyte
May 12, 2008 - 1:37 pm UTC

restart the database, then it'll go away. it is not a table, it is really a data structure in the SGA, you don't need to worry about it there - it is sort of "our data" at that point.

USE monitoring usage

Luciano Alvarenga, August 14, 2008 - 9:35 pm UTC

Hi Tom!
Please, i need your help

I executed this:
SQL> alter index SUPORTERJ.BCSUL_T_CEP_BAIRRO_IDX02 monitoring usage;
SQL> alter index SUPORTERJ.BCSUL_T_CEP_LOCALIDADE_IDX01 monitoring usage;

After i executed:
SQL> select * from v$object_usage

And didn't return results

select * from v$object_usage;
No rows selects

Tom Kyte
August 18, 2008 - 10:15 am UTC

log in as SUPORTERJ

A caveat on V$OBJECT_USAGE

Chris Newman, August 19, 2008 - 1:16 pm UTC

We ran into this; V$OBJECT_USAGE view uses context,
meaning you'll only see indexes owned by the user
who runs the query. Alex Gorbachev wrote an excellent workaround here:

http://www.oracloid.com/2006/05/vobject_usage-empty/

Cheers- Chris

SYS.OBJECT_USAGE

CRISTIANO FONSECA, May 20, 2009 - 10:28 am UTC

Hello All!

Try the following to see all all objects during a MONITORING without connect as the owner:

select o.owner
, o.object_name
, o.object_type
, ou.start_monitoring
, ou.end_monitoring
, decode(ou.flags,0,'NO',1,'YES',NULL) used
from sys.object_usage ou
, dba_objects o
where ou.obj# = o.object_id;

PS: You must connect as SYS or have SELECT grant on SYS.OBJECT_USAGE to see the results.

Best regards to all.

More to Explore

Performance

Get all the information about database performance in the Database Performance guide.