Created
March 26, 2014 18:45
-
-
Save eristoddle/84d524cb3a4f07ce848e to your computer and use it in GitHub Desktop.
Oracle tune queries
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DECLARE | |
l_sql VARCHAR2(2000) := ''; | |
l_sql_tune_task_id VARCHAR2(400) ; | |
recommendations VARCHAR2(2000) ; | |
RetVal CLOB; | |
MAXBUFSIZE NUMBER := 32767; | |
BEGIN | |
dbms_output.enable(1000000) ; | |
l_sql_tune_task_id := dbms_sqltune.create_tuning_task( | |
sql_text => l_sql, | |
time_limit => 120, | |
scope => DBMS_SQLTUNE.scope_comprehensive, | |
task_name => 'sql_id_tuning_task_SD', | |
description => 'Tuning task for statement sqlid' | |
) ; | |
BEGIN | |
DBMS_SQLTUNE.reset_tuning_task(task_name => 'sql_id_tuning_task_SD') ; | |
DBMS_SQLTUNE.execute_tuning_task(task_name => 'sql_id_tuning_task_SD') ; | |
RetVal := dbms_sqltune.report_tuning_task(l_sql_tune_task_id) ; | |
dbms_output.put_line('<PRE>') ; | |
dbms_output.put_line(dbms_lob.substr(RetVal, MAXBUFSIZE - 1, 1)) ; | |
dbms_output.put_line('</PRE>') ; | |
dbms_sqltune.DROP_TUNING_TASK('sql_id_tuning_task_SD') ; | |
EXCEPTION | |
WHEN OTHERS THEN | |
dbms_output.put_line('Unable to produce report.') ; | |
dbms_output.put_line(SQLERRM) ; | |
dbms_sqltune.DROP_TUNING_TASK('sql_id_tuning_task_SD') ; | |
END; | |
END; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment