Tuesday, May 13, 2008

Gather Schema Stats

Gathering schema stats.


exec dbms_stats.gather_schema_stats (
ownname => 'SCHEMA NAME',
degree => dbms_stats.default_degree,
cascade => dbms_stats.auto_cascade,
options => 'GATHER AUTO'
);

OR

exec dbms_stats.gather_schema_stats (
ownname => 'SCHEMA NAME',
options => 'GATHER AUTO'
);

  • ownname : - Schema to analyze (NULL means current schema)
  • degree : - Degree of parallelism. The default for degree is NULL. Use the constant DBMS_STATS.DEFAULT_DEGREE to specify the default value based on the initialization parameters. DEFAULT_DEGREE (the system default value based on number of CPUs and initialization parameters) according to size of the object.
  • cascade :- Gather statistics on the indexes as well.Index statistics gathering is not parallelized. Use the constant DBMS_STATS.AUTO_CASCADE to have Oracle determine whether index statistics to be collected or not.
  • options :- Further specification of which objects to gather statistics for: GATHER AUTO: Gathers all necessary statistics automatically. Oracle implicitly determines which objects need new statistics, and determines how to gather those statistics. When GATHER
    AUTO is specified, the only additional valid parameters are ownname, stattab, statid, objlist and statown; all other parameter settings are ignored.