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少量索引,然后监控系统运行状态。
     
  • 相关阅读:
    限制转交订单-采购直接批准PO
    限制更改采购订单的供应商地点
    限制采购订单行数量的小数位
    加工费采购订单批准后禁止更改订单数量
    限制ITEM读取其它物料的物料描述
    采购订单限制订单“行号”过大的控制
    限制行表新增记录
    采购订单行需求时间必输
    报价单内,同一物料只允许一条行价格记录
    限制头表新增记录
  • 原文地址:https://www.cnblogs.com/erwadba/p/8041158.html
Copyright © 2011-2022 走看看