Customise Consent Preferences

We use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.

The cookies that are categorised as "Necessary" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... 

Always Active

Necessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.

No cookies to display.

Functional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.

No cookies to display.

Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.

No cookies to display.

Performance cookies are used to understand and analyse the key performance indexes of the website which helps in delivering a better user experience for the visitors.

No cookies to display.

Advertisement cookies are used to provide visitors with customised advertisements based on the pages you visited previously and to analyse the effectiveness of the ad campaigns.

No cookies to display.

SQL TUNING ADVISOR

Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
  • User AvatarKiran Dalvi
  • 12 Dec, 2021
  • 0 Comments
  • 1 Min Read

SQL TUNING ADVISOR

SQL Tuning Advisor - Performance Tuning

SQL Tuning Advisor

How to run SQL Tuning Advisor Manually

SQL Tuning Advisor is SQL diagnostic software in the Oracle Database Tuning Pack. SQL Tuning Advisor is a mechanism for resolving problems related to suboptimally performing SQL statements. Use SQL Tuning Advisor to obtain recommendations for improving performance of high-load SQL statements, and prevent regressions by only executing optimal plans.

Find SQL Id of the Statement You Just Ran
Quickly retrieve the SQL ID of your last executed statement.
While connected to the database, you might want to know the sql id of the query you just ran (in your own session, not some other session).

Let’s run a sample query

set serveroutput off
Select * from hr.employees;

Now you might want to know the SQL ID of the above command. You must query PREV_SQL_ID column from V$SESSION

select prev_sql_id from v$session where sid=sys_context('userenv','sid');

You can check if the sql id returned above is correct by checking the SQL TEXT associated with the sql id

select sql_id, sql_text from v$sqltext 
where sql_id in ('fxdbrc4jhqn5r');

STEP 2: Run the SQL Advisor Manually

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
DECLARE
    l_sql_tune_task_id VARCHAR2(100);
BEGIN
    l_sql_tune_task_id := DBMS_SQLTUNE.create_tuning_task (
        sql_id => '7uk907hrgrj6j',
        scope => DBMS_SQLTUNE.scope_comprehensive,
        time_limit => 500,
        task_name => '7uk907hrgrj6j_tuning_task11',
        description => 'Tuning task1 for statement 7uk907hrgrj6j'
    );
    DBMS_OUTPUT.put_line('l_sql_tune_task_id: ' || l_sql_tune_task_id);
END;
/
 
-- Execute the SQL Tuning Task
EXEC DBMS_SQLTUNE.execute_tuning_task(task_name => '7uk907hrgrj6j_tuning_task11');
 
-- Retrieve and Display the Tuning Report
SET LONG 65536
SET LONGCHUNKSIZE 65536
SET LINESIZE 100
SELECT DBMS_SQLTUNE.report_tuning_task('7uk907hrgrj6j_tuning_task11') FROM dual;

******************************THE END***********************************************