`
li.feixiang
  • 浏览: 121266 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
社区版块
存档分类
最新评论

DBMS_STATS.GATHER_SCHEMA_STATS Procedures

阅读更多

This procedure gathers statistics for all objects in a schema.

Syntax

DBMS_STATS.GATHER_SCHEMA_STATS ( 
   ownname          VARCHAR2, 
   estimate_percent NUMBER   DEFAULT to_estimate_percent_type 
                                                (get_param('ESTIMATE_PERCENT')), 
   block_sample     BOOLEAN  DEFAULT FALSE, 
   method_opt       VARCHAR2 DEFAULT get_param('METHOD_OPT'),
   degree           NUMBER   DEFAULT to_degree_type(get_param('DEGREE')), 
   granularity      VARCHAR2 DEFAULT GET_PARAM('GRANULARITY'), 
   cascade          BOOLEAN  DEFAULT to_cascade_type(get_param('CASCADE')), 
   stattab          VARCHAR2 DEFAULT NULL, 
   statid           VARCHAR2 DEFAULT NULL, 
   options          VARCHAR2 DEFAULT 'GATHER', 
   objlist          OUT      ObjectTab,
   statown          VARCHAR2 DEFAULT NULL, 
   no_invalidate    BOOLEAN  DEFAULT to_no_invalidate_type (
                                     get_param('NO_INVALIDATE')),
  force             BOOLEAN DEFAULT FALSE);
   
DBMS_STATS.GATHER_SCHEMA_STATS ( 
   ownname          VARCHAR2, 
   estimate_percent NUMBER   DEFAULT to_estimate_percent_type 
                                                (get_param('ESTIMATE_PERCENT')), 
   block_sample     BOOLEAN  DEFAULT FALSE, 
   method_opt       VARCHAR2 DEFAULT get_param('METHOD_OPT'), 
   degree           NUMBER   DEFAULT to_degree_type(get_param('DEGREE')), 
   granularity      VARCHAR2 DEFAULT GET_PARAM('GRANULARITY'), 
   cascade          BOOLEAN  DEFAULT to_cascade_type(get_param('CASCADE')), 
   stattab          VARCHAR2 DEFAULT NULL, 
   statid           VARCHAR2 DEFAULT NULL, 
   options          VARCHAR2 DEFAULT 'GATHER', 
   statown          VARCHAR2 DEFAULT NULL, 
   no_invalidate    BOOLEAN  DEFAULT to_no_invalidate_type (
                                     get_param('NO_INVALIDATE'), 
   force            BOOLEAN DEFAULT FALSE);
 

 

Parameters

Table 103-30 GATHER_SCHEMA_STATS Procedure Parameters

Parameter Description

ownname

Schema to analyze (NULL means current schema)

estimate_percent

Percentage of rows to estimate (NULL means compute): 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.The default value can be changed using the SET_PARAM Procedure .

block_sample

Whether or not to use random block sampling instead of random row sampling. Random block sampling is more efficient, but if the data is not randomly distributed on disk, then the sample values may be somewhat correlated. Only pertinent when doing an estimate statistics.

method_opt

Accepts:

  • FOR ALL [INDEXED | HIDDEN] COLUMNS [size_clause]

  • FOR COLUMNS [size clause] column|attribute [size_clause] [,column|attribute [size_clause]...]

size_clause is defined as size_clause := SIZE {integer | REPEAT | AUTO | SKEWONLY}


- 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.

The default is FOR ALL COLUMNS SIZE AUTO .The default value can be changed using the SET_PARAM Procedure .

degree

Degree of parallelism. The default for degree is NULL . The default value can be changed using the SET_PARAM Procedure . NULL means use the table default value specified by the DEGREE clause in the CREATE TABLE or ALTER TABLE statement. Use the constant DBMS_STATS.DEFAULT_DEGREE to specify the default value based on the initialization parameters.The AUTO_DEGREE value determines the degree of parallelism automatically. This is either 1 (serial execution) or DEFAULT_DEGREE (the system default value based on number of CPUs and initialization parameters) according to size of the object.

granularity

Granularity of statistics to collect (only pertinent if the table is partitioned).

'ALL' - gathers all (subpartition, partition, and global) statistics

'AUTO' - determines the granularity based on the partitioning type. This is the default value.

'DEFAULT' - gathers global and partition-level statistics. This option is obsolete, and while currently supported, it is included in the documentation for legacy reasons only. You should use the 'GLOBAL AND PARTITION ' for this functionality. Note that the default value is now 'AUTO '.

'GLOBAL' - gathers global statistics

'GLOBAL AND PARTITION ' - gathers the global and partition level statistics. No subpartition level statistics are gathered even if it is a composite partitioned object.

'PARTITION '- gathers partition-level statistics

'SUBPARTITION' - gathers subpartition-level statistics.

cascade

Gather statistics on the indexes as well.Index statistics gathering is not parallelized. Using this option is equivalent to running the GATHER_INDEX_STATS Procedure on each of the indexes in the schema in addition to gathering table and column statistics. Use the constant DBMS_STATS.AUTO_CASCADE to have Oracle determine whether index statistics to be collected or not. This is the default. The default value can be changed using the SET_PARAM Procedure .

stattab

User statistics table identifier describing where to save the current statistics

statid

Identifier (optional) to associate with these statistics within stattab

options

Further specification of which objects to gather statistics for:

GATHER : Gathers statistics on all objects in the schema.

GATHER AUTO : Gathers all necessary statistics automatically. Oracle implicitly determines which objects need new statistics, and determines how to gather those statistics. When GATHER AUTO is specified, the only additional valid parameters are ownname , stattab , statid , objlist and statown ; all other parameter settings are ignored. Returns a list of processed objects.

GATHER STALE : Gathers statistics on stale objects as determined by looking at the *_tab_modifications views. Also, return a list of objects found to be stale.

GATHER EMPTY : Gathers statistics on objects which currently have no statistics. also, return a list of objects found to have no statistics.

LIST AUTO : Returns a list of objects to be processed with GATHER AUTO .

LIST STALE : Returns list of stale objects as determined by looking at the *_tab_modifications views.

LIST EMPTY : Returns list of objects which currently have no statistics.

objlist

List of objects found to be stale or empty

statown

Schema containing stattab (if different than ownname )

no_invalidate

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. The default can be changed using the SET_PARAM Procedure .

force

Gather statistics on objects even if they are locked


Usage Notes

DBMS_STATS.GATHER_SCHEMA_STATS generates differing sampling rates on partitioned tables when you use the auto_sample_size constant. DBMS_STATS tries to determine an adequate sample size for each type of statistic, which is different for each table or column (and each partition, if partitioned). It starts with a sampling rate to get approximately 5000 rows and examines the result based on statistical equations. This process is repeated with increased sampling rate for unsatisfactory results.

In general, the number of distinct values column statistics requires the highest sampling rate among the others, especially when each distinct value repeats a small number of times.

When you use a specific value for the sampling percentage, DBMS_STATS honors it except for when:

  • The result is less than 2500 rows (too small a sample) and

  • The specified percentage is more than the certain percentage.

Statistics for external tables are not collected by this procedure.

Exceptions

ORA-20000 : Schema does not exist or insufficient privileges.

ORA-20001 : Bad input value.

分享到:
评论

相关推荐

    DBMS_STATS.GATHER_TABLE_STATS详解.pdf

    ### DBMS_STATS.GATHER_TABLE_STATS详解 #### 一、概述 `DBMS_STATS.GATHER_TABLE_STATS` 是 Oracle 数据库中的一个重要过程,主要用于收集表、列和索引的统计信息,这些统计信息对于优化器选择合适的执行计划至关...

    使用dbms_stats包手工收集统计信息

    在使用 dbms_stats.gather_schema_stats 过程时,如果你想要知道自从上一次分析统计数据以来,发生了多少次插入、更新和删除操作,可以使用 alter table xxx monitoring 命令,Oracle 会用 dba_tab_modifications ...

    DBMS_RANDOM.VALUE OR DBMS_RANDOM.STRING

    在Oracle数据库系统中,`DBMS_RANDOM`是一个非常实用的包,它提供了生成随机数和随机字符串的功能。这个包在各种场景下都有广泛的应用,比如在测试数据的生成、模拟随机行为或者创建伪随机数据时。我们将深入探讨`...

    Oracle统计分析-dbms_stats.pdf

    在收集统计数据阶段,dbms_stats 可以使用不同的选项来控制统计的刷新方式,例如 gather、gather empty、gather stale 和 gather auto。其中,gather auto 是最常用的选项,它可以重新分析当前没有统计的对象,以及...

    Metalink_DBMS_STATS.doc

    【 Metalink 和 DBMS_STATS 知识点详解】 在Oracle数据库管理中,收集表和索引的统计信息对于优化器(Cost-Based Optimizer, CBO)做出高效的查询计划至关重要。传统上,有两种方法来收集这些统计信息:ANALYZE(或...

    dbms_stats.docx

    - **GATHER**:重新分析整个架构(Schema)的所有对象。 - **GATHEREMPTY**:仅分析那些目前还没有统计信息的表。 - **GATHERSTALE**:仅重新分析那些自上次收集统计信息后修改量超过10%的表。这里的“修改”包括...

    Oracle 18c bug 执行 DBMS_PDB.CHECK_PLUG_COMPATIBILITY报错_ITPUB博客.mhtml

    Oracle 18c bug 执行 DBMS_PDB.CHECK_PLUG_COMPATIBILITY报错_ITPUB博客.mhtml

    DBMS_SQL.rar_dbms_oracle

    在Oracle数据库系统中,DBMS_SQL是一个非常重要的包,它提供了动态执行SQL语句的功能,这对于开发复杂的数据库应用或者需要在运行时构建SQL语句的情况非常有用。DBMS_SQL允许我们处理那些在编译时未知的SQL语句,极...

    怎样禁用及回收java的授权dbms_java

    ### 如何禁用及回收Java的授权:dbms_java 授权管理详解 #### 一、引言 在Oracle数据库环境中,`dbms_java`包提供了一系列功能强大的工具,用于管理和控制Java应用程序的安全性。这对于那些在Oracle环境中部署了...

    [Oracle] dbms_metadata.get_ddl 的使用方法总结

    Oracle数据库中的`dbms_metadata.get_ddl`是一个非常实用的包,它允许开发人员和管理员获取数据库对象的创建语句(DDL),这对于备份和恢复、迁移或者理解对象定义非常有帮助。下面我们将深入探讨`dbms_metadata.get...

    oracle dbms_lob

    Oracle数据库系统中,`DBMS_LOB`是一个重要的PL/SQL包,专门用于处理大型对象(LOBs,Large Object)。LOBs是Oracle提供的一种数据类型,用于存储大量数据,如文本、图像、音频或视频文件等。这个包包含了各种过程和...

    PostgreSQL_DBMS_for_Windows_922_136133.exe

    支持ArcGIS10.2版本的PostgreSQL_DBMS_for_windows_922,ESRI官方原版资源。

    dbms_comp_advisor.getratio 预估压缩比例的存储过程脚本

    本文将详细讲解"dbms_comp_advisor.getratio"存储过程,它是Oracle数据库用来预估数据压缩比例的工具,尤其在11gR2版本之前广泛使用。在11gR2之后,Oracle引入了内置的功能来替代这个过程,但理解其工作原理对于理解...

    DBMS_XMLDOM DBMS_XMLPARSER DBMS_XMLQUERY 文档

    Oracle数据库系统提供了强大的XML处理能力,这主要体现在其内置的几个PL/SQL包上,如DBMS_XMLDOM、DBMS_XMLPARSER和DBMS_XMLQUERY。这些包为开发者提供了处理XML文档的一整套工具,使得在数据库环境中进行XML数据的...

    DBMS_SQL的使用

    ### Oracle DBMS_SQL 使用详解 #### 一、概述 在Oracle数据库中,`DBMS_SQL`包是一个功能强大的工具,用于执行动态SQL语句。它提供了处理动态SQL语句的能力,使得开发人员能够灵活地构建和执行SQL语句,而不需要...

    调整数据库时区版本脚本DBMS_DST_scriptsV1.9.zip

    亲测有效 通过此版本可以把oracle时区版本调整到为最新版本,一般配合时区补丁使用 可以参考...脚本里有说明 先运行upg_tzv_check.sql再运行upg_tzv_apply.sql

    dbms_obfuscation_toolkit加密解密数据

    ### DBMS_OBFUSCATION_TOOLKIT:Oracle 数据库中的加密与解密工具包 DBMS_OBFUSCATION_TOOLKIT是Oracle数据库提供的一种用于数据加密解密的强大工具包,自Oracle 8i版本开始引入。它支持多种加密算法,如DES、...

    十万个为什么_Oracle.docx

    execute dbms_stats.gather_table_stats('数据库用户名', '表名', estimate_percent => DBMS_STATS.AUTO_SAMPLE_SIZE, method_opt => 'FOR ALL COLUMNS SIZE AUTO', cascade => TRUE); ``` - 参数解释: - `...

    ORACLE DBMS STATS ERROR

    然而,当出现错误“ORA-04063: package body 'SYS.DBMS_REGISTRY_SYS' has errors”时,表明`DBMS_STATS`包或与其相关的`SYS.DBMS_REGISTRY_SYS`包体存在错误,这可能对数据库性能和正常操作造成影响。 **问题症状*...

Global site tag (gtag.js) - Google Analytics