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少量索引,然后监控系统运行状态。
     
  • 相关阅读:
    poj3669 广搜
    检索所有课程都选修的的学生的学号与姓名
    UVA10160 Servicing Stations
    uva11205 The broken pedometer 子集生成
    poj1101 the game 广搜
    poj3009 Curling 2.0 深搜
    poj 1564 Sum It Up 搜索
    HDU 2268 How To Use The Car (数学题)
    codeforces 467C George and Job(简单dp,看了题解抄一遍)
    HDU 2267 How Many People Can Survive(广搜,简单)
  • 原文地址:https://www.cnblogs.com/erwadba/p/8041158.html
Copyright © 2011-2022 走看看