INCREMENTAL_STALENESS means "how we decide if a partition's statistics are stale".
Its values can be either USE_STALE_PERCENT or USE_LOCKED_STATS:
USE_STALE_PERCENT - a partition/subpartition is not considered as stale if DML changes are less than the
STALE_PERCENT preference value.
USE_LOCKED_STATS - locked partitions/subpartitions statistics are not considered as stale, regardless of DML changes
NULL - this is the default value, meaning a partition or subpartition is considered as stale as long as it has any DML changes
STALE_PERCENT is the value that determine the percentage of rows in a table that have to change stats before the statistics are deemed stale and should be regathered. Default = 10%
I have used the following script to implement this in one of my 12.2 database.
The last preference (DEGREE) set has nothing to do with incremental statistics, but I have found that using the default degree of parallelism is a good setting for most databases
define owner = 'SCOTT';
define table_name = 'EMP';
BEGIN
dbms_stats.set_table_prefs('&&owner','&&table_name','INCREMENTAL','TRUE');
dbms_stats.set_table_prefs('&&owner','&&table_name','INCREMENTAL_STALENESS','USE_STALE_PERCENT, USE_LOCKED_STATS');
dbms_stats.set_table_prefs('&&owner','&&table_name','DEGREE','DBMS_STATS.DEFAULT_DEGREE');
END;
/
Verfiy your settings with the following script::
define owner = 'SCOTT';
define table_name = 'EMP';
set lines 200
set verify off
col "incremental" format a20
col "incr staleness" format a40
col "incremental level" format a10
col "stale percent" format a20
col "synopsis type" format a40
col "degree" format a30
col "granularity" format a20
select dbms_stats.get_prefs('INCREMENTAL','&&owner','&&table_name') "incremental",
dbms_stats.get_prefs('INCREMENTAL_STALENESS','&&owner','&&table_name') "incr staleness",
dbms_stats.get_prefs('INCREMENTAL_LEVEL','&&owner','&&table_name') "incremental level",
dbms_stats.get_prefs('STALE_PERCENT','&&owner','&&table_name') "stale percent",
dbms_stats.get_prefs('APPROXIMATE_NDV_ALGORITHM','&&owner','&&table_name') "synopsis type",
dbms_stats.get_prefs('DEGREE','&&owner','&&table_name') "degree" ,
dbms_stats.get_prefs('GRANULARITY','&&owner','&&table_name') "granularity"
FROM DUAL
/
Example output:
| incremental | incr staleness | incremental level | stale percent | synopsis type | degree | granularity |
|---|---|---|---|---|---|---|
| TRUE | USE_STALE_PERCENT, USE_LOCKED_STATS | PARTITION | 10 | REPEAT OR HYPERLOGLOG | 32 | AUTO |
Source: "Understanding Optimizer Statistics With Oracle Database 12c Release 2"
No comments:
Post a Comment