顯示自動段顧問建議
阿新 • • 發佈:2019-02-14
問題描述:你有一個查詢耗費時間很長,但是表中資料很少,你想檢視段顧問有什麼建議
解決方案:
使用段顧問來顯示錶的資訊,曾經分配過但現在是空的空間(刪除大量資料行),有大量未使用的空間的表會使全表掃描變得很慢,因為全表掃描會掃描高水位線下的所有塊
dbms_space包可以檢視段顧問的建議。這些資訊由段顧問生成,這些段適合收縮,移動或壓縮,如下查詢:
select
'segment advice--------------------' ||chr(10)||
'TABLESPACE_NAME :'||tablespace_name ||chr(10)||
'SEGMENT_OWNER :'||segment_owner ||chr(10)||
'SEGMENT_NAME :'||segment_name ||chr(10)||
'ALLOCATED_SPACE :'||allocated_space ||chr(10)||
'RECLAIMABLE_SPACE:'||reclaimable_space ||chr(10)||
'RECOMMENDATIONS :'||RECOMMENDATIONS ||chr(10)||
'solution 1 :'||c1 ||chr(10)||
'solution 2 :'||c2 ||chr(10)||
'solution 3 :'||c3 advice
from table(dbms_space.asa_recommendations('FALSE','FALSE','FALSE'));
ADVICE
--------------------------------------------
segment advice--------------------
TABLESPACE_NAME :ACCT_TBS01
SEGMENT_OWNER:JYTLOCAL
SEGMENT_NAME:SC_IDENTIFY_CHECK_MSG
ALLOCATED_SPACE :1567621120
RECLAIMABLE_SPACE:12969320
RECOMMENDATIONS :Enable row movement of the table JYTLOCAL.SC_IDENTIFY_CHECK_MSG and perform shrink, estimated savings is 12969320 bytes.
solution 1:alter table "JYTLOCAL"."SC_IDENTIFY_CHECK_MSG" shrink space
solution 2:alter table "JYTLOCAL"."SC_IDENTIFY_CHECK_MSG" shrink space COMPACT
solution 3:alter table "JYTLOCAL"."SC_IDENTIFY_CHECK_MSG" enable row movement
工作原理:
自10gr2之後,oracle會自動執行段顧問作業,分析資料庫中的段,並將結果儲存到內部表中,結果包括
1、適合收縮的段
2、有顯著行連結的段
3、可以從oltp壓縮中獲益的段
段顧問通過自動排程的dbms_scheduler定期執行,可檢視dba_auto_segadv_summary檢視檢視執行時間
select segments_processed,end_time from dba_auto_segadv_summary order by end_time;
段顧問以awr作為資訊源,執行結果儲存在內部表中,可通過以下資料字典檢視:
dba_advisor_executions
dba_advisor_findings
dba_advisor_objects
可通過三種工具獲取輸出:
1、執行dbms_space.asa_recommendations
2、手工查詢dba_advisor_*檢視
3、通過em介面檢視
dbms_space.asa_recommendations引數含義:
all_runs:true則返回歷次執行結果,false返回上次結果
show_manual:true返回手工執行結果,false返回自動執行的結果
show_finding:僅顯示結果不顯示建議
手工查詢段顧問建議:
select
'TASK_NAME :'||T1.TASK_NAME ||CHR(10)||
'START_RUN_TIME :'||TO_CHAR(T1.EXECUTION_START,'YYYY-MM-DD HH24:MI:SS') ||CHR(10)||
'SEGMENT_OWNER :'||T3.ATTR1 ||CHR(10)||
'SEGMENT_NAME :'||T3.ATTR2 ||CHR(10)||
'PARTITION_NAME :'||T3.ATTR3 ||CHR(10)||
'SEGMENT_TYPE :'||T3.TYPE ||CHR(10)||
'MESSAGE :'||T2.MESSAGE||CHR(10)||
'MORE INFO :'||T2.MORE_INFO||CHR(10)||
'---------------------------------' ADVICE
from dba_advisor_executions t1,
dba_advisor_findings t2,
dba_advisor_objects t3
where t1.task_id = t2.task_id
and t2.task_id = t3.task_id
and t2.object_id=t3.object_id
and t1.advisor_name = 'Segment Advisor'
and t1.execution_last_modified > sysdate - 1
and t2.type = 'PROBLEM';
ADVICE
------------------------------------------------------------------
TASK_NAME :SYS_AUTO_SPCADV_07002208092016
START_RUN_TIME :2016-09-08 22:00:08
SEGMENT_OWNER :JYTPAYDEV
SEGMENT_NAME :CP_ORDER_FLOW
PARTITION_NAME :
SEGMENT_TYPE :TABLE
MESSAGE :The object has chained rows that can be removed by re-org.
MORE INFO :17 percent chained rows can be removed by re-org.
---------------------------------
上面的顯示錶明某張表有行連結
通過em檢視建議,先進入顧問中心(Advisor Central),然後定位到段顧問頁面,進入段建議頁面。
解決方案:
使用段顧問來顯示錶的資訊,曾經分配過但現在是空的空間(刪除大量資料行),有大量未使用的空間的表會使全表掃描變得很慢,因為全表掃描會掃描高水位線下的所有塊
dbms_space包可以檢視段顧問的建議。這些資訊由段顧問生成,這些段適合收縮,移動或壓縮,如下查詢:
select
'segment advice--------------------' ||chr(10)||
'TABLESPACE_NAME :'||tablespace_name ||chr(10)||
'SEGMENT_OWNER :'||segment_owner ||chr(10)||
'SEGMENT_NAME :'||segment_name ||chr(10)||
'ALLOCATED_SPACE :'||allocated_space ||chr(10)||
'RECLAIMABLE_SPACE:'||reclaimable_space ||chr(10)||
'RECOMMENDATIONS :'||RECOMMENDATIONS ||chr(10)||
'solution 1 :'||c1 ||chr(10)||
'solution 2 :'||c2 ||chr(10)||
'solution 3 :'||c3 advice
from table(dbms_space.asa_recommendations('FALSE','FALSE','FALSE'));
ADVICE
--------------------------------------------
segment advice--------------------
TABLESPACE_NAME :ACCT_TBS01
SEGMENT_OWNER:JYTLOCAL
SEGMENT_NAME:SC_IDENTIFY_CHECK_MSG
ALLOCATED_SPACE :1567621120
RECLAIMABLE_SPACE:12969320
RECOMMENDATIONS :Enable row movement of the table JYTLOCAL.SC_IDENTIFY_CHECK_MSG and perform shrink, estimated savings is 12969320 bytes.
solution 1:alter table "JYTLOCAL"."SC_IDENTIFY_CHECK_MSG" shrink space
solution 2:alter table "JYTLOCAL"."SC_IDENTIFY_CHECK_MSG" shrink space COMPACT
solution 3:alter table "JYTLOCAL"."SC_IDENTIFY_CHECK_MSG" enable row movement
工作原理:
自10gr2之後,oracle會自動執行段顧問作業,分析資料庫中的段,並將結果儲存到內部表中,結果包括
1、適合收縮的段
2、有顯著行連結的段
3、可以從oltp壓縮中獲益的段
段顧問通過自動排程的dbms_scheduler定期執行,可檢視dba_auto_segadv_summary檢視檢視執行時間
select segments_processed,end_time from dba_auto_segadv_summary order by end_time;
段顧問以awr作為資訊源,執行結果儲存在內部表中,可通過以下資料字典檢視:
dba_advisor_executions
dba_advisor_findings
dba_advisor_objects
可通過三種工具獲取輸出:
1、執行dbms_space.asa_recommendations
2、手工查詢dba_advisor_*檢視
3、通過em介面檢視
dbms_space.asa_recommendations引數含義:
all_runs:true則返回歷次執行結果,false返回上次結果
show_manual:true返回手工執行結果,false返回自動執行的結果
show_finding:僅顯示結果不顯示建議
手工查詢段顧問建議:
select
'TASK_NAME :'||T1.TASK_NAME ||CHR(10)||
'START_RUN_TIME :'||TO_CHAR(T1.EXECUTION_START,'YYYY-MM-DD HH24:MI:SS') ||CHR(10)||
'SEGMENT_OWNER :'||T3.ATTR1 ||CHR(10)||
'SEGMENT_NAME :'||T3.ATTR2 ||CHR(10)||
'PARTITION_NAME :'||T3.ATTR3 ||CHR(10)||
'SEGMENT_TYPE :'||T3.TYPE ||CHR(10)||
'MESSAGE :'||T2.MESSAGE||CHR(10)||
'MORE INFO :'||T2.MORE_INFO||CHR(10)||
'---------------------------------' ADVICE
from dba_advisor_executions t1,
dba_advisor_findings t2,
dba_advisor_objects t3
where t1.task_id = t2.task_id
and t2.task_id = t3.task_id
and t2.object_id=t3.object_id
and t1.advisor_name = 'Segment Advisor'
and t1.execution_last_modified > sysdate - 1
and t2.type = 'PROBLEM';
ADVICE
------------------------------------------------------------------
TASK_NAME :SYS_AUTO_SPCADV_07002208092016
START_RUN_TIME :2016-09-08 22:00:08
SEGMENT_OWNER :JYTPAYDEV
SEGMENT_NAME :CP_ORDER_FLOW
PARTITION_NAME :
SEGMENT_TYPE :TABLE
MESSAGE :The object has chained rows that can be removed by re-org.
MORE INFO :17 percent chained rows can be removed by re-org.
---------------------------------
上面的顯示錶明某張表有行連結
通過em檢視建議,先進入顧問中心(Advisor Central),然後定位到段顧問頁面,進入段建議頁面。