oracle统计信息

时间:2023-12-13 19:07:08

手工刷ORACLE统计信息

 select count(1) from LOG_TRX_DETAIL;

 select * from user_tab_statistics where table_name = 'LOG_TRX_DETAIL';

 exec dbms_stats.gather_table_stats('ARDB','ACCT_BALANCE',cascade => true);

 exec dbms_stats.gather_table_stats('ARDB','LOG_TRX',cascade => true);

 exec dbms_stats.gather_table_stats(OWNNAME=>'ARDB',TABNAME=>'LOG_TRX_DETAIL',GRANULARITY=>'ALL',ESTIMATE_PERCENT=>5,DEGREE=>4,CASCADE=>TRUE);

 exec dbms_stats.gather_table_stats(OWNNAME=>'ARDB',TABNAME=>'ACCT_BALANCE',GRANULARITY=>'ALL',ESTIMATE_PERCENT=>5,DEGREE=>4,CASCADE=>TRUE);

 execute dbms_stats.gather_table_stats(ownname => 'ARDB',tabname => 'TRANS_DETAIL', estimate_percent => DBMS_STATS.AUTO_SAMPLE_SIZE ,method_opt => 'FOR ALL COLUMNS SIZE 1',no_invalidate=>false, DEGREE=>8, cascade => true);

 exec dbms_stats.gather_table_stats('ARDB', 'LOG_TRX', 'P201301', granularity => 'PARTITION', DEGREE=>4, cascade => true);

 exec dbms_stats.gather_table_stats('ARDB', 'LOG_TRX_DETAIL', 'P201301', granularity => 'PARTITION', DEGREE=>4, cascade => true);

 alter system flush shared_pool;

关闭统计信息更新

 begin

 DBMS_AUTO_TASK_ADMIN.DISABLE(client_name => 'auto optimizer stats collection',

 operation => NULL,

 window_name => NULL);

 end;

 /

 

 通过视图DBA_AUTOTASK_WINDOW_CLIENTS能够查看他们一周七天的运行情况

 select * from DBA_AUTOTASK_WINDOW_CLIENTS;