Improve Gather Stats in Oracle E-Business Suite

Posted in: Technical Track

One important aspect of a healthy Oracle database is database statistics. It’s the main data on which CBO feeds to generate good execution plans for SQLs. Implementing a periodic and consistent gather statistics procedure in Oracle E-Business Suite is every Applications DBA’s duty. But often I see that they are not set up properly to take advantage of the latest database features.  In the last couple of years, we have seen a lot of Oracle E-Business Suite customers upgrade their database from version 10gR2 to 11gR2, but often times they don’t review their procedure and take advantage of new 11gR2 features around gathering database statistics. This is like upgrading to a new Audi with blind spot assist & rear view camera, but driving it with them disabled.

One of the improved features of 11gR2 is the new DBMS_STATS.AUTO_SAMPLE_SIZE, which yields a significant reduction in the time it takes to collect highly accurate statistics.

Here is a quick demo. Here are the actual number of rows in the table


SQL> select count(*) from PAY_RUN_RESULT_VALUES;

COUNT(*)
———-
33222845

Gather Stats with 40% estimate, which most Oracle support analysts recommend for better stats. It took about 4 minutes to complete, with close to accurate stats, but not perfect.


SQL> exec fnd_stats.GATHER_TABLE_STATS( OWNNAME => 'HR', TABNAME=> 'PAY_RUN_RESULT_VALUES', PERCENT => 40, DEGREE => 4 );

PL/SQL procedure successfully completed.

Elapsed: 00:03:59.09

SQL> select num_rows from dba_tables where table_name = ‘PAY_RUN_RESULT_VALUES’;

NUM_ROWS
———-
33222068

Now Gather Stats with Auto Sampling enabled. Note that for the Gather Stats program to use 11g Auto Sampling feature, we either need to give the Estimate percent as Zero or leave it blank. This run completed in 1 min 18 seconds, about 30% of the time it took to run with an estimate percent of 40% and the estimated number of rows is an exact match to the actual number of rows in the table.


SQL> exec fnd_stats.GATHER_TABLE_STATS( OWNNAME => 'HR', TABNAME=> 'PAY_RUN_RESULT_VALUES', PERCENT => 0, DEGREE => 4 );

PL/SQL procedure successfully completed.

Elapsed: 00:01:18.86
SQL> select num_rows from dba_tables where table_name = ‘PAY_RUN_RESULT_VALUES’;

NUM_ROWS
———-
33222845

So why wait to take advantage of 11gR2 improved Auto sampling feature. Just configure your Gather Schema Statistics program to use the parameters below and chug along the freeway in your new Audi !!!

New Gather Stats Parameters in R12

email
Want to talk with an expert? Schedule a call with our team to get the conversation started.

About the Author

Vasu Balla’s colleagues call him “Eagle Eye” for a reason – his diverse technical background enables him to view his clients’ systems from a 360-degree angle, giving him a higher level of understanding. Vasu is well known for being approachable, and he truly enjoys helping people. Even former colleagues reach out to Vasu when they are really stuck on an issue. When he isn’t working, Vasu can be found in the kitchen trying new recipes.

5 Comments. Leave new

Good to know that AUTO_SAMPLE_SIZE can be used from FND_STATS.
Thanks,
Nitin R

Reply

one sting with this feature is – table monitoring should be enabled .. with my database around 10 % of tables are not enabled .. in such case , what would be the best choice..

Reply
Scott Benitez
June 25, 2015 4:27 pm

Hey Vasu, great article. Just actually setting this up for a new customer.
Hope you’re doing well :)

Reply

Hi Vasu,

Is setting estimate_percent to 0 will result in usage of auto_sample_size in 12.1.0.2 DB version as well? please advise.

Thanks,
Aditya

Reply

I think this is out dated. With new versions of ebs, oracle recommends leaving estimate percent to blank than 0.

Reply

Leave a Reply

Your email address will not be published. Required fields are marked *