Thursday, June 27, 2013

How To Use Oracle Analyze / Gather Stats Proc

What we can analyze ?
We can analyze TABLE ,INDEX , Materialized Views, Clusters

How to Analyze ?
For detailed syntax use oracle sites.

For versions prior to 8i we can use analyze command as below

analyze table 'tablename' compute / estimate statistics

Examples will give more detailed understanding.

analyze table employees compute statistics

analyze table employees estimate statistics sample ( 10 percent / 100 rows)

analyze table employees delete statistics

To analyze index use below codes

analyze index indexname compute/delete/estimate statistics

The above all examples are for backward compatibility so if you have database installed > 8i please do not use above.

Insted use DBMS_STATS package.
HOwever if you need to collect statistics unrelated to optimizer then  we must use analyze statement.
for versions above 8i use the below.

exec dbms_stats.gather_table_status ('schema','tablename',cascade => true);

What happends in the background when above query is used ?
Oracle calculates number of rows, empty blocks,number of blocks below high water mark etc.
This is frequently used by DBA when query is taking more time than anticipated.

Posted By: Azhar Mulla

How To Use Oracle Analyze / Gather Stats Proc

Share:

Post a Comment

Facebook
Blogger

No comments :

Post a Comment

Follow Us

About Us

Like Us

© BIDW All rights reserved | Theme Designed by Seo Blogger Templates