Oracle 11g 之自動收集統計資訊
在Oracle的11g版本中提供了統計資料自動收集的功能。在部署安裝11g Oracle軟體過程中,其中有一個步驟便是提示是否啟動這個功能(預設是啟用這個功能)。
一、檢視自動收集統計資訊的任務及狀態:
SQL> select client_name,status from dba_autotask_client;
CLIENT_NAME STATUS
---------------------------------------------------------------- --------
auto optimizer stats collection ENABLED
auto space advisor ENABLED
sql tuning advisor DISABLED
SQL>
二、禁止自動收集統計資訊的任務
SQL> exec DBMS_AUTO_TASK_ADMIN.DISABLE(client_name => 'auto optimizer stats collection',operation => NULL,window_name => NULL);
PL/SQL procedure successfully completed.
SQL> select client_name,status from dba_autotask_client;
CLIENT_NAME STATUS
---------------------------------------------------------------- --------
auto optimizer stats collection DISABLED
auto space advisor ENABLED
sql tuning advisor DISABLED
三、啟用自動收集統計資訊的任務
SQL> exec DBMS_AUTO_TASK_ADMIN.ENABLE(client_name => 'auto optimizer stats collection',operation => NULL,window_name => NULL);
PL/SQL procedure successfully completed.
SQL> select client_name,status from dba_autotask_client;
CLIENT_NAME STATUS
---------------------------------------------------------------- --------
auto optimizer stats collection ENABLED
auto space advisor ENABLED
sql tuning advisor DISABLED
四、獲得當前自動收集統計資訊的執行時間:
SQL> col WINDOW_NAME format a20
SQL> col REPEAT_INTERVAL format a70
SQL> col DURATION format a20
SQL> set line 180
SQL> select t1.window_name,t1.repeat_interval,t1.duration
from dba_scheduler_windows t1,dba_scheduler_wingroup_members t2
where t1.window_name=t2.window_name and t2.window_group_name in ('MAINTENANCE_WINDOW_GROUP','BSLN_MAINTAIN_STATS_SCHED');
WINDOW_NAME REPEAT_INTERVAL DURATION
-------------------- ---------------------------------------------------------------------- --------------------
WEDNESDAY_WINDOW freq=daily;byday=WED;byhour=22;byminute=0; bysecond=0 +000 04:00:00
SATURDAY_WINDOW freq=daily;byday=SAT;byhour=6;byminute=0; bysecond=0 +000 20:00:00
THURSDAY_WINDOW freq=daily;byday=THU;byhour=22;byminute=0; bysecond=0 +000 04:00:00
TUESDAY_WINDOW freq=daily;byday=TUE;byhour=22;byminute=0; bysecond=0 +000 04:00:00
SUNDAY_WINDOW freq=daily;byday=SUN;byhour=6;byminute=0; bysecond=0 +000 20:00:00
MONDAY_WINDOW freq=daily;byday=MON;byhour=22;byminute=0; bysecond=0 +000 04:00:00
FRIDAY_WINDOW freq=daily;byday=FRI;byhour=22;byminute=0; bysecond=0 +000 04:00:00
7 rows selected.
其中:WINDOW_NAME:任務名 REPEAT_INTERVAL:任務重複間隔時間 DURATION:持續時間
五.修改統計資訊執行的時間:
1.停止任務:
SQL> BEGIN
DBMS_SCHEDULER.DISABLE(
name => '"SYS"."THURSDAY_WINDOW"',
force => TRUE); --停止任務是true
END;
/
SQL>
2.修改任務的持續時間,單位是分鐘:
SQL> BEGIN
DBMS_SCHEDULER.SET_ATTRIBUTE(
name => '"SYS"."THURSDAY_WINDOW"',
attribute => 'DURATION',
value => numtodsinterval(60,'minute'));
END;
/
3.開始執行時間,BYHOUR=2,表示2點開始執行:
SQL> BEGIN
DBMS_SCHEDULER.SET_ATTRIBUTE(
name => '"SYS"."THURSDAY_WINDOW"',
attribute => 'REPEAT_INTERVAL',
value => 'freq=daily;byday=THU;byhour=10;byminute=40;bysecond=0');
END;
/
4.開啟任務:
SQL> BEGIN
DBMS_SCHEDULER.ENABLE(
name => '"SYS"."THURSDAY_WINDOW"');
END;
/
5.檢視修改後的情況:
SQL> select t1.window_name,t1.repeat_interval,t1.duration
from dba_scheduler_windows t1,dba_scheduler_wingroup_members t2
where t1.window_name=t2.window_name and t2.window_group_name in ('MAINTENANCE_WINDOW_GROUP','BSLN_MAINTAIN_STATS_SCHED');
WINDOW_NAME REPEAT_INTERVAL DURATION
-------------------- ---------------------------------------------------------------------- --------------------
WEDNESDAY_WINDOW freq=daily;byday=WED;byhour=22;byminute=0; bysecond=0 +000 04:00:00
SATURDAY_WINDOW freq=daily;byday=SAT;byhour=6;byminute=0; bysecond=0 +000 20:00:00
THURSDAY_WINDOW freq=daily;byday=THU;byhour=10;byminute=40;bysecond=0 +000 01:00:00
TUESDAY_WINDOW freq=daily;byday=TUE;byhour=22;byminute=0; bysecond=0 +000 04:00:00
SUNDAY_WINDOW freq=daily;byday=SUN;byhour=6;byminute=0; bysecond=0 +000 20:00:00
MONDAY_WINDOW freq=daily;byday=MON;byhour=22;byminute=0; bysecond=0 +000 04:00:00
FRIDAY_WINDOW freq=daily;byday=FRI;byhour=22;byminute=0; bysecond=0 +000 04:00:00
六.檢視統計資訊執行的歷史記錄
--維護視窗組
select * from dba_scheduler_window_groups;
--維護視窗組對應視窗
select * from dba_scheduler_wingroup_members
--維護視窗歷史資訊
select* from dba_scheduler_windows
--查詢自動收集任務正在執行的job
select * from DBA_AUTOTASK_CLIENT_JOB;
--查詢自動收集任務歷史執行狀態
select * from DBA_AUTOTASK_JOB_HISTORY;
select * from DBA_AUTOTASK_CLIENT_HISTORY;
一、檢視自動收集統計資訊的任務及狀態:
SQL> select client_name,status from dba_autotask_client;
CLIENT_NAME STATUS
---------------------------------------------------------------- --------
auto optimizer stats collection ENABLED
auto space advisor ENABLED
sql tuning advisor DISABLED
SQL>
二、禁止自動收集統計資訊的任務
SQL> exec DBMS_AUTO_TASK_ADMIN.DISABLE(client_name => 'auto optimizer stats collection',operation => NULL,window_name => NULL);
PL/SQL procedure successfully completed.
SQL> select client_name,status from dba_autotask_client;
CLIENT_NAME STATUS
---------------------------------------------------------------- --------
auto optimizer stats collection DISABLED
auto space advisor ENABLED
sql tuning advisor DISABLED
三、啟用自動收集統計資訊的任務
SQL> exec DBMS_AUTO_TASK_ADMIN.ENABLE(client_name => 'auto optimizer stats collection',operation => NULL,window_name => NULL);
PL/SQL procedure successfully completed.
SQL> select client_name,status from dba_autotask_client;
CLIENT_NAME STATUS
---------------------------------------------------------------- --------
auto optimizer stats collection ENABLED
auto space advisor ENABLED
sql tuning advisor DISABLED
四、獲得當前自動收集統計資訊的執行時間:
SQL> col WINDOW_NAME format a20
SQL> col REPEAT_INTERVAL format a70
SQL> col DURATION format a20
SQL> set line 180
SQL> select t1.window_name,t1.repeat_interval,t1.duration
from dba_scheduler_windows t1,dba_scheduler_wingroup_members t2
where t1.window_name=t2.window_name and t2.window_group_name in ('MAINTENANCE_WINDOW_GROUP','BSLN_MAINTAIN_STATS_SCHED');
WINDOW_NAME REPEAT_INTERVAL DURATION
-------------------- ---------------------------------------------------------------------- --------------------
WEDNESDAY_WINDOW freq=daily;byday=WED;byhour=22;byminute=0; bysecond=0 +000 04:00:00
SATURDAY_WINDOW freq=daily;byday=SAT;byhour=6;byminute=0; bysecond=0 +000 20:00:00
THURSDAY_WINDOW freq=daily;byday=THU;byhour=22;byminute=0; bysecond=0 +000 04:00:00
TUESDAY_WINDOW freq=daily;byday=TUE;byhour=22;byminute=0; bysecond=0 +000 04:00:00
SUNDAY_WINDOW freq=daily;byday=SUN;byhour=6;byminute=0; bysecond=0 +000 20:00:00
MONDAY_WINDOW freq=daily;byday=MON;byhour=22;byminute=0; bysecond=0 +000 04:00:00
FRIDAY_WINDOW freq=daily;byday=FRI;byhour=22;byminute=0; bysecond=0 +000 04:00:00
7 rows selected.
其中:WINDOW_NAME:任務名 REPEAT_INTERVAL:任務重複間隔時間 DURATION:持續時間
五.修改統計資訊執行的時間:
1.停止任務:
SQL> BEGIN
DBMS_SCHEDULER.DISABLE(
name => '"SYS"."THURSDAY_WINDOW"',
force => TRUE); --停止任務是true
END;
/
SQL>
2.修改任務的持續時間,單位是分鐘:
SQL> BEGIN
DBMS_SCHEDULER.SET_ATTRIBUTE(
name => '"SYS"."THURSDAY_WINDOW"',
attribute => 'DURATION',
value => numtodsinterval(60,'minute'));
END;
/
3.開始執行時間,BYHOUR=2,表示2點開始執行:
SQL> BEGIN
DBMS_SCHEDULER.SET_ATTRIBUTE(
name => '"SYS"."THURSDAY_WINDOW"',
attribute => 'REPEAT_INTERVAL',
value => 'freq=daily;byday=THU;byhour=10;byminute=40;bysecond=0');
END;
/
4.開啟任務:
SQL> BEGIN
DBMS_SCHEDULER.ENABLE(
name => '"SYS"."THURSDAY_WINDOW"');
END;
/
5.檢視修改後的情況:
SQL> select t1.window_name,t1.repeat_interval,t1.duration
from dba_scheduler_windows t1,dba_scheduler_wingroup_members t2
where t1.window_name=t2.window_name and t2.window_group_name in ('MAINTENANCE_WINDOW_GROUP','BSLN_MAINTAIN_STATS_SCHED');
WINDOW_NAME REPEAT_INTERVAL DURATION
-------------------- ---------------------------------------------------------------------- --------------------
WEDNESDAY_WINDOW freq=daily;byday=WED;byhour=22;byminute=0; bysecond=0 +000 04:00:00
SATURDAY_WINDOW freq=daily;byday=SAT;byhour=6;byminute=0; bysecond=0 +000 20:00:00
THURSDAY_WINDOW freq=daily;byday=THU;byhour=10;byminute=40;bysecond=0 +000 01:00:00
TUESDAY_WINDOW freq=daily;byday=TUE;byhour=22;byminute=0; bysecond=0 +000 04:00:00
SUNDAY_WINDOW freq=daily;byday=SUN;byhour=6;byminute=0; bysecond=0 +000 20:00:00
MONDAY_WINDOW freq=daily;byday=MON;byhour=22;byminute=0; bysecond=0 +000 04:00:00
FRIDAY_WINDOW freq=daily;byday=FRI;byhour=22;byminute=0; bysecond=0 +000 04:00:00
六.檢視統計資訊執行的歷史記錄
--維護視窗組
select * from dba_scheduler_window_groups;
--維護視窗組對應視窗
select * from dba_scheduler_wingroup_members
--維護視窗歷史資訊
select* from dba_scheduler_windows
--查詢自動收集任務正在執行的job
select * from DBA_AUTOTASK_CLIENT_JOB;
--查詢自動收集任務歷史執行狀態
select * from DBA_AUTOTASK_JOB_HISTORY;
select * from DBA_AUTOTASK_CLIENT_HISTORY;
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31397003/viewspace-2147195/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- [統計資訊系列7] Oracle 11g的自動統計資訊收集Oracle
- Oracle 11g系統自動收集統計資訊的一些知識Oracle
- Oracle收集統計資訊Oracle
- 手動收集——收集統計資訊
- 【統計資訊】Oracle常用的收集統計資訊方式Oracle
- 啟用與禁用統計資訊自動收集
- oracle 統計資訊檢視與收集Oracle
- Oracle統計資訊的收集和維護Oracle
- Oracle運維指令碼-收集統計資訊Oracle運維指令碼
- 最佳實踐:解讀GaussDB(DWS) 統計資訊自動收集方案
- 收集統計資訊方案
- ORACLE19c新特性-實時統計資訊收集Oracle
- 【統計資訊】Oracle統計資訊Oracle
- 收集全庫統計資訊
- 【TUNE_ORACLE】定製化收集統計資訊SQL參考OracleSQL
- 微課sql最佳化(3)、統計資訊收集(2)-如何收集統計資訊SQL
- Oracle 11g dg broker自動failoverOracleAI
- 6 收集資料庫統計資訊資料庫
- oracle 11g自動記憶體管理Oracle記憶體
- ORACLE表統計資訊與列統計資訊、索引統計資訊Oracle索引
- oracle 11g 系統審計功能Oracle
- oracle 11g rac新增節點前之清除節點資訊Oracle
- 【TABLE】Oracle表資訊收集指令碼Oracle指令碼
- Oracle之11g DataGuardOracle
- Oracle 11g RAC自動打GI PSU補丁Oracle
- Oracle 統計資訊介紹Oracle
- 修改oracle 的統計資訊Oracle
- 微課sql最佳化(8)、統計資訊收集(6)-統計資訊查詢SQL
- oracle 11g建立基線詳細資訊Oracle
- 【SCRIPT】Oracle資料庫基本資訊收集指令碼Oracle資料庫指令碼
- 【SQL】Oracle資料庫資料量及效能資訊收集SQLOracle資料庫
- 11G oracle資料庫重新啟動crsOracle資料庫
- Sqlserver關於統計資訊自動建立自動更新的知識點SQLServer
- Win10系統關閉“小娜自動收集個人資訊”功能的方法Win10
- 紅藍對抗之資訊收集
- 滲透測試之資訊收集
- ORACLE analyse table方式收集表統計資訊導致SQL執行計劃不準確而效能下降OracleSQL
- 【STATS】Oracle遷移表統計資訊Oracle
- 【SCRIPT】Oracle統計資訊相關SQLOracleSQL