Skip to Content
Oracle Database 11gR2 Performance Tuning Cookbook
book

Oracle Database 11gR2 Performance Tuning Cookbook

by Ciro Fiorillo
January 2012
Intermediate to advanced
542 pages
11h 28m
English
Packt Publishing
Content preview from Oracle Database 11gR2 Performance Tuning Cookbook

Using the SQL Tuning Advisor

In this recipe, we will see how to use the SQL Tuning Advisor to tune our queries.

Getting ready

To use the SQL Tuning Advisor, we need a special privilege; connect as SYSDBA and grant ADVISOR privilege to user SH:

CONNECT / AS SYSDBA
GRANT ADVISOR TO SH;

How to do it...

The following steps will demonstrate the SQL Tuning Advisor:

  1. Connect to the SH schema:
    CONNECT sh@TESTDB/sh
    
  2. Define an SQL Tuning Task for a single query:
    DECLARE
     l_task VARCHAR2(30);
     l_sql CLOB;
    BEGIN
     l_sql := 'SELECT AMOUNT_SOLD FROM sh.SALES S ' ||
      'WHERE S.CUST_ID IN ( '||
      'SELECT C.CUST_ID FROM sh.CUSTOMERS C ' ||
      'WHERE C.CUST_CREDIT_LIMIT IN (:l1, :l2, :l3))';
    
     l_task := DBMS_SQLTUNE.CREATE_TUNING_TASK(
      sql_text => l_sql,
     bind_list => sql_binds(anydata.ConvertNumber(10000), ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Oracle Database 11g Performance Tuning Recipes: A Problem-Solution Approach

Oracle Database 11g Performance Tuning Recipes: A Problem-Solution Approach

Sam R. Alapati, Darl Kuhn, Bill Padfield

Publisher Resources

ISBN: 9781849682602Other