如何监控Oracle索引的使用完全解析

来源:Oracle认证    发布时间:2012-11-12    Oracle认证视频    评论

2、oracle9i中如何确定索引的使用情况:

在oracle9i中,情况会简单得多,因为有一个新得字典视图V$SQL_PLAN存储了实际计划,这些计划用于执行共享SQL区中得语句。V$SQL_PLAN视图很类似与计划表,但V$SQL_PLAN使用ADDRESS和HASH_VALUE列 来识别语句, 而计划表使用用户提供得STATEMENT_ID来识别语句。下面的SQL显示了在一个oracle9i数据库中,由出现在共享SQL区中语句使用的所有索引。

      select object_owner, object_name, options, count(*)  from  v$sql_plan  where operation='INDEX'  and  object_owner!='SYS'  group by object_owner, object_name, operation, options  order by count(*) desc;

所有基于共享SQL区中的信心来识别索引使用情况的方法, 都可能会收集到不完整的信息。共享SQL区是一 个动态结构,除非能对它进行足够频繁的采样, 否则在有关索引使用的情况的信息被收集之前,SQL语句可 能就已经(因为老化)被移出缓存了。oracle9i提供了解决这个问题的方案,即它为alter index提供了一个monitoring usage子句。当启用monitoring usage 时,oralce记录简单的yes或no值,以指出在监控间隔 期间某个索引是否被使用。

为了演示这个新特性,你可以使用下面的例子:

  (a) Create and populate a small test table

  (b) Create Primary Key index on that table

  (c) Query v$object_usage: the monitoring has not started yet

  (d) Start monitoring of the index usage

  (e) Query v$object_usage to see the monitoring in progress

  (f) Issue the SELECT statement which uses the index

  (g) Query v$object_usage again to see that the index has been used

  (h) Stop monitoring of the index usage

  (i) Query v$object_usage to see that the monitoring sDetailed steps

    (a) Create and populate a small test table  create table products  (  prod_id number(3),  prod_name_code varchar2(5));    insert into products values(1,'aaaaa');  insert into products values(2,'bbbbb');  insert into products values(3,'ccccc');  insert into products values(4,'ddddd');  commit;    (b) Create Primary Key index on that table  alter table products  add (constraint products_pk primary key (prod_id));    (c) Query v$object_usage: the monitoring has not started yet  column

上一页12下一页

视频学习

我考网版权与免责声明

① 凡本网注明稿件来源为"原创"的所有文字、图片和音视频稿件,版权均属本网所有。任何媒体、网站或个人转载、链接转贴或以其他方式复制发表时必须注明"稿件来源:我考网",违者本网将依法追究责任;

② 本网部分稿件来源于网络,任何单位或个人认为我考网发布的内容可能涉嫌侵犯其合法权益,应该及时向我考网书面反馈,并提供身份证明、权属证明及详细侵权情况证明,我考网在收到上述法律文件后,将会尽快移除被控侵权内容。

最近更新

社区交流

考试问答