您好,登錄后才能下訂單哦!
這篇文章主要介紹“Oracle自動(dòng)收集統(tǒng)計(jì)信息怎么實(shí)現(xiàn)”,在日常操作中,相信很多人在Oracle自動(dòng)收集統(tǒng)計(jì)信息怎么實(shí)現(xiàn)問題上存在疑惑,小編查閱了各式資料,整理出簡(jiǎn)單好用的操作方法,希望對(duì)大家解答”O(jiān)racle自動(dòng)收集統(tǒng)計(jì)信息怎么實(shí)現(xiàn)”的疑惑有所幫助!接下來,請(qǐng)跟著小編一起來學(xué)習(xí)吧!
在Oracle的11g版本中提供了統(tǒng)計(jì)數(shù)據(jù)自動(dòng)收集的功能。在部署安裝11g Oracle軟件過程中,其中有一個(gè)步驟便是提示是否啟動(dòng)這個(gè)功能(默認(rèn)是啟用這個(gè)功能)。
一、查看自動(dòng)收集統(tǒng)計(jì)信息的任務(wù)及狀態(tài):
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>
二、禁止自動(dòng)收集統(tǒng)計(jì)信息的任務(wù)
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
三、啟用自動(dòng)收集統(tǒng)計(jì)信息的任務(wù)
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
四、獲得當(dāng)前自動(dòng)收集統(tǒng)計(jì)信息的執(zhí)行時(shí)間:
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:任務(wù)名 REPEAT_INTERVAL:任務(wù)重復(fù)間隔時(shí)間 DURATION:持續(xù)時(shí)間
五.修改統(tǒng)計(jì)信息執(zhí)行的時(shí)間:
1.停止任務(wù):
SQL> BEGIN
DBMS_SCHEDULER.DISABLE(
name => '"SYS"."THURSDAY_WINDOW"',
force => TRUE); --停止任務(wù)是true
END;
/
SQL>
2.修改任務(wù)的持續(xù)時(shí)間,單位是分鐘:
SQL> BEGIN
DBMS_SCHEDULER.SET_ATTRIBUTE(
name => '"SYS"."THURSDAY_WINDOW"',
attribute => 'DURATION',
value => numtodsinterval(60,'minute'));
END;
/
3.開始執(zhí)行時(shí)間,BYHOUR=2,表示2點(diǎn)開始執(zhí)行:
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.開啟任務(wù):
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
六.查看統(tǒng)計(jì)信息執(zhí)行的歷史記錄
--維護(hù)窗口組
select * from dba_scheduler_window_groups;
--維護(hù)窗口組對(duì)應(yīng)窗口
select * from dba_scheduler_wingroup_members
--維護(hù)窗口歷史信息
select* from dba_scheduler_windows
--查詢自動(dòng)收集任務(wù)正在執(zhí)行的job
select * from DBA_AUTOTASK_CLIENT_JOB;
--查詢自動(dòng)收集任務(wù)歷史執(zhí)行狀態(tài)
select * from DBA_AUTOTASK_JOB_HISTORY;
select * from DBA_AUTOTASK_CLIENT_HISTORY;
到此,關(guān)于“Oracle自動(dòng)收集統(tǒng)計(jì)信息怎么實(shí)現(xiàn)”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實(shí)踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識(shí),請(qǐng)繼續(xù)關(guān)注億速云網(wǎng)站,小編會(huì)繼續(xù)努力為大家?guī)砀鄬?shí)用的文章!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。