Gathers Schema Stats

March 26, 2018 | Author: Siddharth Chopra | Category: Oracle Database, Sql, Databases, Statistics, Database Index


Comments



Description

An Oracle White PaperSeptember 2013 Best Practices for Gathering Statistics with Oracle E-Business Suite Best Practices for Gathering Statistics with Oracle E-Business Suite 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 Oracle’s products remains at the sole discretion of Oracle. Best Practices for Gathering Statistics with Oracle E-Business Suite 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 incremental stats gathering for partitioned tables and concurrent stats gathering. It focuses on new features implemented in the FND_STATS package that can be applied to Oracle E-Business Suite 11i (11.Best Practices for Gathering Statistics with Oracle E-Business Suite Executive Overview This paper documents the best practices for gathering statistics. The FND_STATS package also supports histograms. schema. Neither the DBMS_STATS package nor the now obsolete ANALYZE command recognize those features and may result in suboptimal execution plans. table exclusions and the new database 11G features such as extended stats. however.5. It describes several methods for collecting or setting statistics. 1 . 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. FND_STATS is a wrapper around the DBMS_STATS package and provides several PL/SQL procedures for gathering statistics at the table. 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).10 and later) and Release 12. or database level. FND_STATS maintains the history of each submission. or for the entire Oracle E-Business Suite. If a run stopped or interrupted. statid can be provided to distinguish between different sets of statistics. the next submission will resume from the point of failure or termination. • Histograms on columns designated in FND_HISTOGRAM_COLS. • The new GATHER_AUTO option combines the collection of statistics for tables with either stale or missing (empty) statistics. If the Gather Schema Statistics concurrent program is used. This is the default behavior. which is generated automatically if one is not provided. the Purge FND_STATS History Records concurrent program should be run periodically to purge the FND_STATS_HIST table. Gather Options Use GATHER_AUTO option to gather stats incrementally. While either the Oracle E-Business Suite or DBMS_STATS will gather statistics for objects with stale or empty (missing) statistics. DBMS_STATS 'GATHER AUTO' option with Table Monitoring feature can be used to serve the purpose of rerun-ability. History records are created for each new run and are identified by the Request ID. GATHER_AUTO relies on the Oracle Table Monitoring feature to gather information about new or changed objects statistics. • FND_STATS_HIST stores historical information about the amount of time it takes the statistics gathering package FND_STATS to gather statistics. This contains a list of histogram columns that Oracle Development have identified as essential.History records are maintained only for the last gather statistics run. 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. DBMS_STATS does not have this functionality. into the dictionary. • Full . • FND_STATS supports rerun-ability feature. • None . the FND_STATS package implements the following features in Oracle E-Business Suite: • Supports collection of statistics for individual schemas. pass the schema name as 'ALL'. Each subsequent run will overwrite the previous history record for the object.EXPORT_TABLE_STATS prior to gathering new statistics and stores them in FND_STATTAB. Starting with the 10g version of the database.This mode does not overwrite previous historical information. History Mode The Gather Table Statistics program can optionally backup the existing statistics prior to gathering new statistics.This mode does not generate any history information and the run cannot be restarted. If this mode is used. If problems ensue post gathering statistics. 2 . FND_STATS exports the old statistics using DBMS_STATS. The history mode parameter controls the amount of history records that are created: • Last Run . To process all EBusiness schemas.Best Practices for Gathering Statistics with Oracle E-Business Suite FND_STATS Features This section provides a high-level view of how the FND_STATS package interacts with DBMS_STATS. If the value of backup flag parameter is BACKUP. . for example.. FND_STATS. which will ensure that they are updated when Gathering Statistics using the following syntax: begin FND_STATS. .CHECK_HISTOGRAM_COLS( tablelist => 'owner. This information is used by the Optimizer when.LOAD_HISTOGRAM_COLS (action=>'INSERT'. colname=>&column_name).in other words when a column has non-unique repeating keys and only a few distinct values..CHECK_HISTOGRAM_COLS to determine the viability of proposed histograms. Those with custom development can use FND_STATS. 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. Collecting statistics for histograms adds time to the overall process. tabname=>&table_name). 3 .’ ) Once you have checked the design and performance use the LOAD_HISTOGRAM_COLS procedure to seed information in the FND_HISTOGRAM_COLS table.. deciding to use an index or perform a full-table scan.GATHER_TABLE_STATS( ownname=>&owner_name. Avoiding histograms will ensure that SQL execution plans will not change depending on the bind value. When Gather Options parameter is set to "GATHER AUTO". tabname=>&table_name.. Oracle 11g uses adaptive cursor sharing to ensure that the correct plan is used with bind peeking. which is beneficial with cardinality estimates. The modifications threshold can be adjusted by the user by passing a value for modpercent. This has been improved in Oracle 11g with the introduction of Adaptive Cursor Sharing. This procedure checks if the leading columns in non-unique indexes have a single value occupancy >=1/75th or more of the sample.gather_schema_statistics (.ENABLE_SCHEMA_MONITORING (‘ALL’).Best Practices for Gathering Statistics with Oracle E-Business Suite In Oracle 9i.options=>’GATHER AUTO’).ENABLE_SCHEMA_MONITORING (SCHEMA_NAME). dropping the histograms was not an option. or deciding the join order. Histograms can be problematic and in Oracle 10g there were concerns with bind peeking and how it affects cardinality estimates. The following example shows how to run the procedure: Set Serveroutput on EXEC FND_STATS. So the GATHER_AUTO will only gather stats on tables that show up in DBA_TAB_MODIFICATIONS with > 10% changes. 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. 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 . use the following procedure: exec FND_STATS. . Histograms may also be used for some join predicates. which by default is equal to 10. The recommendation is that there is a minimum of 3000 rows. The only real solution for Oracle E-Business Suite was to disable bind peeking. 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).table_name2. . appl_id=>&custom_application_id. FND_STATS. Without histograms the Optimizer assumes a uniform distribution of rows across the distinct values in the column. This is referred to as data skew. To mimic this behavior in Oracle 9i. end. Histograms A histogram is a special type of column statistic that provides additional information about the frequency and distribution of values within a column. or to enable monitoring for a single schema: exec FND_STATS.table_name1 . owner. Note: The AUTO sampling feature with Oracle E-Business Suite only operates as described with Oracle 11g. which was provided to the ESTIMATE_PERCENT parameter.Best Practices for Gathering Statistics with Oracle E-Business Suite / The AUTO Sampling Option Traditionally in Oracle E-Business Suite most statistics were gathered at the default sample size of 10%.AUTO_SAMPLE_SIZE. leave the estimate percentage parameter blank. the standalone patches for Oracle 11g are shown in Table 1. even if you specify 100%. but may not collect statistics that reflect the true distribution of data and might result in sub-optimal runtime performance (especially in the case of data skew). whereas it will be set to 10% for previous releases. The new version of FND_STATS now supports the 'AUTO' option for the ESTIMATE_PERCENT parameter. Note: Using AUTO is highly recommended as specifying a numeric percentage will use the old statistics gathering algorithm. but some products/tables benefited from higher sampling percentage of 30% . which in turn uses the DBMS_STATS. a 10% sample was sufficient for most objects. the default value for the ESTIMATE_PERCENT parameter changed to DBMS_STATS. such as system growth or purging. Note: When invoking the Gather Statistics concurrent program. • Historically. For example: 4 . whereas a fixed sampling percentage that was suitable at some point in time will inevitably require regular tests and reviews. Note: AUTO Sampling Statistics Gathering Feature of Oracle Database 11g is implemented with the latest code of FND_STATS. whereas a smaller sample size would collect more quickly. When used with previous database versions it will use 10% for the estimate_percent parameter. Refer to “Standalone Patches” section. custom scripts may be developed that call the FND_STATS package directly. Experience shows that some of the products subject to data skew benefited from gathering at a higher percentage. Having to determine which products benefitted.AUTO_SAMPLE_SIZE.40%. there were some issues with inadequate samples when tables had exceptional data skew. Further advantages of using the AUTO sample size instead of a specific percentage include the following: • It adapts to changes in data volumes. or which sample size provided the best benefit in least time. In Oracle 10g DBMS_STATS. The program will automatically choose the default value for estimate_percent parameter (depends on the database version). Custom Scripts As an alternative to using the Gather Statistics concurrent program. the default value for this parameter will be dbms_stats. should no longer be necessary.auto_sample_size. If the database version is 11g or higher. The syntax is as follows: For schema stats: Exec FND_STATS.gather_schema_statistics('schema_name'). If a value is provided then statistics will be gathered at the specified percentage. but would take longer to collect. usually due to data skew. Oracle 11g now uses hash-based sampling that has accuracy close to 100% but executes more quickly than when collecting at 10% using the old method. Although this allowed Oracle to determine the appropriate sample size. This led to a trade-off. A larger sample size would deliver more accurate results. Administrators who are trying to determine an appropriate strategy may find it useful to monitor the STALE_STATS column in USER_TAB_STATISTICS. When to Gather Statistics Some Oracle E-Business Suite customers gather statistics too frequently unnecessarily wasting system resources. so you also need business knowledge of the major activities. Note: A baseline of critical business processes and transactions provide a datum and is exceptionally useful for performance monitoring when patching or updating the system.Best Practices for Gathering Statistics with Oracle E-Business Suite EXEC FND_STATS.gather_table_stats(‘owner’.gather_table_stats('AR'. Consider an example where 1 million records are added per month to a table containing 10M rows. Instead.'RA_CUSTOMER_TRX_ALL'). gathering statistics for a specific set of objects immediately after significant data imports. or specific time during the business cycle enables administrators to correlate the gathering statistics event with any unexpected behavior.’table_name’). or even individual tables. gathering statistics on a particular day. until key transaction performance starts to change. You should not excessively gather statistics on all schemas such as nightly or weekly. devise a strategy to ensure that the collection frequency does not cause excessive SQL execution plan instability and that the statistics do not reach a level of staleness that impacts performance. Variations in volume that trigger the 10% stale threshold may result in more or less frequent updates to the statistics collection process. Map the business cycle and substantial data changes including. data import. in other words. or purging.gather_schema_statistics('XLA'). month end processing. such as weekly or monthly. doesn’t mean frequently running Gather Statistics. on volume rather than time. Create a repeatable baseline of critical business processes and transactions. This is typically automated within Oracle E-Business Suite interface programs. The collection interval may also be determined by monitoring transaction throughput. for example. updates and deletes. Review the baseline regularly. For table stats: Exec FND_STATS. static and reference tables. This corresponds to the 10% threshold used when gathering stale statistics and therefore statistics would be collected approximately once each month. Use this information to help determine the collection frequency. such as daily.gather_schema_statistics('ALL'). Oracle E-Business Suite customers are advised to determine the frequency of statistics gathering based on substantive changes to data or data skew. such as purging or data import or you should additionally refer to information from USER_TAB_MODIFICATIONS. When time constrained and the time to gather statistics exceeds the collection window. for example. EXEC FND_STATS. With the later approach. For example: EXEC FND_STATS. break the collection process across each time slot by schema. It is highly recommended that statistics are gathered bi-weekly. this information is only updated daily. posting. However. Having representative statistics. or an even longer interval depending on your data. monthly. 5 . Note: During collection Oracle internally prioritizes the database objects that require statistics. are unlikely to become stale and so it is more important to focus on the more volatile high-transaction tables. Exceptions include. which lists the number of inserts. which tend to be relatively small. date. Overall. • Volatile tables where data changes dramatically over time. which are excluded from FND_STATS Gather Schema Statistics anyway. This may be useful when tables are empty when the collection process is run. which may be suboptimal. but this can still result in an increase in library cache waits especially when collecting statistics across a large number of objects. Deciding between these two invalidation options is determined by the collection frequency. In this specific case. There are two distinct methods for protecting table statistics from modification. If you keep your statistics fairly current. which is preferable to using the CBO with incorrect or zero statistics. While this approach suits most Oracle E-Business Suite installations. 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. 1.Best Practices for Gathering Statistics with Oracle E-Business Suite Cursor Invalidation When an object’s statistics are refreshed. New execution plans will be generated whenever cursor has been flushed out and reloaded. all references to that object in the shared pool or library cache are invalidated and all dependent cursors referencing that object are also invalidated. Consider locking statistics for the following: • Very large static tables that have representative statistics already in place and are rarely updated. 6 You can physically lock the statistics using DBMS_STATS. performance should remain consistent and stable and over time. not locking statistics results in having zero or un-representative statistics. this means that existing plans. 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. this parameter allows you to specify that cursors should not be invalidated. Locking Statistics Locking prevents object statistics from being overwritten when the collection processes is run. which are deployed extensively across Oracle E-business Suite. the Invalidate Dependent Cursors parameter is set to “Yes” by default. Note: When using the Gather Statistics concurrent program.LOCK_TABLE_STATS. or if you start to experience performance degradation due to stale statistics. will continue to be used until the dependent cursors are aged out. Example application tables include AP_SELECTED_INVOICES and WSH_PR_WORKERS. However. Good examples include intermediate tables used during batch processing and some interface tables. If tables have empty statistics (null) then dynamic sampling will be used. • Temporary or interim tables that only contain data at runtime but are typically empty when the collection process runs. or when you want to exclude exceptionally large tables while gathering statistics for the remainder of the schema. . Note that these do not include Global Temporary tables. Oracle distributes invalidation timestamps for dependent objects needing invalidation. if you don’t collect statistics frequently enough. Although this may reduce the CPU utilization. which prevents any calls to FND_STATS or DBMS_STATS from modifying the statistics. thereby reducing the potentially large number of simultaneous hard parses. which is the standard best practice. Note: Gather statistics only when there is little system activity or during a defined batch period. 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. each will require a new hard parse. or use DBMS_STATS. This is by design. These are typically used when the cardinality estimates on a group of columns is inaccurate. Delete the statistics if they already contain values. Use the following to seed a table in FND_EXCLUDE_TABLE_STATS: FND_STATS. The column groups are defined using DBMS_STATS. as provided by Oracle E-Business Suite standalone patches now supports Oracle 11g extended statistics.LOAD_XCLUD_TAB(action=>'DELETE'. In Oracle E-Business Suite. the Gather Schema Statistics Concurrent Program will display a message in the request log file explicitly stating that statistics are locked on that table. Statistics are automatically maintained by Gather Schema/Table Statistics concurrent programs or when using FND_STATS.LOCK_TABLE_STATS.LOAD_EXTNSTATS_COLS is used to seed the multi-column groups. Creating extended statistics on a group of columns increases the accuracy of the combined selectivity of the predicates and hence the cardinality estimate. Refer to “Standalone Patches” section. Note: The new FND_STATS. only the DBMS lock. appl_id=>222. when the columns are used together in the where clause of a SQL statement. Oracle will automatically maintain the statistics on that column group when statistics are gathered on the table. Once the statistics are locked using DBMS_STATS. Once created. appl_id=>&application_id. appl_id=>222. 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). They will not be excluded from FND_STATS Gather Schema Statistics. as they have been seeded with negative application_ids.Best Practices for Gathering Statistics with Oracle E-Business Suite 2.tabname=>'RA_CUSTOMER_TRX_ALL) Use the following to delete the table entry from the fnd_exclude_table_stats: FND_STATS.LOAD_XCLUD_TAB(action=>'INSERT'. Many of the EBS volatile and temporary tables are seeded in this table for reference only. The following examples provide the syntax for this procedure: 7 . Only if you have performance issues should you consider gathering statistics when the table has a representative load or populating using FND_STATS.LOAD_XCLUD_TAB(action=>'DELETE'.LOAD_XCLUD_TAB. Note: It is recommended that you use seed tables into FND_EXCLUDE_TABLE_STATS. You can also add the table to a list of excluded tables by using FND_STATS. tabname=>&table_name) Example FND_STATS. there may be instances when you want to manually collect statitistics.LOCK_TABLE_STATS if certain that you never want the statistics modified. This prevents the table from having its statistics modified when using Gather Schema Statistics. For each volatile or temporary table that you have locked you should initially have empty (null) statistics and rely on dynamic sampling. You should consider these tables as candidates for locking. appl_id=>&application_id. tabname=>&table_name) Example FND_STATS.LOAD_XCLUD_TAB(action=>'INSERT'. but the Gather Table Statistics does not honor the FND exclusion. SET_TABLE_STATS. FND_STATS.CREATE_EXTENDED_STATS. tabname=>'RA_CUSTOMER_TRX_ALL') Database 11g Extended Statistics The Oracle Optimizer collects statistics on separate columns but does not have any knowledge about the relationship or correlation between the data stored across separate columns in the same table. the standalone patches for Oracle 11g are shown in Table 1. ). or when times in trace/tkprof files are very high for recursive SQL on the data dictionary objects. fixed tables have no IO cost associated with them and therefore when generating an execution plan the CBO only considers the CPU cost. The following command can be used to gather statistics for all system schemas: EXECUTE DBMS_STATS. or the application of large patches where several objects might be created or rebuilt using Data Definition Language (DDL) operations. FND_STATS does not gather statistics for dictionary or fixed objects and instead you need to use DBMS_STATS in 10g and above. e. • After the R12 upgrade. such as V$SQL and V$SQL_PLAN are based on the x$ tables. such as SYS.. / Note: You need to gather statistics after defining the group of columns.. most of the v$ views. Fixed Object Statistics Fixed objects include the x$ tables and their indexes. Typical examples include upgrades. which typically contain information about the instance or memory structures. colname3.. Dictionary Statistics Dictionary statistics only need to be gathered when there have been significant structural changes to the database. tabname => &table_name. FND_STATS. the statistics need to be gathered for all the dictionary tables (owned by ‘SYS’.. colname1 =>&column_name1. owner=>&owner. tabname=>&table_name).g. end. these defaults may not be representative and could potentially lead to suboptimal execution plans.GATHER_TABLE_STATS( ownname=>&owner_name.AUTO_SAMPLE_SIZE options => 'GATHER AUTO' ). The automatic statistics gathering job does not gather fixed object statistics and in this case. -.LOAD_EXTNSTATS_COLS (action =>'INSERT'. There are no Oracle E-Business Suite specific guidelines on the collection frequency for the dictionary and fixed object statistics.Best Practices for Gathering Statistics with Oracle E-Business Suite begin FND_STATS. Unlike dictionary tables that reside on disk. ‘SYSTEM’ and ‘SYSAUX’ etc) and the x$ tables used by the dynamic v$ performance views. or application SQLs that use data dictionary views or fixed objects. As such. 8 . 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. however. • After move to OATM The question is when.In 10G and above. appl_id=>&custom_application_id. Instead. new modules. which are in-memory structures. colname2 =>&column_name2. and how often do they need to be collected. Gathering Dictionary and Fixed Object Statistics For the Cost Based Optimizer to work effectively for internal (recursive) SQLs. • After any associated platform or DB upgrade that is part of the overall EBS upgrade. the Optimizer uses predefined default values.GATHER_DICTIONARY_STATS( estimate_percent => DBMS_STATS.DBA_DATA_FILES. dynamic sampling is not automatically used for SQL statements involving x$ tables when statistics are missing. Therefore. choose a time after the database has been running for some time and the v$ views have a significant amount of data. may change significantly when the SGA is increased.g. It then gathers dictionary and fixed object statistics. Refer to MyOracle Knowledge Document “Fixed Objects Statistics (GATHER_FIXED_OBJECTS_STATS) Considerations (Doc ID 798257. The following approaches can be used to ensure good execution plan: • Rely on dynamic sampling. You need to delete any stats using DBMS_STATS. However. These tables are completely dynamic in nature. such as x$ tables used in v$buffer_pool or v$shared_pool_advice. Note: In Oracle E-Business Suite it is imperative that you disable the Database 11g automatic DBMS job to gather statistics. * When upgrading Oracle E-Business Suite. For optimal performance. it is highly recommended to rerun DBMS_STATS. The standard performance recommendation is not to gather statistics on global temporary tables. all the x$ tables that contain information about the buffer cache and shared pool. However. the $APPL_TOP/admin/adstats.sql script disables the Oracle DBMS job that automatically gathers statistics.GATHER_FIXED_OBJECT_STATS (available in Oracle 10g and later) to gather fixed object statistics. gathering fixed objects statistics under heavy load can result in contention issues thereby leading to performance degradation or hangs. Oracle E-Business Suite examples include the following: • Major database or application upgrades* • Platform upgrades (especially Exadata) • New application modules are deployed • Performance issues when querying V$ views • Significant changes in the workload or number of sessions • After significant database structure changes (e. Global Temporary Tables Several Oracle E-Business Suite product teams create and use global temporary tables (GTTs) within a process.GATHER_FIXED_OBJECT_STATS post upgrade. but ensure that dictionary statistics are still gathered. which will occur in the absence of statistics. • However. 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. 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.delete_table_stats on Global Temporary Tables as dynamic sampling only works if statistics are empty. they are subsequently dropped when the process completes.Best Practices for Gathering Statistics with Oracle E-Business Suite How and When to Gather Fixed Object Statistics Use DBMS_STATS. SGA/PGA) For example. and due to the transient nature of the x$ tables. when there is a representative load on the system. 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. the Database is run in restricted mode during the upgrade.GATHER_FIXED_OBJECTS_STATS. 9 . The following command can be used to gather fixed object statistics: EXECUTE DBMS_STATS.1)” for further information. 10 . Oracle derives global statistics by scanning only new or modified partitions rather than the whole table.get_prefs('INCREMENTAL'. which is highly beneficial with high volume Oracle E-Business Suite tables. Oracle EBusiness Suite Gather Statistics (table or schema) can be used to automatically gather the statistics and create the synopsis. The preconditions that need to be met for this approach include the following: • The INCREMENTAL preference for the partition table is set to TRUE • DBMS_STATS. intermediate transient tables. Incremental Statistics for Partitioned Tables Incremental statistics gathering is a new Oracle 11gR2 DBMS_STATS feature and is fully supported by FND_STATS. Examples include interface tables. Delete the statistics if they already contain values. Incremental global statistics works by collecting statistics and storing a synopsis (statistical metadata) for each partition. so they do not need to be excluded or locked.AUTO_SAMPLE_SIZE yield a significant reduction in the time to collect highly accurate statistics.Best Practices for Gathering Statistics with Oracle E-Business Suite • Note that FND_STATS Gather Schema Statistics excludes Global Temporary Tables anyway. but by aggregating the synopsis from each partition. This synopsis is typically only a few KB and is stored in the SYSAUX tablespace. Once a synopsis has been created for a new partition. transactions that have been selected by a specific process such as payments or records to be purged. In all cases the statistics should be locked (so that they are not gathered).GATHER_*_STATS parameter GRANULARITY includes “ALL” or “AUTO”. • ESTIMATE_PERCENT is set to AUTO_SAMPLE_SIZE (default in Oracle 11g) Incremental statistics in conjunction with the new Oracle 11g DBMS_STATS. For these tables you should initially have empty (null) statistics and rely on dynamic sampling. Oracle E-Business Suite Incremental statistics can be applied to any large partitioned tables. which consists of statistical metadata and the columns in each partition. They tend to be highly volatile and are typically empty for some of the processing cycle and then re-populated. 'XLA'.'XLA_AE_LINES') from dual. Global statistics are created not by reading the entire table. Once the table preference has been set. SET_TABLE_STATS. all the synopses will be aggregated to update the table level statistics. Temporary Tables Temporary tables in Oracle E-Business Suite are regular tables that should not be confused with GTTs. 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. Only if you have performance issues should you consider gathering statistics when the table has a representative load or populating using FND_STATS. gather_table_stats ('OWNER'. The preference can be set using the following command: exec dbms_stats. This approach has been defined as intra object parallelism. or large servers that have reach maximum CPU during traditional (nonconcurrent) statistics gathering. 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. 'INCREMENTAL'. The preference can be set using the following command: exec DBMS_STATS.Best Practices for Gathering Statistics with Oracle E-Business Suite If it returns TRUE then the preference is set. This combined approach is most beneficial when there is plenty of available CPU. they may not provide a significant improvement as FND_STATS in 11gR2 already uses the AUTO sample size and parallelism while gathering stats. In addition FND_STATS calls 11 .'XLA_AE_LINES'. Improving the Collection Time There are two ways to speed up the gather statistics collection process. Both of these are effectively the same and will invoke all the granularity levels. set the granularity to “ALL” or “AUTO”. Granularity Parameter When running Gather Statistics at the schema or table level: • Set the granularity parameter to “ALL” or “AUTO”. If you use custom scripts with FND_STATS. FND_STATS automatically determines the Degree of Parallelism. This limitation is overcome when combined with the Oracle 11gR2 concurrent feature.set_table_prefs('XLA'. When using DEGREE. 'XLA_AE_LINES. Degree Of Parallelism FND_STATS’s DEGREE (Degree of parallelism) helps speed up statistics gathering for large objects. it defaults to the minimum of parallel_max_servers and cpu_count. If a degree is not provided. which is the default with Oracle 11g. ’TABLE_NAME'.'INCREMENTAL'. It is aimed at systems with several CPUs that have spare capacity when the gather statistics process is run. It is unlikely to make much difference on small servers (that are less likely to have huge partitions).set_table_prefs('XLA'. granularity =>'ALL').SET_GLOBAL_PREFS('CONCURRENT'.'TRUE'). During testing. 'FALSE'). parallel servers will only work on one table partition at a time. • Set the Estimate Percent parameter to “DBMS_STATS. Concurrent Statistics Gathering Concurrent statistics gathering is a new DBMS_STATS feature in Oracle 11gR2 that provides inter-object parallelism. For example: exec fnd_stats.'TRUE'). When CONCURRENT is set to TRUE (FALSE by default) and Estimate Percent is set to DBMS_STATS.AUTO_SAMPLE_SIZE. Although these features are supported.AUTO_SAMPLE_SIZE”. it may be useful to know that the preference can be turned off using: exec dbms_stats. This needs to be set by logging in as sys user. ‘TABLE_NAME’).fnd_stats.OE_ORDER_HOLDS_ALL').1: coe_stats. 1. Database 11g AUTO Sampling Statistics Gathering Option Those unable to apply the Auto sampling standalone patch should review the automated script provided in My Oracle Knowledge Document 156968.10 14707975 12 .FND.sql .A 11. Database 11g Extended Statistics Gathering Feature TABLE 1.0.5. Verifying Statistics The FND_STATS. It produces a report and can be run using the following syntax: set serveroutput on set long 10000 exec apps.gather_table_stats and not gather_schema_statistics.FND.sql . where data is reasonably well distributed across the partitions.VERIFY_STATS procedure can be used to check that statistics are up-to-date.verify_stats ('ONT'.x 16410424:R12.Automates CBO Stats Gathering using FND_STATS and Table sizes. you can verify statistics using the scripts from My Oracle Support Knowledge Document 163208.Best Practices for Gathering Statistics with Oracle E-Business Suite DBMS_STATS. 'ONT.1.x 16410424:R12. bde_last_analyzed. For example: exec apps.B 12. So it is only beneficial on partitioned tables. and collection frequency. So this feature can only be used to gather statistics for different partitions of the same table at the same time. 2.verify_stats (‘OWNER’. This interim solution provides recommendations based on the range. sample size. Alternatively. 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.fnd_stats.Verifies CBO Statistics. ORACLE E-BUSINESS SUITE STANDALONE PATCHES (ORACLE 11G) E-BUSINESS SUITE VERSION PATCH 12.1. this implies that there is a correlation between the columns. Several of the values are only used by specific modules and therefore they are typically both referenced when querying data. which is one of the primary conditions for using extended statistics. 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 Total cardinality of the FND_LOOKUP_VALUES table: select count(1) from FND_LOOKUP_VALUES. - Describe the FND_LOOKUP_VALUES table... but when the where clause includes multiple columns from the same table. 1. ... Statistics without Extended Statistics 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 -----------. Incremental Statistics Gathering 3. - Check the updated statistics in dba_tables.'FND_LOOKUP_VALUES'). Essentially each row contains the QuickCode lookup type. its meaning. These values are used by “List of Values” across several of the Oracle E-Business Suite forms. the QuickCode itself. COUNT(1) ---------532559 - Run gather statistics on FND_LOOKUP_VALUES table: exec fnd_stats. Oracle 11g Extended Optimizer Statistics This simple example demonstrates how you might deploy the Oracle 11g extended (multi-column) optimizer statistics feature in Oracle E-Business Suite.Best Practices for Gathering Statistics with Oracle E-Business Suite Performance Test Cases & Examples 1. and hence the cardinality estimate. and in fact the LOOKUP_TYPE is dependent upon the VIEW_APPLICATION_ID.---------FND_LOOKUP_VALUES 532559 13 . num_rows from dba_tables where table_name='FND_LOOKUP_VALUES'.. which results in a better execution plan. select table_name. Concurrent Stats Gathering 1.. It stores Oracle Application Object Library QuickCode values. As such. the individual column statistics provide no indication of the relationship between the columns. Oracle 11g Extended Optimizer Statistics 2. easy to understand. The extended statistics increase the accuracy of the combined selectivity of the individual predicates. TABLE_NAME NUM_ROWS -----------------------------.--------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 . Recall that. and additional description (also other columns not directly pertinent to this example).gather_table_stats('APPLSYS'. and may be familiar as is used across several modules. individual column statistics provide the selectivity of a specific column. The FND_LOOKUP_VALUES table provides the basis for this example as it is suitably small. ---------. num_distinct.lookup_type. . select VIEW_APPLICATION_ID.null.8302E-06 1 NONE FND_LOOKUP_VALUES ENABLED_FLAG 4 .0219E-06 1 NONE FND_LOOKUP_VALUES DESCRIPTION 207029 4. Explained. TABLE_NAME COLUMN_NAME NUM_DISTINCT DENSITY NUM_BUCKETS HISTOGRAM --------------------------------------------. num_buckets. PLAN_TABLE_OUTPUT 14 .. select plan_table_output from table(dbms_xplan.3886E-07 87 FREQUENCY FND_LOOKUP_VALUES TERRITORY_CODE 10 .----------.-----------.000058129 1 NONE FND_LOOKUP_VALUES LANGUAGE 3 9.---------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 Check the data distribution in fnd_lookup_Values table.000011606 1 NONE FND_LOOKUP_VALUES MEANING 330917 3..--------FND_LOOKUP_VALUES LOOKUP_TYPE 17203 . - 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. histogram from user_tab_col_statistics where table_name = 'FND_LOOKUP_VALUES'.'serial'))..display('plan_table'. TABLE_NAME -----------------------------FND_LOOKUP_VALUES FND_LOOKUP_VALUES - COLUMN_NAME -----------------------------LANGUAGE VIEW_APPLICATION_ID Review the table data distribution.Best Practices for Gathering Statistics with Oracle E-Business Suite - The following histograms are already present in the FND data dictionary: select table_name.column_name from fnd_histogram_cols where table_name='FND_LOOKUP_VALUES'. column_name. select table_name. count(*) from FND_LOOKUP_VALUES group by VIEW_APPLICATION_ID. density.25 1 NONE FND_LOOKUP_VALUES SECURITY_GROUP_ID 17 .1 1 NONE .058823529 1 NONE FND_LOOKUP_VALUES VIEW_APPLICATION_ID 87 9.. VIEW_APPLICATION_ID ------------------3 3 3 3 3 222 8901 3 222 3 222 222 222 8405 3 8901 222 8901 200 3 3 3 3 3 0 222 3 3 8405 3 222 8901 3 - LOOKUP_TYPE COUNT(*) -----------------------------...3886E-07 3 FREQUENCY FND_LOOKUP_VALUES LOOKUP_CODE 86164 .lookup_type order by 3 desc. Explained. 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: 2 . - check if virtual column is created for the multi-columns involved for the extended statistics. PL/SQL procedure successfully completed.'serial')). select plan_table_output from table(dbms_xplan.display('plan_table'.access("LOOKUP_TYPE"='AE_ARIA_CODE' AND "VIEW_APPLICATION_ID"=3) 2.tabname => 'FND_LOOKUP_VALUES'.appl_id=>0. select table_name from fnd_extnstats_cols.null.load_extnstats_cols(action =>'INSERT'. In this example they are gathered manually so that the result can be seen immediately. Table analyzed. 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: 2 .histogram from dba_tab_cols where table_name like 'FND_LOOKUP_VALUES' and owner ='APPLSYS'.display('plan_table'.table_name. no rows selected - Delete the current statistics on FND_LOKUP_VALUES table analyze table applsys.load_extnstats_cols.colname2 =>'LOOKUP_TYPE'). select owner. Explained.null.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'. fnd_exnstats_cols is FND table which holds the columns on which extension stats will be created. - Steps to create multi column extended statistics - Query fnd_extnstats_cols table to confirm that extended statistics do not exist. select plan_table_output from table(dbms_xplan.fnd_lookup_values delete statistics. - Create extended statistics for the LOOKUP_TYPE and VIEW_APPLICATION_ID: set serveroutput on - Execute fnd_stats. Create multi column extension stats using fnd_stats exec fnd_stats.'serial')).Best Practices for Gathering Statistics with Oracle E-Business Suite ---------------------------------------------------------------------------------------------------| 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: 2 .colname1 =>'VIEW_APPLICATION_ID'. Statistics with Extended Stats The extended statistics approach will create a column statistics entry for the column group in the Data Dictionary.access("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'.column_name. OWNER 15 TABLE_NAME COLUMN_NAME HISTOGRAM . '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 .null.'FND_LOOKUP_VALUES').display('plan_table'.gather_table_stats('APPLSYS'.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. 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 . PL/SQL procedure successfully completed.table_name. select plan_table_output from table(dbms_xplan.'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 . select plan_table_output from table(dbms_xplan.null.-------------------ZD_EDITION_NAME NONE SYS_STU_L5AKW15J1DXUKXDMYW3UJF NONE - Above output shows that the virtual column “SYS_STU_L5AKW15J1DXUKXDMYW3UJF“ is created.-----------------------------------------APPLSYS FND_LOOKUP_VALUES ZD_EDITION_NAME APPLSYS - HISTOGRAM ------------NONE FND_LOOKUP_VALUES SYS_STU_L5AKW15J1DXUKXDMYW3UJF HEIGHT BALANCED 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.display('plan_table'. Explained.histogram from dba_tab_cols where table_name like 'FND_LOOKUP_VALUES' and owner ='APPLSYS'. - check if histogram is created on virtual column select owner.null.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'.Best Practices for Gathering Statistics with Oracle E-Business Suite -----------------------------APPLSYS APPLSYS APPLSYS -----------------FND_LOOKUP_VALUES FND_LOOKUP_VALUES FND_LOOKUP_VALUES -----------------------------. select plan_table_output from table(dbms_xplan.column_name.display('plan_table'. - Gather statistics on 'FND_LOOKUP_VALUES' to check if histogram is getting created on the virtual column exec fnd_stats. Explained.'serial')). OWNER TABLE_NAME COLUMN_NAME -----------------------------. 2. Check the statistics and global and partition level select table_name.Best Practices for Gathering Statistics with Oracle E-Business Suite --------------------------------------------------2 . Elapsed: 00:00:14. 1909409 rows created.'XLA_AE_LINES_BKP'). This simple example demonstrates how you might deploy the Oracle 11g incremental Statistics Gathering feature in Oracle EBusiness Suite.to_Char(last_analyzed. - Gathering stats usign fnd_Stats exec fnd_stats.xla_ae_lines_bkp where application_id=222.'DD-MON-YY HH24:MI:SS') "last_analyzed" from dba_Tab_partitions where table_name like 'XLA_AE_LINES_BKP'.06 - 17 After deleting the data ran gather stats without setting the preference.gather_table_stats('XLA'. Incremental Statistics Gathering Incremental statistics gathering is a new feature of 11G Database. - Test case without setting incremental preference set time on timing on exec fnd_stats. It took 14.06 sec .xla_ae_lines.06 - It took 29.06 sec to gather stats for the first time after data insertion.'DD-MON-YY HH24:MI:SS') "last_analyzed" from dba_Tables where table_name like 'XLA_AE_LINES_BKP'. 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: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 delete from xla.xla_Ae_lines_bkp select * from xla.access("LOOKUP_TYPE"='AE_ARIA_CODE' AND "VIEW_APPLICATION_ID"=3) Result: Above results shows the cardinality estimation changes after creating multi column extended stats.gather_table_stats('XLA'. PL/SQL procedure successfully completed. Elapsed: 00:00:29. Incremental stats will work only for partitioned tables where global statistics are updated incrementally by scanning only the partitions that have changed from the last run. - Create a table xla_ae_lines_bkp as a partition table to perform this test case Insert data from xla_ae_lines table insert into xla. TABLE_NAME last_analyzed -----------------------------. PL/SQL procedure successfully completed.'XLA_AE_LINES_BKP').-----------------------XLA_AE_LINES_BKP 23-SEP-12 07:04:34 select partition_name.to_Char(last_analyzed. Best Practices for Gathering Statistics with Oracle E-Business Suite - Checking global stats and partition stats select table_name. NOTE : statistics are gathered on all the partitions even though only AR parition data is deleted. 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: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. Elapsed: 00:00:22.'XLA'. exec dbms_stats.get_prefs('INCREMENTAL'. - - Perform the same test case after setting the preference to true. TABLE_NAME last_analyzed -----------------------------.-----------------------XLA_AE_LINES_BKP 23-SEP-12 07:10:26 select partition_name.-----------------------XLA_AE_LINES_BKP 23-SEP-12 07:17:32 select partition_name.to_Char(last_analyzed.xla_Ae_lines_bkp select * from xla.'XLA_AE_LINES_BKP') -----------------------------------------------------------TRUE - Gather statistics after setting the preference. - Check if the preference is set select dbms_stats.'DD-MON-YY HH24:MI:SS') "last_analyzed" from dba_Tables where table_name like 'XLA_AE_LINES_BKP'. Following command will set the incremental preference at the table level so next time when gather statistics is run.xla_ae_lines.set_table_prefs('XLA'. PL/SQL procedure successfully completed.'DD-MON-YY HH24:MI:SS') "last_analyzed" from dba_Tab_partitions where table_name like 'XLA_AE_LINES_BKP'. 1909409 rows created.GET_PREFS('INCREMENTAL'.91 sec to gather statistics for the first time after data insertion checking stats timing information select table_name.'INCREMENTAL'.to_Char(last_analyzed.'XLA_AE_LINES_BKP').'TRUE').'DD-MON-YY HH24:MI:SS') "last_analyzed" from dba_Tab_partitions where table_name like 'XLA_AE_LINES_BKP'.'XLA_AE_LINES_BKP') from dual. exec fnd_stats.'XLA'.'XLA_AE_LINES_BKP'. last_analyzed is updated for all the partitions. TABLE_NAME last_analyzed -----------------------------. DBMS_STATS.91 - After setting the preference it took 22. 18 .to_Char(last_analyzed.gather_table_stats('XLA'.'DD-MON-YY HH24:MI:SS') "last_analyzed" from dba_Tables where table_name like 'XLA_AE_LINES_BKP'. 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 insert into xla.to_Char(last_analyzed. delete from xla_ae_lines_bkp where application_id=222.-----------------------XLA_AE_LINES_BKP 23-SEP-12 07:26:20 select partition_name.'DD-MON-YY HH24:MI:SS') "last_analyzed" from dba_Tab_partitions where ta ble_name like 'XLA_AE_LINES_BKP'.gather_table_stats('XLA'. Elapsed: 00:00:04. 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: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.11 sec Check global and partition statistics select table_name. Elapsed: 00:00:00.'XLA_AE_LINES_BKP').'DD-MON-YY HH24:MI:SS') "last_analyzed" from dba_Tables where table_name like 'XLA_AE_LINES_BKP'. last_analyzed date is changed for only AR partition and timing has also reduced.11 - After deleting the data for one partition incremental gathering statistics took 4.01 Note : statistics are gathered. PL/SQL procedure successfully completed. 100233 rows deleted - Gather statistics after deleting data from application_id 222 partition AR exec fnd_stats. - Deleting the data from one partition to see how incremental statistics gathering will help next time when stats are gathered.Best Practices for Gathering Statistics with Oracle E-Business Suite 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.to_Char(last_analyzed. TABLE_NAME last_analyzed -----------------------------.to_Char(last_analyzed. 19 . Elapsed: 00:29:30.'TRUE'). we see fnd_stats (with parallel option.97 00:26:59.delete_table_stats('XLA'.delete_table_stats('XLA'.'XLA_AE_HEADERS').11 sec --------- 3.91 sec 14. PL/SQL procedure successfully completed.'FALSE').SET_GLOBAL_PREFS('CONCURRENT'.SET_GLOBAL_PREFS('CONCURRENT'.06 sec 22. - Concurrent statistics gathering is controlled by setting global preference exec DBMS_STATS.06 sec 04.97 - Set the global preference to TRUE exec DBMS_STATS. took 26 mins and 59 secs. Setting job_queue_processes to 10. - Setting concurrent preference to FALSE exec DBMS_STATS. system altered.'XLA_AE_HEADERS'). - To run statistics concurrently job_queue_processes should be set to more than 4 Test case to gather stats concurrently. - 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. And even this small gain could be explained by blocks already being in cache. Concurrent Statistics Gathering Concurrent statistics gathering is a new feature introduced in 11gR2.gather_table_stats('XLA'.'XLA_AE_HEADERS'). as fnd_stats runs by default with parallel option) with setting global preference to FALSE took 29 mins and 30 secs.54 Results of the test case: Method ---------FND_STATS FND_STATs ---------- Level (schema/table) --------------------table(XLA_AE_HEADERS) table(XLA_AE_HEADERS) --------------------- Concurrent processing option ---------------------------FALSE TRUE ---------------------------- Timing ----------00:29:30. - Delete the statistics exec dbms_stats. 20 . Concurrent statistics gathering is use to run stats on multiple table and partitions concurrently.Best Practices for Gathering Statistics with Oracle E-Business Suite - With the above test case we can see improvement in timings when incremental preference is set. This simple example demonstrates how you might deploy the Oracle 11g Concurrent Statistics Gathering feature in Oracle E-Business Suite.'XLA_AE_HEADERS'). - Gathering Statistics exec fnd_stats.54 ----------- From the above test cases. fnd_stats ran with setting global preference to TRUE. Elapsed: 00:26:59.'TRUE'). PL/SQL procedure successfully completed. We see a net gain of 2 mins 5 secs in the gather statistics timing.SET_GLOBAL_PREFS('CONCURRENT'. - Delete statistics on the table exec dbms_stats. - Gather statistics using fnd_stats exec fnd_stats.gather_table_stats('XLA'. alter system set job_queue_processes=10. indexes. This is available on the Oracle Optimizer blog: https://blogs.oracle.com/technetwork/database/focus-areas/bi-datawarehousing/twp-upgrading-10g-to-11g-what-to-ex133707. Blogs 21 . it includes a clear explanation of the different types of histograms and where they are applicable. Whitepapers These papers are generic and do not specifically focus on Oracle E-Business Suite.oracle. It also validates the statistics on tables and indexes owned by 'SYS'.sql .1) This script verifies the Optimizer statistics in the data dictionary for all tables. but create a clean baseline for non-application objects (data dictionary. • EBPERF FAQ . It should be considered as the source for many of the generic statements in this document.pdf My Oracle Support Knowledge Documents • Fixed Objects Statistics Considerations (Doc ID 798257.Automates CBO Stats Gathering using FND_STATS (Doc ID 156968. fixed objects and system performance).sql . missing or bad statistics on the x$/fixed tables that can lead to performance degradation or hangs.com/technetwork/database/bi-datawarehousing/dbbi-tech-info-optmztn-092214.1) This generic document summarizes problems including. for example.oracle. and collection frequency.com/optimizer/ and Oracle Technet: http://www.pdf • 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. • bde_last_analyzed.1) This interim solution provides recommendations based on the range. For example. and partitions. This could be considered a precursor to the Best Practices for Gathering Optimizer Statistics paper.com/technetwork/database/focus-areas/bi-datawarehousing/twp-optimizer-stats-concepts-110711-1354477. • Best Practices for Gathering Optimizer Statistics This paper provides an extensive overview of the Oracle Database statistics gathering process and is a useful precursor to this paper. This is available on Oracle Technet: http://www.oracle.Best Practices for Gathering Statistics with Oracle E-Business Suite Appendix A: Related Documentation This appendix contains important Oracle documents. • Managing CBO Stats during an upgrade to Oracle 10g or Oracle 11g (Doc ID 465787.Verifies CBO Statistics (Doc ID 163208. This is available on Oracle Technet: http://www. My Oracle Support Knowledge Documents and Blog references that provide useful information. sample size.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: • coe_stats.Collecting Statistics with Oracle EBS 11i and R12 (Doc ID 368252.html • Understanding Optimizer Statistics This document provides more foundation information about Optimizer statistics and related topics.1) The core idea presented is to continue gathering Optimizer statistics for application schemas as usual. 22 . Topics include the following • Extended Statistics • Concurrent Statistics Gathering • Maintaining statistics on large partitioned tables • Fixed Objects Statistics and why they are important In addition there are articles on other tuning related issues such as cardinality feedback.oracle.Best Practices for Gathering Statistics with Oracle E-Business Suite The Oracle Optimizer blog ( https://blogs.com/optimizer ) contains excellent generic information on a number of topics from the author of the Best Practices for Gathering Optimizer Statistics paper. Gather Table Statistics Concurrent Request Submission window Figure 1 shows an example of submitting Gather Table Statistics.GATHER_TABLE_STATS package. ensuring that they can be restored if necessary. Note that Estimate Percent is blank. It is also useful to update the statistics for a small set of tables when investigating performance of a single SQL statement. If left blank. This program calls the FND_STATS. Figure 1 : Oracle E-Business Suite . It is useful when collecting statistics for very large tables that have been excluded from the main gather statistics collection due to time constraints. a description of the parameters follows. In both cases they attempt to parallelize as much of the work as possible and can optionally backup the existing statistics in the FND_STATTAB table (only if the value of the backup flag parameter is BACKUP) before gathering new statistics.GATHER_TABLE_STATS PARAMETERS PARAMETER DESCRIPTION Owner Name The table owner. the parameters are shown in Table B1. Gather Table Statistics The Gather Table Statistics program gathers table. TABLE B1. Table Name The table name. Estimate Percent The sampling percentage. for 11g defaults to dbms_stats.auto_sample_size and for 23 .Best Practices for Gathering Statistics with Oracle E-Business Suite Appendix B: Package Specifications This appendix describes the Gather Table Statistics and Gather Schema Statistics programs. column and index statistics. FND_STATS. FULL and NONE. • PARTITION . This parameter is ignored prior to Oracle 9iR2 . This indicates whether dependent cursors should be invalidated. Backup Flag Specify BACKUP to back up your statistics. Partition Name The partition name. Degree The degree of parallelism to be used when gathering statistics. it defaults to the minimum of parallel_max_servers and cpu_count. • SUBPARTITION . (BACKUP/NOBACKUP) Granularity The granularity of statistics to collect (only relevant for partitioned tables).Best Practices for Gathering Statistics with Oracle E-Business Suite 10g and prior it the default value of 10 is used. include LASTRUN. partition. The options.Gather partition–level statistics.Gather global and partition–level statistics. and global) statistics. which are discussed in the History Mode section. Valid values are: • DEFAULT . If a Degree is not provided. The valid range is from 0 to 100. The default is LASTRUN.Gather global statistics.Gather all (subpartition. • ALL . • GLOBAL . History Mode Invalidate Dependent Cursors 24 This parameter controls the number of history records.Gather subpartition–level statistics. column and index statistics for every object in the schema. it may be useful to exclude very large tables and schedule these at different times. When the collection time exceeds the available time slot. If left blank. This is the recommended process to run in order to update Oracle E-Business Suite statistics. which can be queried from the FND_STATS_HIST table. for the request that failed.Best Practices for Gathering Statistics with Oracle E-Business Suite Gather Schema Statistics The Gather Schema Statistics program gathers table. This program calls the FND_STATS. 25 .auto_sample_size and for 10g and prior it the default value of 10 is used. is captured when the program is started from concurrent manager or will be automatically created if the FND_STATS.Gather Schema Statistics Concurrent Request Submission window Figure 2 shows an example of submitting Gather Schema Statistics. for 11g defaults to dbms_stats.GATHER_SCHEMA_STATS is used directly or in a custom script. can restart it. supplying the request ID. TABLE B2: FND_STATS. Various considerations are explained throughout the main part of this paper. If this procedure fails at any time during operation. a description of the parameters follows. Note that Estimate Percent is blank.GATHER_SCHEMA_STATS package. Estimate percent The sampling percentage. The valid range is from 0 to 100. The request ID. the parameters are shown in Table B2.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. Figure 2 : Oracle E-Business Suite . 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. Gather Options This parameter specifies how objects are selected for statistics gathering. 26 . FULL and NONE.Statistics are gathered only for tables and indexes that are missing statistics. Backup Flag Specify BACKUP to back up your statistics.It only provides a list of objects for gather statistics if GATHER_AUTO is used. History Mode This parameter controls the number of history records. Default value is MIN (DB init parameters: parallel_max_servers. include LASTRUN. • GATHER_AUTO .Tables of the schema schemaname for which the percentage of modifications has exceeded modpercent are selected for statistics gathering. The options. • GATHER (Default) . Invalidate Dependent Cursors This indicates whether dependent cursors should be invalidated. it can be re-submitted with this parameter and it will pick up where the failed run left off.Best Practices for Gathering Statistics with Oracle E-Business Suite Degree The degree of parallelism for gathering statistics. which are discussed in the History Mode section. The default is LASTRUN. • LIST_EMPTY . cpu_count).All schema tables and indexes are selected for statistics gathering. • GATHER_EMPTY . (BACKUP/NOBACKUP) Restart Request ID If the Gather Schema Statistics run failed or was stopped. Modification Threshold This option is applicable only to GATHER AUTO and LIST AUTO options.It only provides a list of objects for gather statistics if GATHER_EMPTY is used. • LIST_AUTO . The default is 'Y'. Table monitoring needs to be enabled before using this option. This document is not warranted to be error-free. Oracle E-Business Suite Aug 2013 Authors: Deepak Bhatnagar. Oracle E-Business Suite Performance Group Oracle and Java are registered trademarks of Oracle and/or its affiliates.650. electronic or mechanical. CA 94065 U. without our prior written permission.com Intel and Intel Xeon are trademarks or registered trademarks of Intel Corporation. 0113 . This document may not be reproduced or transmitted in any form or by any means. All rights reserved. Inc.7000 Fax: +1. Opteron.A. and the AMD Opteron logo are trademarks or registered trademarks of Advanced Micro Devices. Oracle and/or its affiliates. UNIX is a registered trademark of The Open Group. and the contents hereof are subject to change without notice. and no contractual obligations are formed either directly or indirectly by this document.Best Practices for Gathering Statistics with Copyright © 2013. for any purpose.7200 oracle.506. the AMD logo.650. whether expressed orally or implied in law. Mohammed Saleem. including implied warranties and conditions of merchantability or fitness for a particular purpose. Oracle Corporation World Headquarters 500 Oracle Parkway Redwood Shores. Other names may be trademarks of their respective owners. nor subject to any other warranties or conditions. We specifically disclaim any liability with respect to this document.S. Worldwide Inquiries: Phone: +1. Andy Tremayne Editor: Robert Farrington This document is provided for information purposes only.506. All SPARC trademarks are used under license and are trademarks or registered trademarks of SPARC International. AMD.
Copyright © 2024 DOKUMEN.SITE Inc.