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少量索引,然后监控系统运行状态。
     
  • 相关阅读:
    bzoj 1017 魔兽地图DotR
    poj 1322 chocolate
    bzoj 1045 糖果传递
    poj 3067 japan
    timus 1109 Conference(二分图匹配)
    URAL 1205 By the Underground or by Foot?(SPFA)
    URAL 1242 Werewolf(DFS)
    timus 1033 Labyrinth(BFS)
    URAL 1208 Legendary Teams Contest(DFS)
    URAL 1930 Ivan's Car(BFS)
  • 原文地址:https://www.cnblogs.com/erwadba/p/8041158.html
Copyright © 2011-2022 走看看