通过dbms_space包来访问段顾问的建议。这个包获取由段顾问生成的相关信息,这些段适合进行收缩、移动或压缩。
sys@ORCL> SELECT 2 'Segment Advice --------------------------'|| chr(10) || 3 'TABLESPACE_NAME : ' || tablespace_name || chr(10) || 4 'SEGMENT_OWNER : ' || segment_owner || chr(10) || 5 'SEGMENT_NAME : ' || segment_name || chr(10) || 6 'ALLOCATED_SPACE : ' || allocated_space || chr(10) || 7 'RECLAIMABLE_SPACE: ' || reclaimable_space || chr(10) || 8 'RECOMMENDATIONS : ' || recommendations || chr(10) || 9 'SOLUTION 1 : ' || c1 || chr(10) || 10 'SOLUTION 2 : ' || c2 || chr(10) || 11 'SOLUTION 3 : ' || c3 Advice 12 FROM 13 TABLE(dbms_space.asa_recommendations('FALSE', 'FALSE', 'FALSE')); ADVICE -------------------------------------------------------------------------------- Segment Advice -------------------------- TABLESPACE_NAME : USERS SEGMENT_OWNER : QYV SEGMENT_NAME : BIG_TABLE ALLOCATED_SPACE : 125829120 RECLAIMABLE_SPACE: 81788928 RECOMMENDATIONS : 压缩对象 QYV.BIG_TABLE, 估计可以节省 81788928 字节。 SOLUTION 1 : alter table "QYV"."BIG_TABLE" compress for oltp SOLUTION 2 : alter table "QYV"."BIG_TABLE" move SOLUTION 3 :all_runs:为true则存储过程返回历次运行的结果,而为false则仅返回最近一次运行的结果。
可以查询dba_auto_segadv_summary视图,查看自动作业最后一次运行的时间:
sys@ORCL> select segments_processed,start_time,end_time from dba_auto_segadv_summary order by end_time; SEGMENTS_PROCESSED START_TIME END_TIME ------------------ ----------------------------------- ----------------------------------- 3 29-10月-13 10.00.03.862590 下午 29-10月-13 10.00.35.743062 下午
sys@ORCL> select 2 'Task Name : ' || f.task_name || chr(10) || 3 'Start Run Time : ' || TO_CHAR(execution_start, 'dd-mon-yy hh24:mi') || chr (10) || 4 'Segment Name : ' || o.attr2 || chr(10) || 5 'Segment Type : ' || o.type || chr(10) || 6 'Partition Name : ' || o.attr3 || chr(10) || 7 'Message : ' || f.message || chr(10) || 8 'More Info : ' || f.more_info || chr(10) || 9 '------------------------------------------------------' Advice 10 FROM dba_advisor_findings f 11 ,dba_advisor_objects o 12 ,dba_advisor_executions e 13 WHERE o.task_id = f.task_id 14 AND o.object_id = f.object_id 15 AND f.task_id = e.task_id 16 AND e. execution_start > sysdate - 1 17 AND e.advisor_name = 'Segment Advisor' 18 ORDER BY f.task_name; ADVICE -------------------------------------------------------------------------------- Task Name : BIG_TABLE Advice Start Run Time : 29-10月-13 22:52 Segment Name : BIG_TABLE Segment Type : TABLE Partition Name : Message : 启用表 U1.BIG_TABLE 的行移动并执行收缩, 估计可以节省 10953547 5 字节。 More Info : 分配空间:125829120: 已用空间:16293645: 可回收空间:109535475: ------------------------------------------------------ Task Name : SYS_AUTO_SPCADV_11002229102013 Start Run Time : 29-10月-13 22:00 Segment Name : BIG_TABLE Segment Type : TABLE Partition Name : Message : 压缩对象 QYV.BIG_TABLE, 估计可以节省 81788928 字节。 More Info : 分配空间:125829120: 已用空间:43959601: 可回收空间:81788928: ------------------------------------------------------