• 《Oracle系列》Oracle 索引使用情况查看


    查询用户的索引

    select index_name,
           table_name,
           tablespace_name,
           index_type,
           uniqueness,
           status
      from dba_indexes
     where owner = '<用户名>';
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    查询用户的索引列

    select index_name,
           table_name,
           column_name,
           index_owner,
           table_owner
      from dba_ind_columns
     where table_owner = '<用户名>';
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    查看索引的各种初始化因子

    select index_name,
           table_name,
           tablespace_name,
           pct_free,
           pct_increase,
           initial_extent,
           next_extent,
           status
      from dba_indexes
     where owner = '<用户名>';
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10

    重建和维护索引

    alter index scott.emp_ename_idx rebuild
    pctfree 40
    storage (next 300k);
    
    • 1
    • 2
    • 3

    查看索引segment

    select segment_name, segment_type, tablespace_name, extents
      from dba_segments
     where owner = '<用户名>'
       and segment_type = 'INDEX';
    
    • 1
    • 2
    • 3
    • 4

    给索引添加相应的extent

    alter index scott.emp_ename_idx allocate extent;
    
    • 1

    回收索引端

    alter index scott.emp_ename_idx deallocate unused;
    
    • 1

    合并索引碎片

    alter index scott.emp_ename_idx coalesce;
    
    • 1

    联机重建索引

    alter index scott.emp_ename_idx rebuild online;
    
    • 1

    标识索引的使用情况

    1. 启用索引监控

    alter index emp_ename_idx monitoring usage;
    
    • 1

    生成启用索引监控语句:

    select 'alter index ' || owner || '.' || index_name || ' monitoring usage;'
      from dba_indexes
     where owner = '<用户名>';
    
    • 1
    • 2
    • 3

    2. 执行相关查询

    select ename, job, sal
      from scott.emp
     where ename like 'C%';
    
    • 1
    • 2
    • 3

    3. 查看索引是否使用

    select * from v$object_usage;
    
    • 1

    4. 禁用索引监控

    alter index emp_ename_idx nomonitoring usage;
    
    • 1

    生成禁用索引监控语句:

    select 'alter index ' || owner || '.' || index_name || ' nomonitoring usage;'
      from dba_indexes
     where owner = '<用户名>';
    
    • 1
    • 2
    • 3
  • 相关阅读:
    jQuery 第三章(语法+选择器+事件)
    刷爆力扣之检查数组对是否可以被 k 整除
    酸酸甜甜的杨梅数据库
    易用且免费的在线3D交互编辑器?
    ElasticSearch(ES)简单介绍
    附加:信息脱敏;
    再谈缓存雪崩、穿透、击穿
    web前端设计与开发期末作品 用DIV CSS技术设计的网上书城网页与实现制作(大一Web课程设计)
    开发跨境商城的意义
    Linux网络命令
  • 原文地址:https://blog.csdn.net/liuhuanping/article/details/133379213