Monday, December 17, 2012

So, this might be old news to most of anyone that reads this, but, despite my sage experience, I got caught out by this today.

First things first:

11.2.0.2.6 on AIX with 4 node RAC cluster.

I have a scheduler job that runs once an hour to gather statistics in the database.  The jobs calls a home grown procedure which in turn calls DBMS_STATS.GATHER_TABLE_STATS.  When this job runs, it uses a combination of logic and TABLE_PREFS to control how statistics are gathered.  Ultimately, it sets and passes the various values to DBMS_STATS.GATHER_TABLE_STATS.  In this particular instance, I was changing the way the job sets METHOD_OPT from "FOR ALL COLUMNS SIZE " to instead just use the stored TABLE_PREFS.  Before my change, my procedure passed in METHOD_OPT.  After the change, METHOD_OPT was no longer passed relying on the TABLE_PREF setting for each individual table.

The problem:  After I changed my procedure, the job still ran with the old procedure.  Hence, statistics were gathered the old way and not using the TABLE_PREFS.  I knew this because my procedure logs the code it executes for each individual table.

The question: Why did my job not execute my new code?  Does it not just call the underlying procedure? (OWNER.PACKAGE.PROCEDURE).

The solution:  When you create and enable a job, Oracle must "store" the procedure code internally.  This is the only thing I can think of.  So, to get your new procedure to run, you must simply DISABLE and ENABLE the scheduler job.

After doing this, my job executed the way I expected.

Let me know if you have a different experience with this.