ITPub博客

首页 > Linux操作系统 > Linux操作系统 > dbms_stats

dbms_stats

原创 Linux操作系统 作者:g644516804 时间:2011-11-02 15:04:51 0 删除 编辑

dbms_stats

begin

sys.dbms_stats.gather_index_stats(

ownname=>'T7',

indname=>'IND_T7',

estimate_percent=>100

);

end;

 

SQL> exec dbms_stats.gather_schema_stats(ownname=>'TEST',estimate_percent=> dbms_stats.auto_sample_size,method_opt=>'for table',options=>'gather auto',degree=>6); --收集schema

Estimate_percent:自动估计要采样的一个segment的最佳百分比,

estimate_percent => dbms_stats.auto_sample_size  --oracle自动算取最优比例

通过user_tab_statistics.sample_size可以获取

SQL>exec dbms_stats.gather_table_stats(ownname=>'TEST',tabname=>'T7',estimate_percent=> dbms_stats.auto_sample_size,method_opt=>'for table');--收集table

Method_opt:

For table

For all indexed columns  --只统计有索引的表列

For all indexes

For all columns size

Options:

Gather 重新分析整个schemas

Gather empty 只分析目前还未统计的表

Gather stale 只重新分析修改量(插删除)超过10%的表

Gather auto 重新分析当前未统计对象及统计数据过期的对象

Degree:并行收集维度(cpu个数)

SQL>exec dbms_stats.create_stat_table(ownname=>'TEST',stattab=>'stats_test',tblspace=>'TEST'); --创建统计信息导出表

SQL>exec dbms_stats.gather_table_stats(ownname=>'TEST',tabname=>'T7',estimate_percent=>100,method_opt=>'for table');

SQL> exec dbms_stats.export_schema_stats(ownname=>'TEST',stattab=>'stats_test');  --导出schema统计信息

SQL>  exec dbms_stats.export_table_stats(ownname=>'TEST',tabname=>'T7',stattab=>'stats_test');  --导出table统计信息

SQL>inset into t7 as select * from t7;

SQL>COMMIT;

SQL>exec dbms_stats.gather_table_stats(ownname=>'TEST',tabname=>'T7',estimate_percent=>100,method_opt=>'for table');

SQL>select num_rows from dba_tables where table_name=’T7’;

156行

SQL> exec dbms_stats.import_table_stats(ownname=>'TEST',tabname=>'T7',stattab=>'stats_test');--导入历史统计信息

SQL>select num_rows from dba_tables where table_name=’T7’;

99行

SQL>exec dbms_stats.improt_schema_stats(ownname=>’TEST’,stattab=>’stats_test’);

 

利用analyze ..

Analyze table t7 compute statistics;--分析t7全部分析

Analyze index ind_t7 validate structure;

分析index之后,查看table index_stats(注:需要在同一个session中才可以看到具体信息)

SQL>select name,height,blocks,lf_rows,del_lf_rows,lf_rows_len,del_lf_rows_len from index_stats;

Lf_rows:leaf row 的数量

Lf_rows_len:所有leaf row (Sum of the lengths of all the leaf rows)

Del_lf_rows: Number of deleted leaf rows in the index

Del_lf_rows_len: Total length of all deleted rows in the index

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/24849178/viewspace-710108/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: SMT migration
下一篇: oracle header_block
请登录后发表评论 登录
全部评论

注册时间:2011-03-04

  • 博文量
    104
  • 访问量
    271258