denrepo

OracleStatistics

Gather statistics for a table or schema

Templates for gathering stats by hand. New statistics can change execution plans, so do this at a quiet time and know which plans matter.

Changes data

Not yet verified. How scripts are tested

This script changes the database. Check the names and values before you run it.
ora-gather-stats.sql
1-- One table and its indexes2EXEC DBMS_STATS.GATHER_TABLE_STATS(ownname => 'APP', tabname => 'ORDERS', cascade => TRUE, degree => 4);3 4-- Or only the stale objects in a schema5-- EXEC DBMS_STATS.GATHER_SCHEMA_STATS(ownname => 'APP', options => 'GATHER STALE');

Save it as ora-gather-stats.sql and run it with SQL> @ora-gather-stats.

Open in denrepo

More Oracle scripts: Statistics