analyze表或索引会不会产生Histogram信息?

来源:互联网 发布:软件开发薪资待遇 编辑:程序博客网 时间:2024/05/18 13:48

下面做实验来验证,analyze表或索引的时候,会不会产生Histogram信息.

数据库版本: 9.2.0.4.0

操作系统平台: Solaris 9

SQL> desc test
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 NAME                                               VARCHAR2(20)
 CHENFENG                                           DATE

SQL> analyze table test delete statistics;

Table analyzed.

只分析表:

SQL> analyze table test compute statistics for table;

Table analyzed.

SQL> select count(*) from dba_tab_histograms where table_name = 'TEST';

  COUNT(*)
----------
         0 

---不产生Histogram信息!

SQL> analyze table test delete statistics;

Table analyzed.

SQL>  select count(*) from dba_tab_histograms where table_name = 'TEST';

  COUNT(*)
----------
         0

只分析索引:
SQL> analyze table test compute statistics for all indexes;

Table analyzed.

SQL> select count(*) from dba_tab_histograms where table_name = 'TEST';

  COUNT(*)
----------
         0

---不产生Histogram信息!

SQL> analyze table test delete statistics;

Table analyzed.

SQL> select count(*) from dba_tab_histograms where table_name = 'TEST';

  COUNT(*)
----------
         0

对索引列进行分析:

SQL>  analyze table test compute statistics for table for all columns;

Table analyzed.

SQL> select count(*) from dba_tab_histograms where table_name = 'TEST';          

  COUNT(*)
----------
        21

---产生Histogram信息.

SQL>  analyze table test delete  statistics;

Table analyzed.

SQL> select count(*) from dba_tab_histograms where table_name = 'TEST';

  COUNT(*)
----------
         0

默认的COMPUTE STATISTICS对表进行分析:

SQL> analyze table test compute statistics;

Table analyzed.

SQL> select count(*) from dba_tab_histograms where table_name = 'TEST';

  COUNT(*)
----------
         4
---产生Histogram信息. 

从上面的试验,关于Analyze和Histogram,我们可以得到如下结论:

 只要对列进行分析的话,就会产生Histogram信息。而光对表,索引进行分析的话,则不会产生Histogram,而且默认的COMPUTE | ESTIMATE STATISTICS; 对表进行分析是会产生Histogram的,因为它默认的会加上for all columns

原创粉丝点击