Beruflich Dokumente
Kultur Dokumente
September 2013
Disclaimer
The following is intended to outline our general product direction. It is intended for information purposes
only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code,
or functionality, and should not be relied upon in making purchasing decisions. The development, release,
and timing of any features or functionality described for Oracles products remains at the sole discretion
of Oracle.
Executive Overview......................................................................................... 1
Introduction ..................................................................................................... 1
FND_STATS Features .................................................................................... 2
History Mode ................................................................................................... 2
Gather Options ................................................................................................ 2
Histograms ...................................................................................................... 3
The AUTO Sampling Option ........................................................................... 4
Custom Scripts ................................................................................................ 4
When to Gather Statistics ............................................................................... 5
Cursor Invalidation .......................................................................................... 6
Locking Statistics ............................................................................................ 6
Database 11g Extended Statistics .................................................................. 7
Gathering Dictionary and Fixed Object Statistics ........................................... 8
Dictionary Statistics .................................................................................... 8
Fixed Statistics............................................................................................ 8
Global Temporary Tables................................................................................ 9
Temporary Tables ......................................................................................... 10
Incremental Statistics for Partitioned Tables................................................. 10
Improving the Collection Time ...................................................................... 11
Verifying Statistics ......................................................................................... 11
Standalone Patches ...................................................................................... 12
Performance Test Cases & Examples .......................................................... 13
1. Oracle 11g Extended Optimizer Statistics ........................................ 13
2. Incremental Statistics Gathering ....................................................... 17
3. Concurrent Statistics Gathering ........................................................ 20
Appendix A: Related Documentation ............................................................ 21
Whitepapers.............................................................................................. 21
My Oracle Support Knowledge Documents ............................................. 21
Blogs ......................................................................................................... 21
Appendix B: Package Specifications ............................................................ 23
Gather Table Statistics ............................................................................. 23
Gather Schema Statistics ......................................................................... 25
Executive Overview
This paper documents the best practices for gathering statistics. It focuses on new features
implemented in the FND_STATS package that can be applied to Oracle E-Business Suite 11i (11.5.10
and later) and Release 12.
Introduction
The Best Practices for Gathering Optimizer Statistics white paper provides an extensive overview of
the Oracle database statistics gathering process and is a useful precursor to this paper. It describes
several methods for collecting or setting statistics, however, the only supported methods with Oracle
E-Business Suite are either the Gather Statistics concurrent program or the FND_STATS package
(which is called by the Gather Statistics concurrent program). FND_STATS is a wrapper around the
DBMS_STATS package and provides several PL/SQL procedures for gathering statistics at the table,
schema, or database level. The FND_STATS package also supports histograms, table exclusions and
the new database 11G features such as extended stats, incremental stats gathering for partitioned tables
and concurrent stats gathering. Neither the DBMS_STATS package nor the now obsolete ANALYZE
command recognize those features and may result in suboptimal execution plans.
FND_STATS Features
This section provides a high-level view of how the FND_STATS package interacts with DBMS_STATS. While either the
Oracle E-Business Suite or DBMS_STATS will gather statistics for objects with stale or empty (missing) statistics, the
FND_STATS package implements the following features in Oracle E-Business Suite:
Supports collection of statistics for individual schemas, or for the entire Oracle E-Business Suite. To process all EBusiness schemas, pass the schema name as 'ALL'. DBMS_STATS does not have this functionality.
Histograms on columns designated in FND_HISTOGRAM_COLS. This contains a list of histogram columns that
Oracle Development have identified as essential.
The new GATHER_AUTO option combines the collection of statistics for tables with either stale or missing (empty)
statistics.
FND_STATS supports rerun-ability feature. If the Gather Schema Statistics concurrent program is used, FND_STATS
maintains the history of each submission. If a run stopped or interrupted, the next submission will resume from the point
of failure or termination. Starting with the 10g version of the database, DBMS_STATS 'GATHER AUTO' option with
Table Monitoring feature can be used to serve the purpose of rerun-ability.
FND_STATS_HIST stores historical information about the amount of time it takes the statistics gathering package
FND_STATS to gather statistics.
History Mode
The Gather Table Statistics program can optionally backup the existing statistics prior to gathering new statistics. If the value
of
backup
flag
parameter
is
BACKUP,
FND_STATS
exports
the
old
statistics
using
DBMS_STATS.EXPORT_TABLE_STATS prior to gathering new statistics and stores them in FND_STATTAB.
The history mode parameter controls the amount of history records that are created:
Last Run - History records are maintained only for the last gather statistics run. Each subsequent run will overwrite
the previous history record for the object. This is the default behavior.
Full - This mode does not overwrite previous historical information. History records are created for each new run and
are identified by the Request ID, which is generated automatically if one is not provided. If this mode is used, the
Purge FND_STATS History Records concurrent program should be run periodically to purge the FND_STATS_HIST
table.
None - This mode does not generate any history information and the run cannot be restarted.
If problems ensue post gathering statistics, you can use the RESTORE_SCHEMA_STATS or
RESTORE_TABLE_STATS procedure to restore statistics that were previously backed up in the FND_STATTAB table,
into the dictionary; statid can be provided to distinguish between different sets of statistics.
Gather Options
Use GATHER_AUTO option to gather stats incrementally. GATHER_AUTO relies on the Oracle Table Monitoring
feature to gather information about new or changed objects statistics.
In Oracle 9i, it was possible to specify individual tables, but this approach was deprecated in later releases and is now
automatically enabled for the entire schemas by default in Oracle 10g and Oracle 11g. To mimic this behavior in Oracle 9i,
use the following procedure:
exec FND_STATS.ENABLE_SCHEMA_MONITORING (ALL);
or to enable monitoring for a single schema:
exec FND_STATS.ENABLE_SCHEMA_MONITORING (SCHEMA_NAME);
When Gather Options parameter is set to "GATHER AUTO", fnd_stats will only gather statistics for tables that have
changed by more than the modification threshold % since the table was last analyzed (statistics gathered). The
modifications threshold can be adjusted by the user by passing a value for modpercent, which by default is equal to 10. So
the GATHER_AUTO will only gather stats on tables that show up in DBA_TAB_MODIFICATIONS with > 10%
changes.
FND_STATS.gather_schema_statistics (. . ..,options=>GATHER AUTO);
Histograms
A histogram is a special type of column statistic that provides additional information about the frequency and distribution
of values within a column. This information is used by the Optimizer when, for example, deciding to use an index or
perform a full-table scan, or deciding the join order. Without histograms the Optimizer assumes a uniform distribution of
rows across the distinct values in the column. These are created in Oracle E-Business Suite when a value in a column that is
referenced in a where clause has a disproportionate number of values that would usually make a full-table scan cheaper than
using the index - in other words when a column has non-unique repeating keys and only a few distinct values. This is
referred to as data skew. Histograms may also be used for some join predicates, which is beneficial with cardinality
estimates. Oracle 11g uses adaptive cursor sharing to ensure that the correct plan is used with bind peeking.
Collecting statistics for histograms adds time to the overall process. Histograms can be problematic and in Oracle 10g there
were concerns with bind peeking and how it affects cardinality estimates. The Optimizer would peek at the value of the
bind variables on the first hard parse of the SQL statement and then always use that plan for all future executions. The only
real solution for Oracle E-Business Suite was to disable bind peeking; dropping the histograms was not an option.
This has been improved in Oracle 11g with the introduction of Adaptive Cursor Sharing. Avoiding histograms will ensure
that SQL execution plans will not change depending on the bind value.
Those with custom development can use FND_STATS.CHECK_HISTOGRAM_COLS to determine the viability of
proposed histograms. This procedure checks if the leading columns in non-unique indexes have a single value occupancy
>=1/75th or more of the sample. The recommendation is that there is a minimum of 3000 rows. The following example
shows how to run the procedure:
Set Serveroutput on
EXEC FND_STATS.CHECK_HISTOGRAM_COLS( tablelist => 'owner.table_name1 , owner.table_name2, .... )
Once you have checked the design and performance use the LOAD_HISTOGRAM_COLS procedure to seed information
in the FND_HISTOGRAM_COLS table, which will ensure that they are updated when Gathering Statistics using the
following syntax:
begin
FND_STATS.LOAD_HISTOGRAM_COLS
(action=>'INSERT', appl_id=>&custom_application_id, tabname=>&table_name, colname=>&column_name);
FND_STATS.GATHER_TABLE_STATS( ownname=>&owner_name, tabname=>&table_name);
end;
It adapts to changes in data volumes, such as system growth or purging, whereas a fixed sampling percentage that was
suitable at some point in time will inevitably require regular tests and reviews.
Historically, a 10% sample was sufficient for most objects, but some products/tables benefited from higher sampling
percentage of 30% - 40%, usually due to data skew. Having to determine which products benefitted, or which sample size
provided the best benefit in least time, should no longer be necessary.
Note: The AUTO sampling feature with Oracle E-Business Suite only operates as described with Oracle 11g.
When used with previous database versions it will use 10% for the estimate_percent parameter.
Note: When invoking the Gather Statistics concurrent program, leave the estimate percentage parameter blank.
The program will automatically choose the default value for estimate_percent parameter (depends on the
database version). If a value is provided then statistics will be gathered at the specified percentage. If the
database version is 11g or higher, the default value for this parameter will be dbms_stats.auto_sample_size,
whereas it will be set to 10% for previous releases.
Note: AUTO Sampling Statistics Gathering Feature of Oracle Database 11g is implemented with the latest code
of FND_STATS. Refer to Standalone Patches section, the standalone patches for Oracle 11g are shown in
Table 1.
Custom Scripts
As an alternative to using the Gather Statistics concurrent program, custom scripts may be developed that call the
FND_STATS package directly. The syntax is as follows:
For schema stats: Exec FND_STATS.gather_schema_statistics('schema_name');
For example:
EXEC FND_STATS.gather_schema_statistics('ALL');
EXEC FND_STATS.gather_schema_statistics('XLA');
For table stats: Exec FND_STATS.gather_table_stats(owner,table_name);
For example:
EXEC FND_STATS.gather_table_stats('AR','RA_CUSTOMER_TRX_ALL');
Cursor Invalidation
When an objects statistics are refreshed, all references to that object in the shared pool or library cache are invalidated and
all dependent cursors referencing that object are also invalidated, each will require a new hard parse. Oracle distributes
invalidation timestamps for dependent objects needing invalidation, thereby reducing the potentially large number of
simultaneous hard parses, but this can still result in an increase in library cache waits especially when collecting statistics
across a large number of objects.
Note: When using the Gather Statistics concurrent program, the Invalidate Dependent Cursors parameter is set
to Yes by default, which is the standard best practice. New execution plans will be generated whenever cursor
has been flushed out and reloaded.
While this approach suits most Oracle E-Business Suite installations, this parameter allows you to specify that cursors
should not be invalidated. Although this may reduce the CPU utilization, this means that existing plans, which may be suboptimal, will continue to be used until the dependent cursors are aged out.
Deciding between these two invalidation options is determined by the collection frequency. If you keep your statistics fairly
current, you will probably not need to invalidate cursors as the plans from the newly collected statistic are unlikely to be
significantly different. In other words, performance should remain consistent and stable and over time. However, if you
dont collect statistics frequently enough, or if you start to experience performance degradation due to stale statistics, then
setting this to the default to invalidate the cursors that are dependent on the targeted objects as soon as possible will ensure
that the plans are refreshed sooner.
Note: Gather statistics only when there is little system activity or during a defined batch period.
Locking Statistics
Locking prevents object statistics from being overwritten when the collection processes is run. This may be useful when
tables are empty when the collection process is run, or when you want to exclude exceptionally large tables while gathering
statistics for the remainder of the schema.
Consider locking statistics for the following:
Very large static tables that have representative statistics already in place and are rarely updated.
Volatile tables where data changes dramatically over time. Good examples include intermediate tables used during
batch processing and some interface tables, which are deployed extensively across Oracle E-business Suite. Example
application tables include AP_SELECTED_INVOICES and WSH_PR_WORKERS.
Temporary or interim tables that only contain data at runtime but are typically empty when the collection process
runs. In this specific case, not locking statistics results in having zero or un-representative statistics. Note that these do
not include Global Temporary tables, which are excluded from FND_STATS Gather Schema Statistics anyway.
Note : If a table has zero statistics (num_rows = 0) then the CBO uses these statistics to determine the
execution plan and if the table has a lot of rows at time of execution then this execution plan could be very
inefficient. If tables have empty statistics (null) then dynamic sampling will be used, which is preferable to
using the CBO with incorrect or zero statistics.
There are two distinct methods for protecting table statistics from modification.
1.
You can physically lock the statistics using DBMS_STATS.LOCK_TABLE_STATS, which prevents any calls to
FND_STATS or DBMS_STATS from modifying the statistics.
2.
You can also add the table to a list of excluded tables by using FND_STATS.LOAD_XCLUD_TAB. This prevents the table
from having its statistics modified when using Gather Schema Statistics, but the Gather Table Statistics does not honor
the FND exclusion, only the DBMS lock. This is by design; there may be instances when you want to manually collect
statitistics.
Oracle E-Business Suite development teams use LOAD_XCLUD_TAB to seed exceptions into the
FND_EXCLUDE_TABLE_STATS table (which is a metadata container). Many of the EBS volatile and temporary tables
are seeded in this table for reference only. They will not be excluded from FND_STATS Gather Schema Statistics, as they
have been seeded with negative application_ids. You should consider these tables as candidates for locking.
Note: It is recommended that you use seed tables into FND_EXCLUDE_TABLE_STATS, or use
DBMS_STATS.LOCK_TABLE_STATS if certain that you never want the statistics modified.
For each volatile or temporary table that you have locked you should initially have empty (null) statistics and rely
on dynamic sampling. Delete the statistics if they already contain values. Only if you have performance issues
should you consider gathering statistics when the table has a representative load or populating using
FND_STATS. SET_TABLE_STATS.
Once the statistics are locked using DBMS_STATS.LOCK_TABLE_STATS, the Gather Schema Statistics Concurrent
Program will display a message in the request log file explicitly stating that statistics are locked on that table.
Use the following to seed a table in FND_EXCLUDE_TABLE_STATS:
FND_STATS.LOAD_XCLUD_TAB(action=>'INSERT', appl_id=>&application_id, tabname=>&table_name)
Example
FND_STATS.LOAD_XCLUD_TAB(action=>'INSERT',
appl_id=>222,tabname=>'RA_CUSTOMER_TRX_ALL)
Use the following to delete the table entry from the fnd_exclude_table_stats:
Example
FND_STATS.LOAD_XCLUD_TAB(action=>'DELETE',
appl_id=>222, tabname=>'RA_CUSTOMER_TRX_ALL')
begin
FND_STATS.LOAD_EXTNSTATS_COLS
(action =>'INSERT', appl_id=>&custom_application_id, tabname => &table_name,
owner=>&owner, colname1
Note: You need to gather statistics after defining the group of columns.
Dictionary Statistics
Dictionary statistics only need to be gathered when there have been significant structural changes to the database.
e.g.
After any associated platform or DB upgrade that is part of the overall EBS upgrade.
The question is when, and how often do they need to be collected. Typical examples include upgrades, new modules, or the
application of large patches where several objects might be created or rebuilt using Data Definition Language (DDL)
operations.
Statistics will need to be collected when SQL on the data dictionary objects appears as a high load (usually high elapsed
time) in AWR reports or other monitoring tools, or when times in trace/tkprof files are very high for recursive SQL on the
data dictionary objects. The following command can be used to gather statistics for all system schemas:
EXECUTE DBMS_STATS.GATHER_DICTIONARY_STATS( estimate_percent => DBMS_STATS.AUTO_SAMPLE_SIZE options
=> 'GATHER AUTO' ); -- In 10G and above.
Use DBMS_STATS.GATHER_FIXED_OBJECT_STATS (available in Oracle 10g and later) to gather fixed object
statistics. For optimal performance, and due to the transient nature of the x$ tables, it is important to gather statistics when
there is a representative workload on the system. The collection process tends to be resource intensive and if there is
insufficient capacity during peak load, choose a time after the database has been running for some time and the v$ views
have a significant amount of data. However, gathering fixed objects statistics under heavy load can result in contention
issues thereby leading to performance degradation or hangs. Refer to MyOracle Knowledge Document Fixed Objects
Statistics (GATHER_FIXED_OBJECTS_STATS) Considerations (Doc ID 798257.1) for further information.
The following command can be used to gather fixed object statistics:
EXECUTE DBMS_STATS.GATHER_FIXED_OBJECTS_STATS;
Planning Collection
Fixed object statistics should be gathered when there are significant changes to the database configuration or when
accessing the v$ views is of concern. Oracle E-Business Suite examples include the following:
For example, all the x$ tables that contain information about the buffer cache and shared pool, such as x$ tables used in
v$buffer_pool or v$shared_pool_advice, may change significantly when the SGA is increased.
Note: In Oracle E-Business Suite it is imperative that you disable the Database 11g automatic DBMS job to
gather statistics, but ensure that dictionary statistics are still gathered.
* When upgrading Oracle E-Business Suite, the $APPL_TOP/admin/adstats.sql script disables the Oracle DBMS job that
automatically gathers statistics. It then gathers dictionary and fixed object statistics. However, the Database is run in
restricted mode during the upgrade. Therefore, it is highly recommended to rerun
DBMS_STATS.GATHER_FIXED_OBJECT_STATS post upgrade, when there is a representative load on the system.
Rely on dynamic sampling, which will occur in the absence of statistics. You need to delete any stats using
DBMS_STATS.delete_table_stats on Global Temporary Tables as dynamic sampling only works if statistics are empty.
However, dynamic sampling statistics may not result in an optimal execution plan and often queries will also need to
include Optimizer hints to force a particular execution plan.
Note that FND_STATS Gather Schema Statistics excludes Global Temporary Tables anyway, so they do not need to
be excluded or locked.
Temporary Tables
Temporary tables in Oracle E-Business Suite are regular tables that should not be confused with GTTs. They tend to be
highly volatile and are typically empty for some of the processing cycle and then re-populated. Examples include interface
tables, intermediate transient tables, transactions that have been selected by a specific process such as payments or records
to be purged.
For these tables you should initially have empty (null) statistics and rely on dynamic sampling. Delete the statistics if they
already contain values.
Only if you have performance issues should you consider gathering statistics when the table has a representative load or
populating using FND_STATS. SET_TABLE_STATS.
In all cases the statistics should be locked (so that they are not gathered).
Incremental statistics in conjunction with the new Oracle 11g DBMS_STATS.AUTO_SAMPLE_SIZE yield a significant
reduction in the time to collect highly accurate statistics.
Oracle E-Business Suite
Incremental statistics can be applied to any large partitioned tables. Once the table preference has been set, Oracle EBusiness Suite Gather Statistics (table or schema) can be used to automatically gather the statistics and create the synopsis.
Incremental Preference
Use the following command to check if the incremental preference is set for the XLA_AE_LINES table (which is part of
the Oracle E-Business Suite12 Subledger Accounting):
select dbms_stats.get_prefs('INCREMENTAL', 'XLA','XLA_AE_LINES')
from dual;
10
During testing, it may be useful to know that the preference can be turned off using:
exec dbms_stats.set_table_prefs('XLA', 'XLA_AE_LINES, 'INCREMENTAL', 'FALSE');
Granularity Parameter
Set the granularity parameter to ALL or AUTO. Both of these are effectively the same and will invoke all the
granularity levels.
Set the Estimate Percent parameter to DBMS_STATS.AUTO_SAMPLE_SIZE, which is the default with Oracle 11g.
If you use custom scripts with FND_STATS, set the granularity to ALL or AUTO. For example:
exec fnd_stats.gather_table_stats
('OWNER', TABLE_NAME', granularity =>'ALL');
FND_STATSs DEGREE (Degree of parallelism) helps speed up statistics gathering for large objects. If a degree is not
provided, FND_STATS automatically determines the Degree of Parallelism, it defaults to the minimum of
parallel_max_servers and cpu_count. This approach has been defined as intra object parallelism.
Concurrent Statistics Gathering
Concurrent statistics gathering is a new DBMS_STATS feature in Oracle 11gR2 that provides inter-object parallelism.
When CONCURRENT is set to TRUE (FALSE by default) and Estimate Percent is set to
DBMS_STATS.AUTO_SAMPLE_SIZE, Oracle uses the Oracle Job Scheduler ( job_queue_processes should be set to more
than 4) and Advanced Queuing to concurrently run multiple gather statistics jobs across multiple objects.
The preference can be set using the following command:
exec DBMS_STATS.SET_GLOBAL_PREFS('CONCURRENT','TRUE');
11
DBMS_STATS.gather_table_stats and not gather_schema_statistics. So this feature can only be used to gather statistics for
different partitions of the same table at the same time. So it is only beneficial on partitioned tables, where data is reasonably
well distributed across the partitions.
Verifying Statistics
The FND_STATS.VERIFY_STATS procedure can be used to check that statistics are up-to-date. It produces a report and
can be run using the following syntax:
set serveroutput on
set long 10000
exec apps.fnd_stats.verify_stats (OWNER, TABLE_NAME);
For example:
exec apps.fnd_stats.verify_stats ('ONT', 'ONT.OE_ORDER_HOLDS_ALL');
Alternatively, you can verify statistics using the scripts from My Oracle Support Knowledge Document 163208.1.
bde_last_analyzed.sql - Verifies CBO Statistics.
Standalone Patches
The standalone patches for Oracle 11g are shown in Table 1: Oracle E-Business Suite Standalone Patches for the following
new features implemented in FND_STATS code.
1.
2.
PATCH
12.1.x
16410424:R12.FND.B
12.0.x
16410424:R12.FND.A
11.5.10
14707975
12
Gathering statistics on table without any multi column extension stats for this test case we are using
FND_LOOKUP_VALUES table.
-
desc FND_LOOKUP_VALUES
Datatype
---------------------LOOKUP_TYPE
LANGUAGE
LOOKUP_CODE
MEANING
DESCRIPTION
ENABLED_FLAG
SECURITY_GROUP_ID
VIEW_APPLICATION_ID
Length
Mandatory
------------ --------VARCHAR2 (30)
Yes
VARCHAR2 (30)
Yes
VARCHAR2 (30)
Yes
VARCHAR2 (80)
Yes
VARCHAR2 (240)
VARCHAR2 (1)
Yes
NUMBER (15)
Yes
NUMBER (15)
Yes
TERRITORY_CODE
....
....
VARCHAR2 (2)
Comments
------------------------QuickCode lookup type
Language
QuickCode code
QuickCode meaning
Description
Enabled flag
Security group identifier
Identifies which application's view will include the
lookup values
Territory code of territory using the language
exec fnd_stats.gather_table_stats('APPLSYS','FND_LOOKUP_VALUES');
-
13
The following histograms are already present in the FND data dictionary:
COLUMN_NAME
-----------------------------LANGUAGE
VIEW_APPLICATION_ID
LOOKUP_TYPE
COUNT(*)
------------------------------ ---------NO_POSTAL_CODE
13698
FI_POSTAL_CODE
11496
GHR_US_ACADEMIC_INSTITUTION
11043
AE_OCCUPATION
8760
PL_COMMUNITY
7437
NAICS_2002
7035
FV_PSC_TYPE
6906
NAIC
6306
NAICS_1997
5430
GHR_US_ACADEMIC_DISCIPLINE
5127
NACE
4599
1987 SIC
4512
1972 SIC
4338
PE_US_COURSE_SUBJECT
4299
DK_POSTCODE_TOWN
4002
FV_NAICS_TYPE
3537
1977 SIC
3111
FV_SIC_TYPE
3012
NUMBERS
3000
GHR_US_OCC_SERIES
2889
NO_TAX_MUNICIPALITY
2619
GHR_US_LANG_IDENTIFIER
2547
GHR_US_FOR_ALL_LOC
2238
GHR_US_AGENCY_CODE
2208
BUSINESS_ENTITY
2199
NAF
2145
GHR_US_LEGAL_AUTHORITY
2031
GHR_US_HEALTH_PLAN
2001
IMPORT_ERROR_CODE
1890
HU_JOB_FEOR_CODES
1884
HZ_RELATIONSHIP_ROLE
1521
FV_FSC_TYPE
1365
AE_AREA_CODES
1350
select table_name, column_name, num_distinct, density, num_buckets, histogram from user_tab_col_statistics where
table_name = 'FND_LOOKUP_VALUES';
TABLE_NAME
COLUMN_NAME
NUM_DISTINCT
DENSITY NUM_BUCKETS HISTOGRAM
--------------------------------------------- ------------ ---------- ----------- --------FND_LOOKUP_VALUES
LOOKUP_TYPE
17203 .000058129
1 NONE
FND_LOOKUP_VALUES
LANGUAGE
3 9.3886E-07
3 FREQUENCY
FND_LOOKUP_VALUES
LOOKUP_CODE
86164 .000011606
1 NONE
FND_LOOKUP_VALUES
MEANING
330917 3.0219E-06
1 NONE
FND_LOOKUP_VALUES
DESCRIPTION
207029 4.8302E-06
1 NONE
FND_LOOKUP_VALUES
ENABLED_FLAG
4
.25
1 NONE
FND_LOOKUP_VALUES
SECURITY_GROUP_ID
17 .058823529
1 NONE
FND_LOOKUP_VALUES
VIEW_APPLICATION_ID
87 9.3886E-07
87 FREQUENCY
FND_LOOKUP_VALUES
TERRITORY_CODE
10
.1
1 NONE
....
....
-
Check explain plan of the select for the different values of view_application_id and lookup_type
explain plan for select * from FND_LOOKUP_VALUES where VIEW_APPLICATION_ID=201 and lookup_type=:b2;
Explained.
select plan_table_output from table(dbms_xplan.display('plan_table',null,'serial'));
PLAN_TABLE_OUTPUT
14
---------------------------------------------------------------------------------------------------| Id | Operation
| Name
| Rows | Bytes | Cost (%CPU)| Time
|
---------------------------------------------------------------------------------------------------|
0 | SELECT STATEMENT
|
|
1 |
152 |
4
(0)| 00:00:01 |
|
1 | TABLE ACCESS BY INDEX ROWID| FND_LOOKUP_VALUES
|
1 |
152 |
4
(0)| 00:00:01 |
|* 2 |
INDEX RANGE SCAN
| FND_LOOKUP_VALUES_U1 |
1 |
|
3
(0)| 00:00:01 |
---------------------------------------------------------------------------------------------------Predicate Information:
explain plan for select * from FND_LOOKUP_VALUES where VIEW_APPLICATION_ID=3 and lookup_type='NO_POSTAL_CODE';
Explained.
select plan_table_output from table(dbms_xplan.display('plan_table',null,'serial'));
PLAN_TABLE_OUTPUT
---------------------------------------------------------------------------------------------------| Id | Operation
| Name
| Rows | Bytes | Cost (%CPU)| Time
|
---------------------------------------------------------------------------------------------------|
0 | SELECT STATEMENT
|
|
12 | 1680 |
13
(0)| 00:00:01 |
|
1 | TABLE ACCESS BY INDEX ROWID| FND_LOOKUP_VALUES
|
12 | 1680 |
13
(0)| 00:00:01 |
|* 2 |
INDEX RANGE SCAN
| FND_LOOKUP_VALUES_U2 |
12 |
|
3
(0)| 00:00:01 |
---------------------------------------------------------------------------------------------------Predicate Information:
explain plan for select * from FND_LOOKUP_VALUES where VIEW_APPLICATION_ID=3 and lookup_type='AE_ARIA_CODE';
Explained.
select plan_table_output from table(dbms_xplan.display('plan_table',null,'serial'));
PLAN_TABLE_OUTPUT
---------------------------------------------------------------------------------------------------| Id | Operation
| Name
| Rows | Bytes | Cost (%CPU)| Time
|
---------------------------------------------------------------------------------------------------|
0 | SELECT STATEMENT
|
|
12 | 1680 |
13
(0)| 00:00:01 |
|
1 | TABLE ACCESS BY INDEX ROWID| FND_LOOKUP_VALUES
|
12 | 1680 |
13
(0)| 00:00:01 |
|* 2 |
INDEX RANGE SCAN
| FND_LOOKUP_VALUES_U2 |
12 |
|
3
(0)| 00:00:01 |
---------------------------------------------------------------------------------------------------Predicate Information:
Query fnd_extnstats_cols table to confirm that extended statistics do not exist. fnd_exnstats_cols is FND table
which holds the columns on which extension stats will be created.
set serveroutput on
-
check if virtual column is created for the multi-columns involved for the extended statistics.
select owner,table_name,column_name,histogram from dba_tab_cols where table_name like 'FND_LOOKUP_VALUES' and owner
='APPLSYS';
OWNER
15
TABLE_NAME
COLUMN_NAME
HISTOGRAM
-----------------------------APPLSYS
APPLSYS
APPLSYS
-----------------FND_LOOKUP_VALUES
FND_LOOKUP_VALUES
FND_LOOKUP_VALUES
------------------------------ -------------------ZD_EDITION_NAME
NONE
SYS_STU_L5AKW15J1DXUKXDMYW3UJF NONE
Gather statistics on 'FND_LOOKUP_VALUES' to check if histogram is getting created on the virtual column
exec fnd_stats.gather_table_stats('APPLSYS','FND_LOOKUP_VALUES');
PL/SQL procedure successfully completed.
-
select owner,table_name,column_name,histogram from dba_tab_cols where table_name like 'FND_LOOKUP_VALUES' and owner
='APPLSYS';
OWNER
TABLE_NAME COLUMN_NAME
------------------------------ -----------------------------------------APPLSYS
FND_LOOKUP_VALUES ZD_EDITION_NAME
APPLSYS
-
HISTOGRAM
------------NONE
Above output shows that the height balanced histogram is created on the virtual column
Now check the changes in the explain plan of the select for the different values of view_application_id and
lookup_type
explain plan for select * from FND_LOOKUP_VALUES where VIEW_APPLICATION_ID=201 and lookup_type=:b2;
Explained.
select plan_table_output from table(dbms_xplan.display('plan_table',null,'serial'));
PLAN_TABLE_OUTPUT
---------------------------------------------------------------------------------------------------| Id | Operation
| Name
| Rows | Bytes | Cost (%CPU)| Time
|
---------------------------------------------------------------------------------------------------|
0 | SELECT STATEMENT
|
|
30 | 4560 |
27
(0)| 00:00:01 |
|
1 | TABLE ACCESS BY INDEX ROWID| FND_LOOKUP_VALUES
|
30 | 4560 |
27
(0)| 00:00:01 |
|* 2 |
INDEX RANGE SCAN
| FND_LOOKUP_VALUES_U2 |
30 |
|
3
(0)| 00:00:01 |
---------------------------------------------------------------------------------------------------Predicate Information (identified by operation id):
--------------------------------------------------2 - access("LOOKUP_TYPE"=:B2 AND "VIEW_APPLICATION_ID"=201)
explain plan for select * from FND_LOOKUP_VALUES where VIEW_APPLICATION_ID=3 and lookup_type='NO_POSTAL_CODE'
Explained.
select plan_table_output from table(dbms_xplan.display('plan_table',null,'serial'));
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------------| Id | Operation
| Name
| Rows | Bytes | Cost (%CPU)| Time
|
--------------------------------------------------------------------------------------|
0 | SELECT STATEMENT |
| 12580 | 1867K| 2729
(2)| 00:00:33 |
|* 1 | TABLE ACCESS FULL| FND_LOOKUP_VALUES | 12580 | 1867K| 2729
(2)| 00:00:33 |
--------------------------------------------------------------------------------------Predicate Information (identified by operation id):
--------------------------------------------------1 - filter("LOOKUP_TYPE"='NO_POSTAL_CODE' AND "VIEW_APPLICATION_ID"=3)
explain plan for select * from FND_LOOKUP_VALUES where VIEW_APPLICATION_ID=3 and lookup_type='AE_ARIA_CODE';
Explained.
select plan_table_output from table(dbms_xplan.display('plan_table',null,'serial'));
PLAN_TABLE_OUTPUT
---------------------------------------------------------------------------------------------------| Id | Operation
| Name
| Rows | Bytes | Cost (%CPU)| Time
|
---------------------------------------------------------------------------------------------------|
0 | SELECT STATEMENT
|
|
24 | 3648 |
22
(0)| 00:00:01 |
|
1 | TABLE ACCESS BY INDEX ROWID| FND_LOOKUP_VALUES
|
24 | 3648 |
22
(0)| 00:00:01 |
|* 2 |
INDEX RANGE SCAN
| FND_LOOKUP_VALUES_U2 |
24 |
|
3
(0)| 00:00:01 |
---------------------------------------------------------------------------------------------------Predicate Information (identified by operation id):
16
It took 29.06 sec to gather stats for the first time after data insertion.
Check the statistics and global and partition level
last_analyzed
-----------------------23-SEP-12 07:04:15
23-SEP-12 07:04:16
23-SEP-12 07:04:16
23-SEP-12 07:04:23
23-SEP-12 07:04:23
23-SEP-12 07:04:23
23-SEP-12 07:04:23
23-SEP-12 07:04:23
23-SEP-12 07:04:23
23-SEP-12 07:04:23
23-SEP-12 07:04:23
23-SEP-12 07:04:23
23-SEP-12 07:04:23
23-SEP-12 07:04:23
23-SEP-12 07:04:24
23-SEP-12 07:04:24
23-SEP-12 07:04:24
23-SEP-12 07:04:24
23-SEP-12 07:04:24
Delete the data from one of the partition to check how statistics are getting calculated
exec fnd_stats.gather_table_stats('XLA','XLA_AE_LINES_BKP');
PL/SQL procedure successfully completed.
Elapsed: 00:00:14.06
-
17
After deleting the data ran gather stats without setting the preference. It took 14.06 sec
last_analyzed
-----------------------23-SEP-12 07:10:14
23-SEP-12 07:10:14
23-SEP-12 07:10:14
23-SEP-12 07:10:15
23-SEP-12 07:10:15
23-SEP-12 07:10:15
23-SEP-12 07:10:15
23-SEP-12 07:10:15
23-SEP-12 07:10:15
23-SEP-12 07:10:15
23-SEP-12 07:10:16
23-SEP-12 07:10:16
23-SEP-12 07:10:16
23-SEP-12 07:10:16
23-SEP-12 07:10:17
23-SEP-12 07:10:17
23-SEP-12 07:10:17
23-SEP-12 07:10:17
23-SEP-12 07:10:17
19 rows selected.
NOTE : statistics are gathered on all the partitions even though only AR parition data is deleted, last_analyzed is
updated for all the partitions.
-
Perform the same test case after setting the preference to true. Following command will set the incremental
preference at the table level so next time when gather statistics is run, it will gather stats incremental on this
table
Drop and Recreate the table xla_ae_lines_bkp as a partition table to perform this test case
Insert data from xla_ae_lines table
exec fnd_stats.gather_table_stats('XLA','XLA_AE_LINES_BKP');
PL/SQL procedure successfully completed.
Elapsed: 00:00:22.91
-
After setting the preference it took 22.91 sec to gather statistics for the first time after data insertion
checking stats timing information
18
PARTITION_NAME
-----------------------------AP
AR
CE
CST
DPP
FUN
FV
GMF
IGC
IGI
LNS
OFA
OKL
OZF
PA
PAY
PN
PO
PSB
last_analyzed
-----------------------23-SEP-12 07:17:30
23-SEP-12 07:17:12
23-SEP-12 07:17:10
23-SEP-12 07:17:21
23-SEP-12 07:17:21
23-SEP-12 07:17:12
23-SEP-12 07:17:10
23-SEP-12 07:17:10
23-SEP-12 07:17:10
23-SEP-12 07:17:12
23-SEP-12 07:17:10
23-SEP-12 07:17:10
23-SEP-12 07:17:12
23-SEP-12 07:17:30
23-SEP-12 07:17:12
23-SEP-12 07:17:12
23-SEP-12 07:17:12
23-SEP-12 07:17:10
23-SEP-12 07:17:30
19 rows selected.
-
Deleting the data from one partition to see how incremental statistics gathering will help next time when stats are
gathered.
exec fnd_stats.gather_table_stats('XLA','XLA_AE_LINES_BKP');
PL/SQL procedure successfully completed.
Elapsed: 00:00:04.11
-
After deleting the data for one partition incremental gathering statistics took 4.11 sec
Check global and partition statistics
last_analyzed
-----------------------23-SEP-12 07:17:30
23-SEP-12 07:26:18
23-SEP-12 07:17:10
23-SEP-12 07:17:21
23-SEP-12 07:17:21
23-SEP-12 07:17:12
23-SEP-12 07:17:10
23-SEP-12 07:17:10
23-SEP-12 07:17:10
23-SEP-12 07:17:12
23-SEP-12 07:17:10
23-SEP-12 07:17:10
23-SEP-12 07:17:12
23-SEP-12 07:17:30
23-SEP-12 07:17:12
23-SEP-12 07:17:12
23-SEP-12 07:17:12
23-SEP-12 07:17:10
23-SEP-12 07:17:30
19 rows selected.
Elapsed: 00:00:00.01
Note : statistics are gathered, last_analyzed date is changed for only AR partition and timing has also reduced.
19
With the above test case we can see improvement in timings when incremental preference is set.
Timing information:
Preference set
--------------NO
Yes
NO
Yes
---------------
Table_name
-----------xla_ae_lines
xla_ae_lines
xla_ae_lines
xla_ae_lines
------------
Operation
----------------------------------------------------stats gathered after inserting data for first time
stats gathered after inserting data for first time
stats gathered after modifying one partition
stats gathered after modifying one partition
-----------------------------------------------------
Timing
--------29.06 sec
22.91 sec
14.06 sec
04.11 sec
---------
exec DBMS_STATS.SET_GLOBAL_PREFS('CONCURRENT','TRUE');
-
exec DBMS_STATS.SET_GLOBAL_PREFS('CONCURRENT','FALSE');
-
exec dbms_stats.delete_table_stats('XLA','XLA_AE_HEADERS');
-
exec fnd_stats.gather_table_stats('XLA','XLA_AE_HEADERS');
Elapsed: 00:29:30.97
-
exec DBMS_STATS.SET_GLOBAL_PREFS('CONCURRENT','TRUE');
-
exec dbms_stats.delete_table_stats('XLA','XLA_AE_HEADERS');
PL/SQL procedure successfully completed.
-
Gathering Statistics
exec fnd_stats.gather_table_stats('XLA','XLA_AE_HEADERS');
PL/SQL procedure successfully completed.
Elapsed: 00:26:59.54
Results of the test case:
Method
---------FND_STATS
FND_STATs
----------
Level (schema/table)
--------------------table(XLA_AE_HEADERS)
table(XLA_AE_HEADERS)
---------------------
Timing
----------00:29:30.97
00:26:59.54
-----------
From the above test cases, we see fnd_stats (with parallel option, as fnd_stats runs by default with parallel option)
with setting global preference to FALSE took 29 mins and 30 secs. fnd_stats ran with setting global preference to TRUE,
took 26 mins and 59 secs. We see a net gain of 2 mins 5 secs in the gather statistics timing. And even this small gain
could be explained by blocks already being in cache.
20
Whitepapers
These papers are generic and do not specifically focus on Oracle E-Business Suite.
Upgrading from Oracle Database 10g to 11g: What to expect from the Optimizer
This paper introduces the new Oracle 11g Optimizer features and outlines essential steps before and after the upgrade
in order to avoid performance regressions related to plan changes that are likely to occur. This is available on Oracle
Technet: http://www.oracle.com/technetwork/database/focus-areas/bi-datawarehousing/twp-upgrading-10g-to-11g-what-to-ex133707.pdf
Managing CBO Stats during an upgrade to Oracle 10g or Oracle 11g (Doc ID 465787.1)
The core idea presented is to continue gathering Optimizer statistics for application schemas as usual, but create a clean
baseline for non-application objects (data dictionary, fixed objects and system performance).
EBPERF FAQ - Collecting Statistics with Oracle EBS 11i and R12 (Doc ID 368252.1)
This FAQ note assists with generic questions about gathering stats for Apps 11i and R12
The following My Oracle Support Knowledge Documents are useful if you are unable to apply the FND_STATS
standalone patch:
Blogs
21
The Oracle Optimizer blog ( https://blogs.oracle.com/optimizer ) contains excellent generic information on a number of topics
from the author of the Best Practices for Gathering Optimizer Statistics paper.
Topics include the following
Extended Statistics
In addition there are articles on other tuning related issues such as cardinality feedback.
22
Figure 1 :
Oracle E-Business Suite - Gather Table Statistics Concurrent Request Submission window
Figure 1 shows an example of submitting Gather Table Statistics. Note that Estimate Percent is blank; a description of the
parameters follows.
TABLE B1. FND_STATS.GATHER_TABLE_STATS PARAMETERS
PARAMETER
DESCRIPTION
Owner Name
Table Name
Estimate Percent
The sampling percentage. If left blank, for 11g defaults to dbms_stats.auto_sample_size and for
23
10g and prior it the default value of 10 is used. The valid range is from 0 to 100.
Degree
The degree of parallelism to be used when gathering statistics. If a Degree is not provided, it
defaults to the minimum of parallel_max_servers and cpu_count.
Partition Name
Backup Flag
Granularity
The granularity of statistics to collect (only relevant for partitioned tables). Valid values are:
DEFAULT - Gather global and partitionlevel statistics.
SUBPARTITION - Gather subpartitionlevel statistics.
PARTITION - Gather partitionlevel statistics.
GLOBAL - Gather global statistics.
ALL - Gather all (subpartition, partition, and global) statistics.
History Mode
Invalidate Dependent Cursors
24
This parameter controls the number of history records. The options, which are discussed in the
History Mode section, include LASTRUN, FULL and NONE. The default is LASTRUN.
This indicates whether dependent cursors should be invalidated. This parameter is ignored prior
to Oracle 9iR2
Figure 2 :
Oracle E-Business Suite - Gather Schema Statistics Concurrent Request Submission window
Figure 2 shows an example of submitting Gather Schema Statistics. Note that Estimate Percent is blank; a description of
the parameters follows.
TABLE B2: FND_STATS.GATHER_SCHEMA_STATS PARAMETERS
PARAMETER
DESCRIPTION
Schema Name
ALL will collect statistics for every registered Oracle E-Business Suite schema listed in
FND_PRODUCT_INSTALLATIONS table.
Estimate percent
The sampling percentage. If left blank, for 11g defaults to dbms_stats.auto_sample_size and for
10g and prior it the default value of 10 is used. The valid range is from 0 to 100.
25
Degree
The degree of parallelism for gathering statistics. Default value is MIN (DB init parameters:
parallel_max_servers, cpu_count).
Backup Flag
Restart Request ID
If the Gather Schema Statistics run failed or was stopped, it can be re-submitted with this
parameter and it will pick up where the failed run left off.
History Mode
This parameter controls the number of history records. The options, which are discussed in the
History Mode section, include LASTRUN, FULL and NONE. The default is LASTRUN.
Gather Options
This parameter specifies how objects are selected for statistics gathering.
GATHER (Default) - All schema tables and indexes are selected for statistics gathering.
GATHER_AUTO - Tables of the schema schemaname for which the percentage of modifications
has exceeded modpercent are selected for statistics gathering. Table monitoring needs to be
enabled before using this option.
GATHER_EMPTY - Statistics are gathered only for tables and indexes that are missing
statistics.
LIST_AUTO - It only provides a list of objects for gather statistics if GATHER_AUTO is used.
LIST_EMPTY - It only provides a list of objects for gather statistics if GATHER_EMPTY is used.
Modification Threshold
This option is applicable only to GATHER AUTO and LIST AUTO options. This parameter
specifies the percentage of modifications that have to take place on a table before it can be
picked up for AUTO statistics gathering.
This indicates whether dependent cursors should be invalidated. The default is 'Y'.
26
This document is provided for information purposes only, and the contents hereof are subject to change without notice. This
document is not warranted to be error-free, nor subject to any other warranties or conditions, whether expressed orally or implied in
law, including implied warranties and conditions of merchantability or fitness for a particular purpose. We specifically disclaim any
liability with respect to this document, and no contractual obligations are formed either directly or indirectly by this document. This
document may not be reproduced or transmitted in any form or by any means, electronic or mechanical, for any purpose, without our
prior written permission.
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
Oracle Corporation
World Headquarters
500 Oracle Parkway
Redwood Shores, CA 94065
U.S.A.
Worldwide Inquiries:
Phone: +1.650.506.7000
Fax: +1.650.506.7200
oracle.com
Intel and Intel Xeon are trademarks or registered trademarks of Intel Corporation. All SPARC trademarks are used under license and
are trademarks or registered trademarks of SPARC International, Inc. AMD, Opteron, the AMD logo, and the AMD Opteron logo are
trademarks or registered trademarks of Advanced Micro Devices. UNIX is a registered trademark of The Open Group. 0113