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少量索引,然后监控系统运行状态。
     
  • 相关阅读:
    Nginx rewrite模块深入浅出详解
    一个ip对应多个域名多个ssl证书配置-Nginx实现多域名证书HTTPS
    nginx: [emerg] getpwnam(“www”) failed错误
    mysql5.7 启动报发生系统错误2
    obv15 实例6:如果K线柱过多,ZIG将发生变动,导致明显的OBV15指标被隐藏!
    obv15 案例4,待日后分析
    稳定
    教你识别指标骗局:以某家捕捞季节和主力追踪为例讲解
    C++ 语句
    C++ 表达式
  • 原文地址:https://www.cnblogs.com/erwadba/p/8041158.html
Copyright © 2011-2022 走看看