Today One of Apps team ping me for A sql run everyday 15 minuts in Procedure, but last 3 day's its take 40 to 50 minutes.
I know that which query is problematic,i have SQL ID for that query and use the SQL tuning advisory to get the recommendation. Below is an example that I used.
SQL> DECLARE
l_sql_tune_task_id VARCHAR2(100);
BEGIN
l_sql_tune_task_id := DBMS_SQLTUNE.create_tuning_task (
sql_id => 'gq7k9ry2pazbh',
scope => DBMS_SQLTUNE.scope_comprehensive,
time_limit => 60,
task_name => 'gq7k9ry2pazbh_tuning_task',
description => 2 3 4 5 6 7 8 9 'Tuning task for statement gq7k9ry2pazbh');
DBMS_OUTPUT.put_line('l_sql_tune_task_id: ' || l_sql_tune_task_id);
END;
/ 10 11 12
PL/SQL procedure successfully completed.
SQL> EXEC DBMS_SQLTUNE.execute_tuning_task(task_name => 'gq7k9ry2pazbh_tuning_task');
^[[6~^H^H
PL/SQL procedure successfully completed.
SQL> SP2-0042: unknown command" - rest of line ignored.
SQL>
SQL> SELECT task_name, status FROM dba_advisor_log WHERE owner = 'SYS' and task_name = 'gq7k9ry2pazbh_tuning_task';
TASK_NAME STATUS
------------------------------ -----------
gq7k9ry2pazbh_tuning_task COMPLETED
SQL> SET LONG 10000;
SET PAGESIZE 1000
SET LINESIZE 200
SELECT DBMS_SQLTUNE.report_tuning_task('gq7k9ry2pazbh_tuning_task') AS recommendations FROM dual;
SET PAGESIZE 24 SQL> SQL> SQL>
RECOMMENDATIONS
--------------------------------------------------------------------------------
GENERAL INFORMATION SECTION
-------------------------------------------------------------------------------
Tuning Task Name : gq7k9ry2pazbh_tuning_task
Tuning Task Owner : SYS
Scope : COMPREHENSIVE
Time Limit(seconds): 60
Completion Status : COMPLETED
Started at : 09/16/2013 12:42:38
Completed at : 09/16/2013 12:43:11
-------------------------------------------------------------------------------
Schema Name: CRM
SQL ID : gq7k9ry2pazbh
SQL Text : sele...............................................
-------------------------------------------------------------------------------
There are no recommendations to improve the statement.
-------------------------------------------------------------------------------
- Consider accepting the recommended SQL profile.
SQL> execute dbms_sqltune.accept_sql_profile(task_name =>'gq7k9ry2pazbh_tuning_task', task_owner => 'SYS', replace => TRUE);
No comments:
Post a Comment