1. 程式人生 > >手工蒐集Oracle統計分析

手工蒐集Oracle統計分析

手工刷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;