1、查看segment advisor
方法一:
select * fromtable(dbms_space.asa_recommendations('TRUE','FALSE','FALSE'));
dbms_space.asa_recommentdations的三个参数:
all_runs TURE返回历次运行的结果,FALSE则返回最近一次运行的结果
show_manual TURE返回手工执行segment advisor的执行结果,FALSE返回自动执行的segment advisor的执行结果
show_finding TURE仅显示结果不显示建议,FALSE显示结果和建议
方法二:
select f.task_name,
execution_start,
o.attr2,
o.type,
o.attr3,
f.message,
f.more_info
from dba_advisor_executions e,
dba_advisor_findings f,
dba_advisor_objects o
where o.task_id = f.task_id
and o.object_id = f.object_id
and f.task_id = e.task_id
and e.advisor_name = 'Segment Advisor'
order by f.task_name;
segment advisor会自动的定期执行,查看其执行情况的视图是dba_auto_segadv_summary
查看ora advisor的视图
dba_advisor_executions
dba_advisor_findings
dba_advisor_objects
2、手工生成segment advisor?
查看advisor name
select * fromdba_advisor_definitions;?
ADVISOR_IDADVISOR_NAME PROPERTY
---------------------------------------- ----------
1 ADDM 1
2 SQL Access Advisor 271
3 Undo Advisor 1
4 SQL Tuning Advisor 935
5 Segment Advisor 67
6 SQL Workload Manager 0
7 Tune MView 31
8 SQL Performance Analyzer 935
9 SQL Repair Advisor 679
10 Compression Advisor 3
生成segmentadvisor
DECLARE
my_task_id number;
obj_id number;
my_task_name varchar2(100);
my_task_desc varchar2(500);
BEGIN
my_task_name := 'BIG_TABLE Advice';
my_task_desc := 'Manual Segment Advisor Run';
-- Step 1创建一个任务
dbms_advisor.create_task(advisor_name =>'Segment Advisor',
task_id => my_task_id,
task_name => my_task_name,
task_desc => my_task_desc);
-- Step 2为这个任务分配一个对象
dbms_advisor.create_object(task_name => my_task_name,
object_type =>'TABLE',
attr1 => 'SYSTEM',
attr2 => 'AL_APPLY',
attr3 => NULL,
attr4 => NULL,
attr5 => NULL,
object_id => obj_id);
-- Step 3设置任务参数
dbms_advisor.set_task_parameter(task_name=> my_task_name,
parameter=> 'recommend_all',
value => 'TRUE');
-- Step 4执行这个任务
dbms_advisor.execute_task(my_task_name);
END;
/
说明:
Table 14-2 DBMS_ADVISOR packageprocedures relevant to the Segment Advisor
| Package Procedure Name |
Description |
| CREATE_TASK |
Use this procedure to create the Segment Advisor task. Specify 'Segment Advisor' as the value of the ADVISOR_NAME parameter. |
| CREATE_OBJECT |
Use this procedure to identify the target object for segment space advice. The parameter values of this procedure depend upon the object type. Table 14-3 lists the parameter values for each type of object. Note: To request advice on an IOT overflow segment, use an object type of TABLE, TABLE PARTITION, or TABLE SUBPARTITION. Use the following query to find the overflow segment for an IOT and to determine the overflow segment table name to use with CREATE_OBJECT: select table_name, iot_name, iot_type from dba_tables; |
| SET_TASK_PARAMETER |
Use this procedure to describe the segment advice that you need. Table 14-4 shows the relevant input parameters of this procedure. Parameters not listed here are not used by the Segment Advisor. |
| EXECUTE_TASK |
Use this procedure to execute the Segment Advisor task. |
Table 14-3 Input forDBMS_ADVISOR.CREATE_OBJECT
| Input Parameter |
? |
? |
? |
? |
| OBJECT_TYPE |
ATTR1 |
ATTR2 |
ATTR3 |
ATTR4 |
| TABLESPACE |
tablespace name |
NULL |
NULL |
Unused. Specify NULL. |
| TABLE |
schema name |
table name |
NULL |
Unused. Specify NULL. |
| INDEX |
schema name |
index name |
NULL |
Unused. Specify NULL. |
| TABLE PARTITION |
schema name |
table |