How to use STA (SQL Tuning Advisor)

Source: Internet
Author: User

First, manually generated SQL Tuning Advisor
1. SQL Text Format:
DECLARE
My_task_name VARCHAR2 (30);
My_sqltext CLOB;
BEGIN
My_sqltext: = ' SELECT * from dba_segments WHERE owner= ' CLIC ' and segment_type= ' TABLE ';
My_task_name: = Dbms_sqltune. Create_tuning_task (Sql_text = My_sqltext,
Scope = ' comprehensive ',
Time_limit = 60,
Task_name = ' Test_sql_tuning_task1 ',
Description = ' Task to tune a query ');
Dbms_sqltune. Execute_tuning_task (task_name = ' test_sql_tuning_task1 ');
END;
/


2. SQL ID Format:
DECLARE
My_task_name VARCHAR2 (30);
My_sqltext CLOB;
BEGIN
My_task_name: = Dbms_sqltune. Create_tuning_task (sql_id = ' b3uaak09jfaxc ',
Scope = ' comprehensive ',
Time_limit = 60,
Task_name = ' Test_sql_tuning_task1 ',
Description = ' Task to tune a query ');
Dbms_sqltune. Execute_tuning_task (task_name = ' test_sql_tuning_task1 ');
END;
/


Second, view the generated Stareport:


Set Long 999999
Set Longchunksize 999999
Set serveroutput on size 999999
Set Linesize 200
Select Dbms_sqltune.report_tuning_task (' Test_sql_tuning_task1 ') from dual;


exec dbms_sqltune.drop_tuning_task (' Test_sql_tuning_task1 ');


Delete optimization Tasks
Sql> execdbms_sqltune.drop_tuning_task (task_name = ' li_sql_1 ');


Iii. Accept SQL Profile
Accept the proposed SQL profile, which is to create the Sql_profle
Sql> Execute dbms_sqltune.accept_sql_profile (task_name = ' Test_sql_tuning_task1 ', Task_owner = ' SYS ', replace = TRUE);

View the Sql_profile information created
Sql>select a.name,a.task_id,a.createdfrom dba_sql_profiles a,dba_advisor_log bwhere A.task_id=b.task_idand b.task _name= ' Test_sql_tuning_task1 ';


Delete Sql_profile
Sql>exec dbms_sqltune.drop_sql_profile (name = ' sys_sqlprof_01411bdf99410002 ');











Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.