zoukankan      html  css  js  c++  java
  • oracle oltp系统索引使用监控

    1.使用语句监控应用帐号的normal索引

    select owner,
    'alter index ' || owner || '.'||'"'||index_name||'"'||' monitoring usage;'
    from dba_indexes
    where index_type = 'NORMAL'
    and uniqueness = 'NONUNIQUE'
    and owner in ( select username from dba_users t where t.account_status='OPEN' and t.default_tablespace not in ('SYSTEM','USERS','SYSAUX'));

    2.查询索引是否被使用
    select us.username 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,
           ou.end_monitoring
      from sys.obj$         io,
           sys.obj$         t,
           sys.ind$         i,
           sys.object_usage ou,
           sys.dba_users    us
     where us.username in
           (select username
              from dba_users t
             where t.account_status = 'OPEN'
               and t.default_tablespace not in ('SYSTEM', 'USERS', 'SYSAUX'))
       and io.owner# = us.user_id
       and i.obj# = ou.obj#
       and io.obj# = ou.obj#
       and t.obj# = i.bo#
       and decode(bitand(i.flags, 65536), 0, 'NO', 'YES') = 'YES'
       and decode(bitand(ou.flags, 1), 0, 'NO', 'YES') = 'NO';
    3.对已经使用的索引不进行监控
    select 'alter index '||owner||'.'||'"'||index_name||'"'||' nomonitoring usage;' from    
     (
     select us.username 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,
            ou.end_monitoring
       from sys.obj$ io, sys.obj$ t, sys.ind$ i, sys.object_usage ou, sys.dba_users us
      where us.username in ( select  username from dba_users t where t.account_status='OPEN' and t.default_tablespace not in ('SYSTEM','USERS','SYSAUX'))
        and io.owner# =us.user_id
        and i.obj# = ou.obj#
        and io.obj# = ou.obj#
        and t.obj# = i.bo#
     )  where used='YES' and monitoring='YES'  ;
    4.在一段时间之后。对不使用的索引进行invisible处理(目的:让CBO产生执行计划的时候,排除该索引)。
    select * from DBA_HIST_SQL_PLAN t where object_type like '%INDEX%' and object_name=<index_name>;  ---在invisible处理之前,检查该索引被哪些sql语句使用
    alter index <index_name> invisible;     ---对索引进行invisible处理。建议一次invisible少量索引,然后监控系统运行状态。
     
  • 相关阅读:
    [Knowledge-based AI] {ud409} Lesson 8: 08
    [Knowledge-based AI] {ud409} Lesson 7: 07
    [Knowledge-based AI] {ud409} Lesson 6: 06
    [Knowledge-based AI] {ud409} Lesson 5: 05
    [Knowledge-based AI] {ud409} Lesson 4: 04
    [Knowledge-based AI] {ud409} Lesson 3: 03
    [Knowledge-based AI] {ud409} Lesson 2: 02
    [Knowledge-based AI] {ud409} Lesson 1: 01
    [Software Development Process] {ud805} excerpt
    [Machine Learning for Trading] {ud501} Lesson 25: 03-05 Reinforcement learning | Lesson 26: 03-06 Q-Learning | Lesson 27: 03-07 Dyna
  • 原文地址:https://www.cnblogs.com/erwadba/p/8041158.html
Copyright © 2011-2022 走看看