Oracle 12c发布1个偏斜数据的直方图

时间:2018-02-13 10:57:05

标签: oracle histogram table-statistics

我们在12.1.0.2.0数据库上运行Oracle Applications 12.2.4。当我执行以下查询时:

select DBMS_STATS.GET_PREFS('AUTOSTATS_TARGET') as autostats_target,
       DBMS_STATS.GET_PREFS('CASCADE') as cascade,
       DBMS_STATS.GET_PREFS('DEGREE') as degree,
       DBMS_STATS.GET_PREFS('ESTIMATE_PERCENT') as estimate_percent,
       DBMS_STATS.GET_PREFS('METHOD_OPT') as method_opt,
       DBMS_STATS.GET_PREFS('NO_INVALIDATE') as no_invalidate,
       DBMS_STATS.GET_PREFS('GRANULARITY') as granularity,
       DBMS_STATS.GET_PREFS('PUBLISH') as publish,
       DBMS_STATS.GET_PREFS('INCREMENTAL') as incremental,
       DBMS_STATS.GET_PREFS('STALE_PERCENT') as stale_percent
from   dual

我明白了:

"AUTOSTATS_TARGET","CASCADE","DEGREE","ESTIMATE_PERCENT","METHOD_OPT","NO_INVALIDATE","GRANULARITY","PUBLISH","INCREMENTAL","STALE_PERCENT"
"AUTO","DBMS_STATS.AUTO_CASCADE","NULL","DBMS_STATS.AUTO_SAMPLE_SIZE","FOR ALL COLUMNS SIZE AUTO","DBMS_STATS.AUTO_INVALIDATE","AUTO","TRUE","FALSE","10"

但是当我跑步时:

select distinct histogram
from   user_tab_col_statistics

我只获得NONE

Oracle Application实例怎么可能没有需要直方图的偏斜表呢?或者我不理解这些设置?

另外,当您想要列上的直方图时,您是否必须使用method_opt => 'for all columns size skewonly'?如何为一列指定所有列的自动和倾斜?

我真的很喜欢直方图可能带来的潜在巨大速度提升,而且我很惊讶Oracle Applications默认情况下不提供此功能。每晚都会运行一个Gather Schema Statistics进程,可能是那个代码很旧而且它会杀掉任何dbms_stats调用吗?我专门创建了以下索引,它应该有一个直方图。

create index xxpqh_ss_trans_history_idx1 on hr.pqh_ss_transaction_history (process_name, nvl(selected_person_id, -1)) compress 1 tablespace apps_ts_tx_idx;

exec dbms_stats.gather_table_stats(ownname => 'HR', tabname => 'PQH_SS_TRANSACTION_HISTORY', cascade => true, method_opt => 'for all columns size skewonly');

1 个答案:

答案 0 :(得分:1)

Oracle Applications使用其自己的机制进行统计信息收集,您应该直接使用dbms_stats。

"只能使用FND_STATS或Gather Statistics并发请求收集Oracle电子商务套件统计信息。使用DBMS_STATS或不支持的ANALYZE命令收集统计信息可能会导致电子商务套件的次优执行计划"

有关建议,请参阅以下白皮书:

使用Oracle电子商务套件收集统计信息的最佳实践(MOS Note 1586374.1)