设为首页 加入收藏

TOP

使用DBMS_STATS来收集统计信息(十一)
2014-11-24 03:16:03 来源: 作者: 【 】 浏览:1
Tags:使用 DBMS_STATS 收集 统计 信息
c dbms_stats.flush_database_monitoring_info; PL/SQL procedure successfully completed.

Step 7 : Check for what it has collected.

As user "scott", check USER_TAB_MODIFICATIONS to see what it was collected.
SELECT * FROM user_tab_modifications;

TABLE_NAME PARTITION_NAME SUBPARTITION_NAME INSERTS UPDATES DELETES TIMESTAMP TRUNCATED
---------- -------------- ----------------- ------- ------- ------- --------- ---------
EMP                                               0       0     500 18-SEP-02 NO

Step 8 : Execute DBMS_STATS to gather stats on all "stale" tables.

BEGIN
  DBMS_STATS.GATHER_SCHEMA_STATS(
    ownname           => 'scott',
    estimate_percent  => null,
    block_sample      => false,
    method_opt        => 'FOR ALL COLUMNS',
    degree            => null,
    granularity       => 'ALL',
    cascade           => true,
    options           => 'GATHER STALE');
END;
/

PL/SQL procedure successfully completed.

Step 9 : Verify that the table is no longer listed in USER_TAB_MODIFICATIONS.

SQL> SELECT * FROM user_tab_modifications;

no rows selected.

Step 10 : Examine some of new statistics collected.

SELECT table_name, num_rows, blocks, avg_row_len    
FROM user_tables where table_name='EMP';

TABLE_NAME                       NUM_ROWS     BLOCKS AVG_ROW_LEN
------------------------------ ---------- ---------- -----------
EMP                                  1000         28          92

How to determine if dictionary statistics are RDBMS-generated or user-defined

The following section explains how to determine if your dictionary statistics are RDBMS-generated or set by users through one of the DBMS_STATS.SET_xx_STATS procedures.

This is crucial for development environments that are testing the performance of SQL statements with various sets of statistics. The DBA will need to know if the relying statistics are RDBMS-defined or user-defined.

RDBMS-generated statistics are generated by the following:(我们可以通过如下方式生成统计信息)

ANALYZE SQL commandDBMS_UTILITY.ANALYZE_SCHEMA procedureDBMS_UTILITY.ANALYZE_DATABASE procedureDBMS_DDL.ANALYZE_OBJECT procedure8.1 DBMS_STATS.GATHER_xx_STATS procedures User generated statistics are only done through the use of the DBMS_STATS.SET_xx_STATS procedures(如果我们需要手工设置统计信息,只可以通过dbms_stats包的set_xx_stats过程来实现)

The column USER_STATS from DBA_TABLES, ALL_TABLES, USER_TABLES displays:

YES, when statistics are entered directly by a user.NO, when statistics are generated by RDBMS through an ANALYZE statement(如果USER_STATS字段的值为Yes,则统计信息为手工指定,NO,为通过dbms或者analyze方式 系统生成)
首页 上一页 8 9 10 11 下一页 尾页 11/11/11
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇各类数据库通过sql查询表字段的注.. 下一篇为过程或函数指定了过多的参数

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·C++中智能指针的性能 (2025-12-25 03:49:29)
·如何用智能指针实现c (2025-12-25 03:49:27)
·如何在 C 语言中管理 (2025-12-25 03:20:14)
·C语言和内存管理有什 (2025-12-25 03:20:11)
·为什么C语言从不被淘 (2025-12-25 03:20:08)