【问题标题】:Oracle compressed index - How to determine which columns to compressOracle 压缩索引 - 如何确定要压缩哪些列
【发布时间】:2018-01-31 11:56:58
【问题描述】:

我想为 Oracle 应用程序表创建以下索引。

create index xxhr_api_transactions_idx1 on hr.hr_api_transactions (status, process_name, nvl(selected_person_id, -1)) compress 3

该表总共有 62421 行。状态列中有 10 个不同的值。 process_name 列中有 23 个不同的值。 selected_person_id 列中有 17419 个不同的值。 selected_person_id 列仅存在 43530 个值,其余为空(该人尚不存在的新员工工作流程)。

我的查询是这样的:

select *
from   hr.hr_api_transactions psth   
where  psth.process_name in ('TFG_HR_NEW_HIRE_PLACE_JSP_PRC', 'HR_NEW_HIRE_PLACE_JSP_PRC', 'HR_NEWHIRE_JSP_PRC')   -- TFG specific.
--and    nvl(psth.selected_person_id, -1) in (:p_person_id, -1)   -- 1118634
and    psth.status not in ('W', 'S')   -- Work in Progress, Saved For Later.

我的问题是我应该使用压缩 3 还是压缩 2?将selected_person_id 列与其总共62421 个中的17419 个不同值压缩(以及18891 个空值呢)是否更好?

【问题讨论】:

    标签: oracle indexing


    【解决方案1】:

    压力声明和建议是出了名的糟糕。这是您真正需要自己测试的任务之一。您可以通过检查DBA_SEGMENTS.BYTES 来测试压缩。

    压缩是 CPU 和大小之间的权衡。根据我的经验,基本索引压缩的 CPU 开销非常小。只要尺寸小几个百分点以上,我建议使用增加的压缩设置。

    使用下面的代码测试不压缩到compress 3的段大小。确保使用足够多的数据进行测试。 Oracle以extents分配空间;如果您使用较小的测试大小,您只会测量范围大小的开销。

    drop index hr.xxhr_api_transactions_idx1;
    create index xxhr_api_transactions_idx1 on hr.hr_api_transactions (status, process_name, nvl(selected_person_id, -1));
    select bytes/1024/1024/1024 gb from dba_segments where segment_name = 'XXHR_API_TRANSACTIONS_IDX1';
    
    drop index hr.xxhr_api_transactions_idx1;
    create index xxhr_api_transactions_idx1 on hr.hr_api_transactions (status, process_name, nvl(selected_person_id, -1)) compress 1;
    select bytes/1024/1024/1024 gb from dba_segments where segment_name = 'XXHR_API_TRANSACTIONS_IDX1';
    
    drop index hr.xxhr_api_transactions_idx1;
    create index xxhr_api_transactions_idx1 on hr.hr_api_transactions (status, process_name, nvl(selected_person_id, -1)) compress 2;
    select bytes/1024/1024/1024 gb from dba_segments where segment_name = 'XXHR_API_TRANSACTIONS_IDX1';
    
    drop index hr.xxhr_api_transactions_idx1;
    create index xxhr_api_transactions_idx1 on hr.hr_api_transactions (status, process_name, nvl(selected_person_id, -1)) compress 3;
    select bytes/1024/1024/1024 gb from dba_segments where segment_name = 'XXHR_API_TRANSACTIONS_IDX1';
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-01-07
      • 2017-06-01
      • 2014-10-06
      • 2010-09-20
      • 2014-08-08
      • 2019-04-13
      • 2014-09-24
      • 1970-01-01
      相关资源
      最近更新 更多