DBMS_STATS.SET_GLOBAL_PREFS ( pname IN VARCHAR2, pvalue IN VARCHAR2);
DBMS_STATS.SET_DATABASE_PREFS ( pname IN VARCHAR2, pvalue IN VARCHAR2, add_sys IN BOOLEAN DEFAULT FALSE);
DBMS_STATS.SET_SCHEMA_PREFS ( ownname IN VARCHAR2, pname IN VARCHAR2, pvalue IN VARCHAR2);
DBMS_STATS.SET_TABLE_PREFS ( ownname IN VARCHAR2, tabname IN VARCHAR2, pname IN VARCHAR2, pvalue IN VARCHAR2);
DBMS_STATS.Constants Name TypeValue AUTO_CASCADE BOOLEAN NULL AUTO_DEGREE NUMBER 32768 AUTO_INVALIDATE BOOLEAN NULL AUTO_SAMPLE_SIZE NUMBER 0
pname:Preference name. The default value for following preferences can be set:CASCADE、DEGREE、ESTIMATE_PERCENT、METHOD_OPT、NO_INVALIDATE、GRANULARITY、PUBLISH、INCREMENTAL、STALE_PERCENT
pvalue:Preference value. If NULL is specified, it will set the Oracle default value.
CASCADE - Determines whether or not index statistics are collected as part of gathering table statistics. 確定是否收集索引統計信息作為收集表統計信息的一部分。 默認值是DBMS_STATS.AUTO_CASCADE,AUTO_CASCADE的默認值是NULL,也就是false,因為_optimizer_compute_index_stats隱含參數指明了只有創建或重建索引時才會自動收集索引的統計信息force index stats collection on index creation/rebuild
DEGREE - Determines degree of parallelism used for gathering statistics. 確定用于收集統計數據的并行度 默認值是DBMS_STATS.AUTO_DEGREE,oracle基于基于對象的大小,CPU的數量和初始化參數來自動決定的。based on size of the object, number of CPUs and initialization parameters
ESTIMATE_PERCENT - Determines the percentage of rows to estimate. The valid range is [0.000001,100]. Use the constant DBMS_STATS.AUTO_SAMPLE_SIZE to have Oracle determine the appropriate sample size for good statistics. This is the default. 確定要估計的行的百分比。 有效范圍是[0.000001,100]。 使用常量DBMS_STATS.AUTO_SAMPLE_SIZE來擁有Oracle確定適當的樣本量以獲得良好的統計數據 默認值是DBMS_STATS.AUTO_SAMPLE_SIZE,oracle使用自動樣本大小算法,Indicates that auto-sample size algorithms should be used
METHOD_OPT - Controls column statistics collection and histogram creation. It accepts either of the following options, or both in combination: FOR ALL [INDEXED | HIDDEN] COLUMNS [size_clause] FOR COLUMNS [size clause] column [size_clause] [,column [size_clause]...] size_clause is defined as size_clause := SIZE {integer | REPEAT | AUTO | SKEWONLY} column is defined as column := column_name | extension name | extension - integer : Number of histogram buckets. Must be in the range [1,254]. - REPEAT : Collects histograms only on the columns that already have histograms - AUTO : Oracle determines the columns to collect histograms based on data distribution and the workload of the columns. - SKEWONLY : Oracle determines the columns to collect histograms based on the data distribution of the columns. - column_name : Name of a column - extension : Can be either a column group in the format of (column_name, colume_name [, ...]) or an expression The default is FOR ALL COLUMNS SIZE AUTO. 控制列統計信息收集和直方圖創建。 它接受以下選項之一,或兩者組合 size_clause使用整數:就是把所有數據分成XX份來采樣
NO_INVALIDATE - The value controls the invalidation of dependent cursors of the tables for which statistics are being gathered. Does not invalidate the dependent cursors if set to TRUE. The procedure invalidates the dependent cursors immediately if set to FALSE. Use DBMS_STATS.AUTO_INVALIDATE to have Oracle decide when to invalidate dependent cursors. This is the default. 該值控制正在收集統計信息的表的從屬游標(即依賴該表的執行計劃)的無效。 不會使依賴關系無效光標如果設置為TRUE。 如果設置為FALSE,則該過程立即使依賴游標無效。 true:當收集完統計信息后,收集對象的cursor不會失效(不會產生新的執行計劃) false:當收集完統計信息后,收集對象的cursor會立即失效(產生新的執行計劃) 默認值DBMS_STATS.AUTO_INVALIDATE,受參數_optimizer_invalidation_period控制,默認是18000秒即5小時。
GRANULARITY - Determines granularity of statistics to collect (only pertinent if the table is partitioned) 確定要收集的統計信息的粒度(僅在表被分區時才相關)
PUBLISH - Determines whether or not newly gathered statistics will be published once the gather job has completed. Prior to Oracle Database 11g, Release 1 (11.1), once a statistic gathering job completed the new statistics were automatically published into the dictionary tables. The user now has the ability to gather statistics but not publish them immediately. This allows the DBA to test the new statistics before publishing them. 確定收集作業完成后是否新發布的統計信息將被發布。 在Oracle Database 11g第1版(11.1)之前,一旦統計收集工作完成,新的統計數據就會自動發布到字典表中。 用戶現在有能力收集統計,但不立即發布。 這樣DBA可以在發布新的統計信息之前測試新的統計信息
INCREMENTAL - Determines whether or not the global statistics of a partitioned table will be maintained without doing a full table scan. With partitioned tables it is very common to load new data into a new partition. As new partitions are added and data loaded, the global table statistics need to be kept up to date. Oracle will update the global table statistics by scanning only the partitions that have been changed instead of the entire table if the following conditions hold: INCREMENTAL value for the partitioned table is set to TRUE; PUBLISH value for the partitioned table is set to TRUE; User specifies AUTO_SAMPLE_SIZE for ESTIMATE_PERCENT and AUTO for GRANULARITY when gathering statistics on the table. If the INCREMENTAL value for the partitioned table was set to FALSE (default value), a full table scan is used to maintain the global statistics which is a much more resource intensive and time-consuming operation for large tables. 確定在不進行全表掃描的情況下,是否維護分區表的全局統計信息。使用分區表將新數據加載到新分區中非常常見。 隨著添加新分區和加載數據,全局表統計信息需要保持最新狀態。如果滿足以下條件,則僅掃描已更改的分區而不是整個表的更新全局表統計信息: 分區表的INCREMENTAL值設置為TRUE; 分區表的PUBLISH值設置為TRUE; 在收集表上的統計信息時,用戶為ESTIMATE_PERCENT指定AUTO_SAMPLE_SIZE,并為GRANULARITY指定AUTO。 如果分區表的INCREMENTAL值設置為FALSE(默認值),則使用全表掃描來維護全局統計信息更大的資源密集和耗時的大型桌面操作。
STALE_PERCENT - Determines the percentage of rows in a table that have to change before the statistics on that table are deemed stale and should be regathered. The valid domain for stale_percent is non-negative numbers. The default value is 10%. 確定表中必須更改的行的百分比,該表之前的統計信息被視為過時且應該被歸并。該stale_percent的有效域是非負數。 默認值為10%