Bo's Oracle Station

查看: 2304|回复: 0

第41和42次:2015-04-25星期六

[复制链接]

1005

主题

1469

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
12012
发表于 2015-4-27 10:02:57 | 显示全部楼层 |阅读模式
  1. select t.num_rows ,t.last_analyzed    from dba_tables t where t.owner='HR' and t.table_name='T04209_UNAME' ;

  2. select  i.index_name,i.num_rows,  i.last_analyzed   from dba_indexes i where i.owner='HR' and i.table_name='T04209_UNAME';

  3. select   *   from dba_histograms h  where h.owner='HR' and h.table_name='T04209_UNAME';

  4. select   *  from dba_tab_col_statistics  tcs  where tcs.owner='HR' and tcs.table_name='T04209_UNAME';

  5. begin
  6.    dbms_stats.gather_table_stats(ownname => 'HR',
  7.    tabname => 'T04209_UNAME',
  8.    estimate_percent => dbms_stats.AUTO_SAMPLE_SIZE,
  9.    method_opt => 'for all columns size skewonly',cascade => true);
  10.    end;
  11.    
  12. begin
  13.    dbms_stats.gather_table_stats(ownname => 'HR',
  14.    tabname => 'T04209_UNAME',
  15.    estimate_percent => 100,
  16.    method_opt => 'for columns   uvalue  size 2 ',cascade => true);
  17.    end;
  18.    
  19.    select  * from dba_tab_stat_prefs;
  20.    
  21.    

  22.    select    DBMS_STATS.GET_PREFS(pname => 'METHOD_OPT' )  from dual;

  23.    select    DBMS_STATS.GET_PREFS(pname => 'STALE_PERCENT' )  from dual;
  24.    
  25.    
  26.    select    DBMS_STATS.GET_PREFS(pname => 'PUBLISH' )  from dual;

  27. begin
  28. dbms_stats.gather_table_stats('HR','T04209_UNAME');
  29. end;

  30. begin
  31.    dbms_stats.set_table_prefs(ownname => 'HR',tabname => 'T04209_UNAME',
  32.       pname => 'STALE_PERCENT',
  33.       pvalue => '13');
  34.    
  35.    end;
  36.    
  37.    
  38.    begin
  39.    dbms_stats.set_table_prefs(ownname => 'HR',tabname => 'T04209_UNAME',
  40.       pname => 'PUBLISH',
  41.       pvalue => 'FALSE');
  42.    
  43.    end;


  44. select  * from dict where table_name like '%PENDING%';

  45. select  * from DBA_TAB_PENDING_STATS;


  46. begin
  47.    dbms_stats.publish_pending_stats(ownname => 'HR',tabname => 'T04209_UNAME' ,no_invalidate => true);
  48.   end;
  49.   -----
  50.   
  51.   begin
  52.      DBMS_STATS.RESET_PARAM_DEFAULTS ;
  53.      end;
  54.      
  55.    select * from (     select * from v$sql order by    elapsed_time  desc  ) where rownum <=6;
  56.    
  57.    
  58.    
复制代码


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|Bo's Oracle Station   

GMT+8, 2024-3-29 15:23 , Processed in 0.035073 second(s), 24 queries .

快速回复 返回顶部 返回列表