• 搜集直方图repeat和skewonly


    SQL> set linesize 200
    SQL>   select a.column_name,
                       b.num_rows,
                      a.num_distinct Cardinality,
                        round(a.num_distinct / b.num_rows * 100, 2) selectivity,
                       a.histogram,
                      a.num_buckets
                  from dba_tab_col_statistics a, dba_tables b
                 where a.owner = b.owner
                  and a.table_name = b.table_name
                and a.owner = 'MBFE'
             and a.table_name = upper('messagein');  2    3    4    5    6    7    8    9   10   11  
    
    COLUMN_NAME			 NUM_ROWS CARDINALITY SELECTIVITY HISTOGRAM	  NUM_BUCKETS
    ------------------------------ ---------- ----------- ----------- --------------- -----------
    ID				   978619      978619	      100 NONE			    1
    MSGID				   978619      978619	      100 FREQUENCY		    2
    STATUS				   978619	    1		0 NONE			    1
    PROCCNT 			   978619	    2		0 NONE			    1
    ACCEPTTIME			   978619      653888	    66.82 NONE			    1
    MSGBODY 			   978619	    0		0 NONE			    0
    QUEUE				   978619	    4		0 NONE			    1
    
    7 rows selected.
    
    
    
    SQL>  BEGIN
              DBMS_STATS.GATHER_TABLE_STATS(ownname          => 'MBFE',
                                           tabname          => 'MESSAGEIN',
                                          estimate_percent => 100,
                                            method_opt       => 'for columns MSGID size 1',
                                          no_invalidate    => FALSE,
                                           degree           => 16,
                                           cascade          => TRUE);
           END;  2    3    4    5    6    7    8    9  
     10  /
    
    PL/SQL procedure successfully completed.
    
    
    SQL>   select a.column_name,
                       b.num_rows,
                      a.num_distinct Cardinality,
                        round(a.num_distinct / b.num_rows * 100, 2) selectivity,
                       a.histogram,
                      a.num_buckets
                  from dba_tab_col_statistics a, dba_tables b
                 where a.owner = b.owner
                  and a.table_name = b.table_name
                and a.owner = 'MBFE'
             and a.table_name = upper('messagein');  2    3    4    5    6    7    8    9   10   11  
    
    COLUMN_NAME			 NUM_ROWS CARDINALITY SELECTIVITY HISTOGRAM	  NUM_BUCKETS
    ------------------------------ ---------- ----------- ----------- --------------- -----------
    ID				   978619      978619	      100 NONE			    1
    MSGID				   978619      978619	      100 NONE			    1
    STATUS				   978619	    1		0 NONE			    1
    PROCCNT 			   978619	    2		0 NONE			    1
    ACCEPTTIME			   978619      653888	    66.82 NONE			    1
    MSGBODY 			   978619	    0		0 NONE			    0
    QUEUE				   978619	    4		0 NONE			    1
    
    7 rows selected.
    
    此时直方图已经被干掉
    
    SQL>  BEGIN
              DBMS_STATS.GATHER_TABLE_STATS(ownname          => 'MBFE',
                                           tabname          => 'MESSAGEIN',
                                          estimate_percent => 100,
                                            method_opt       => 'for columns MSGID size repeat',
                                          no_invalidate    => FALSE,
                                           degree           => 16,
                                           cascade          => TRUE);
           END;  2    3    4    5    6    7    8    9  
     10  /
    
    PL/SQL procedure successfully completed.
    
    SQL> ^C^C
    
    SQL> 
    SQL> select a.column_name,
                       b.num_rows,
                      a.num_distinct Cardinality,
                        round(a.num_distinct / b.num_rows * 100, 2) selectivity,
                       a.histogram,
                      a.num_buckets
                  from dba_tab_col_statistics a, dba_tables b
                 where a.owner = b.owner
                  and a.table_name = b.table_name
                and a.owner = 'MBFE'
             and a.table_name = upper('messagein');  2    3    4    5    6    7    8    9   10   11  
    
    COLUMN_NAME			 NUM_ROWS CARDINALITY SELECTIVITY HISTOGRAM	  NUM_BUCKETS
    ------------------------------ ---------- ----------- ----------- --------------- -----------
    ID				   978619      978619	      100 NONE			    1
    MSGID				   978619      978619	      100 NONE			    1
    STATUS				   978619	    1		0 NONE			    1
    PROCCNT 			   978619	    2		0 NONE			    1
    ACCEPTTIME			   978619      653888	    66.82 NONE			    1
    MSGBODY 			   978619	    0		0 NONE			    0
    QUEUE				   978619	    4		0 NONE			    1
    
    7 rows selected.
    
    SQL> 
    
    用repert 方式收集:
    repeat表示以前收集过直方图,现在收集统计信息的时候就收集直方图,如果以前没收集过直方图,现在收集统计信息的时候就不收集。
    
    此时无效果
    SQL> BEGIN
              DBMS_STATS.GATHER_TABLE_STATS(ownname          => 'MBFE',
                                           tabname          => 'MESSAGEIN',
                                          estimate_percent => 100,
                                            method_opt       => 'for columns MSGID size skewonly',
                                          no_invalidate    => FALSE,
                                           degree           => 16,
                                           cascade          => TRUE);
           END;  2    3    4    5    6    7    8    9  
     10  /
    
    PL/SQL procedure successfully completed.
    
    SQL> select a.column_name,
           b.num_rows,
           a.num_distinct Cardinality,
           round(a.num_distinct / b.num_rows * 100, 2) selectivity,
           a.histogram,
           a.num_buckets
      from dba_tab_col_statistics a, dba_tables b
     where a.owner = b.owner
       and a.table_name = b.table_name
       and a.owner = 'MBFE'
       and a.table_name = upper('messagein');
      2    3    4    5    6    7    8    9   10   11  
    COLUMN_NAME			 NUM_ROWS CARDINALITY SELECTIVITY HISTOGRAM	  NUM_BUCKETS
    ------------------------------ ---------- ----------- ----------- --------------- -----------
    ID				   978619      978619	      100 NONE			    1
    MSGID				   978619      978619	      100 FREQUENCY		    2
    STATUS				   978619	    1		0 NONE			    1
    PROCCNT 			   978619	    2		0 NONE			    1
    ACCEPTTIME			   978619      653888	    66.82 NONE			    1
    MSGBODY 			   978619	    0		0 NONE			    0
    QUEUE				   978619	    4		0 NONE			    1
    
    7 rows selected.
    
    此时已搜集:
    
    skewonly 对所有的列搜集统计信息
    

  • 相关阅读:
    关于Entity Framework中的Attached报错的完美解决方案
    关于C# Winform DataGridView 设置DefaultCellStyle无效的原因与解决方案
    实现winform DataGridView控件判断滚动条是否滚动到当前已加载的数据行底部
    关于Entity Framework自动关联查询与自动关联更新导航属性对应的实体注意事项说明
    阅读《LEARNING HARD C#学习笔记》知识点总结与摘要系列文章索引
    阅读《LEARNING HARD C#学习笔记》知识点总结与摘要五
    C# Winform 通过FlowLayoutPanel及自定义的编辑控件,实现快速构建C/S版的编辑表单页面
    NPOI导入导出EXCEL通用类,供参考,可直接使用在WinForm项目中
    阅读《LEARNING HARD C#学习笔记》知识点总结与摘要四
    C#实现通用数据过滤窗体
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13351866.html
Copyright © 2020-2023  润新知