PeopleSoft for the Oracle DBA
2 Paper 357
DDL
M
ODELS
&
%U
PDATE
S
TATS
A recent thread on Oracle-L
2
led me to look at how Oracle has changed the way that PeopleTools 8.48 collects Oracle Cost-
Based Optimiser statistics. It now uses DBMS_STATS instead of the ANALYZE command. This has also caused me to
reconsider some options for managing statistics for a PeopleSoft system.
Application Engine programs can collect Cost-Based Optimiser statistics on specific tables by calling the
%UpdateStats([,high/low]); PeopleCode macro. This uses one of two DDL models depending on whether the high or low
option is specified. However, these DDL models only exist for Oracle and DB2/MVS. %UpdateStats() has no function on
other platforms.
This was PeopleSoft’s platform generic solution (before their takeover by Oracle, and before Dynamic Sampling was available
in the Oracle database) to the very real problem that occurs when statistics on a working storage or reporting table, that is
emptied, repopulated and used during a batch process, do not accurately represent the content of the table and hence cause
the optimiser to choose an inappropriate execution plan. PeopleSoft provided a method of refreshing the statistics during the
process, and introduced new DDL models because each database platform would have its own command. However, this
approach relies upon developers to add the %UpdateStats() macro for every occasion where data has changed sufficiently to
require refreshing the statistics. Unfortunately, developers are not always best placed to make that decision. There are still
plenty of places in delivered PeopleSoft code where this macro could be usefully added.
Up to PeopleTools 8.47, PeopleSoft delivered two DDL models that used the ANALYZE command. The %UpdateStats(,high)
ran a full compute of the table:
ANALYZE TABLE [TBNAME] COMPUTE STATISTICS;
While %UpdateStats(,low) estimated statistics with the default sample size:
ANALYZE TABLE [TBNAME] ESTIMATE STATISTICS;
From PeopleTools 8.48, these DDL models now call the Oracle supplied PL/SQL package DBMS_STATS. The low option
collects statistics on a 1% sample.
DBMS_STATS.GATHER_TABLE_STATS (ownname=> [DBNAME], tabname=>[TBNAME], estimate_percent=>1,
method_opt=> 'FOR ALL COLUMNS SIZE 1',cascade=>TRUE);
While the high option estimates statistics with the automatic sample size.
DBMS_STATS.GATHER_TABLE_STATS (ownname=> [DBNAME], tabname=>[TBNAME], estimate_percent=>
dbms_stats.auto_sample_size, method_opt=> 'FOR ALL INDEXED COLUMNS SIZE 1',cascade=>TRUE);
So it would appear that PeopleSoft now follow the recommendations that Oracle have been making since version 8i of the
database to use DBMS_STATS instead of the ANALYZE command. This is certainly a step in the right direction. It also
makes good sense to use the automatic sample size. ESTIMATE_PERCENT defaults to
DBMS_STATS.AUTO_SAMPLE_SIZE from Oracle 10g. Previously it was NULL, which caused a full compute.
However, there are various problems:
• Oracle has swapped over the DDL models. I believe that the automatic sample size was supposed to be in the low
option, and a 100% sample was supposed to be used in the high, but there is a typo in the script.
• PeopleSoft have chosen to specify the METHOD_OPT as FOR ALL INDEXED COLUMNS SIZE 1. If you have
specified histograms on any of your columns, or generated them automatically with DBMS_STATS, the PeopleSoft
command will remove them from indexed columns and will leave any histograms on unindexed columns unchanged,
and potentially out of date.
o The default in Oracle 9i is FOR ALL COLUMNS SIZE 1. This removes all histograms on all columns,
although this is at least the same behaviour as the ANALYZE command.
2
http://www.freelists.org/archives/oracle-l/04-2007/msg00959.html