zoukankan      html  css  js  c++  java
  • Oracle统计分析

    1.oracle11g查看自动收集统计信息是否开启

    SQL> select client_name,status from dba_autotask_client;
    
    CLIENT_NAME                                                      Status
    ---------------------------------------------------------------- --------
    auto optimizer stats collection                                  ENABLED
    

     https://blog.csdn.net/xqzhang8/article/details/72758208

     2.手动分析某张表

    exec dbms_stats.gather_table_ststs('ownname','tabname');

    DBMS_STATS.GATHER_TABLE_STATS (   ownname          VARCHAR2,     tabname          VARCHAR2,     partname         VARCHAR2,   estimate_percent NUMBER,     block_sample     BOOLEAN,   method_opt       VARCHAR2,   degree           NUMBER,   granularity      VARCHAR2,     cascade          BOOLEAN,   stattab          VARCHAR2,     statid           VARCHAR2,   statown          VARCHAR2,   no_invalidate    BOOLEAN,   force            BOOLEAN);
    
    参数说明:
    ownname:要分析表的拥有者
    tabname:要分析的表名.
    partname:分区的名字,只对分区表或分区索引有用.
    estimate_percent:采样行的百分比,取值范围[0.000001,100],null为全部分析,不采样. 常量:DBMS_STATS.AUTO_SAMPLE_SIZE是默认值,由oracle决定最佳取采样值.
    block_sapmple:是否用块采样代替行采样.
    method_opt:决定histograms信息是怎样被统计的.method_opt的取值如下(默认值为FOR ALL COLUMNS SIZE AUTO):
    for all columns:统计所有列的histograms.
    for all indexed columns:统计所有indexed列的histograms.
    for all hidden columns:统计你看不到列的histograms
    for columns <list> SIZE <N> | REPEAT | AUTO | SKEWONLY:统计指定列的histograms.N的取值范围[1,254]; REPEAT上次统计过的histograms;AUTO由oracle决定N的大小;SKEWONLY multiple end-points with the same value which is what we define by "there is skew in thedata
    degree:决定并行度.默认值为null.
    granularity:Granularity of statistics to collect ,only pertinent if the table is partitioned.
    cascade:是收集索引的信息.默认为FALSE.
    stattab:指定要存储统计信息的表,statid如果多个表的统计信息存储在同一个stattab中用于进行区分.statown存储统计信息表的拥有者.以上三个参数若不指定,统计信息会直接更新到数据字典.
    no_invalidate: Does not invalidate the dependent cursors if set to TRUE. The procedure invalidates the dependent cursors immediately if set to FALSE.
    force:即使表锁住了也收集统计信息.
    例子:
    execute dbms_stats.gather_table_stats(ownname => 'owner',tabname => 'table_name' ,estimate_percent => null ,method_opt => 'for all indexed columns' ,cascade => true)
    

     3.对象统计信息锁定的解决办法(ORA-20005/ORA-38029)

      解锁单个对象
      先查出被锁定的表select table_name from user_tab_statistics where stattype_locked is not null;
      然后再解锁对象
      exec dbms_stats.unlock_table_stats(user,'表名');

    参考资料:

    https://www.cndba.cn/Expect-le/article/1900 

    https://www.linuxidc.com/Linux/2011-07/39435p2.htm

  • 相关阅读:
    由Highcharts加载提示想到的:我想要的别人已经做好了
    ajaxmin js压缩和VS(转1)
    ajaxmin js压缩和VS(转2)
    Silverlight客户端怎样获取外部参数
    SQL中的事务
    qt webkit 中文乱码问题 另辟蹊径
    密码学基础(1)
    使用jQuery的属性[attr]筛选
    Leetcode NO.19 Remove Nth Node From End Of List && 移除链表倒数第n个节点
    经典排序算法(一) —— Selection Sort 选择排序
  • 原文地址:https://www.cnblogs.com/jycjy/p/11208212.html
Copyright © 2011-2022 走看看