Need help to debug SQL Tuning Advisor Error Message

Hi,
I am getting an error message while try to get recommendations from the SQL Tuning Advisor.
Environment:
Oracle Version:  11.2.0.3.0
O/S: AIX
Following is my code:
declare
my_task_name  varchar2 (30);
my_sqltext    clob;
begin
my_sqltext := 'SELECT DISTINCT MRKT_AREA AS DIVISION, PROMO_ID,
                PROMO_CODE,
                RBR_DTL_TYPE.PERF_DETL_TYP, 
                RBR_DTL_TYPE.PERF_DETL_DESC,
                RBR_DTL_TYPE.PERF_DETL_SUB_TYP,
                RBR_DTL_TYPE.PERF_DETL_SUB_DESC,
                BU_SYS_ITM_NUM,
                RBR_CPN_LOC_ITEM_ARCHIVE.CLI_SYS_ITM_DESC,
                PROMO_START_DATE,
                PROMO_END_DATE,
                PROMO_VALUE2,
                PROMO_VALUE1,
                EXEC_COMMENTS,
                PAGE_NUM,
                BLOCK_NUM,
                AD_PLACEMENT,
                BUYER_CODE,
                RBR_CPN_LOC_ITEM_ARCHIVE.CLI_STAT_TYP,
                RBR_MASTER_CAL_ARCHIVE.STATUS_FLAG
FROM  (PROMO_REPT_OWNER.RBR_CPN_LOC_ITEM_ARCHIVE
INNER JOIN PROMO_REPT_OWNER.RBR_MASTER_CAL_ARCHIVE
ON (RBR_CPN_LOC_ITEM_ARCHIVE.CLI_PROMO_ID = PROMO_ID)
AND (RBR_CPN_LOC_ITEM_ARCHIVE.CLI_PERF_DTL_ID = PERF_DETAIL_ID)
AND (RBR_CPN_LOC_ITEM_ARCHIVE.CLI_STR_NBR = STORE_ZONE)
AND (RBR_CPN_LOC_ITEM_ARCHIVE.CLI_ITM_ID = ITM_ID))
INNER JOIN PROMO_REPT_OWNER.RBR_DTL_TYPE
ON (RBR_MASTER_CAL_ARCHIVE.PERF_DETL_TYP = RBR_DTL_TYPE.PERF_DETL_TYP)
AND (RBR_MASTER_CAL_ARCHIVE.PERF_DETL_SUB_TYP = RBR_DTL_TYPE.PERF_DETL_SUB_TYP)
WHERE ( ((MRKT_AREA)=40)
AND ((RBR_DTL_TYPE.PERF_DETL_TYP)=1)
AND ((RBR_DTL_TYPE.PERF_DETL_SUB_TYP)=1) )
AND ((CLI_STAT_TYP)=1 Or (CLI_STAT_TYP)=6)
AND ((RBR_MASTER_CAL_ARCHIVE.STATUS_FLAG)=''A'')
AND ( ((PROMO_START_DATE) >= to_date(''2011-10-20'', ''YYYY-MM-DD'')
And (PROMO_END_DATE) <= to_date(''2011-10-26'', ''YYYY-MM-DD'')) )
ORDER BY MRKT_AREA';
my_task_name := dbms_sqltune.create_tuning_task
                             (sql_text => my_sqltext,
                              user_name => 'PROMO_REPT_OWNER',
                              scope     => 'COMPREHENSIVE',
                              time_limit => 3600,
                              task_name  => 'Test_Query',
                              description  => 'Test Query');
end;
begin
  dbms_sqltune.execute_tuning_task(task_name => 'Test_Query');
end;
set serveroutput on size unlimited;
set pagesize 5000
set linesize 130
set long 50000
set longchunksize 500000
SELECT DBMS_SQLTUNE.REPORT_TUNING_TASK('Test_Query') FROM DUAL;
Output:
snippet .....
FINDINGS SECTION (1 finding)
1- Index Finding (see explain plans section below)
The execution plan of this statement can be improved by creating one or more
indices.
Recommendation (estimated benefit: 71.48%)
- Consider running the Access Advisor to improve the physical schema design
or creating the recommended index.
Error: Cannot fetch actions for recommendation: INDEX
Error: ORA-06502: PL/SQL: numeric or value error: character string buffer too small
Rationale
Creating the recommended indices significantly improves the execution plan
of this statement. However, it might be preferable to run "Access Advisor"
using a representative SQL workload as opposed to a single statement. This
will allow to get comprehensive index recommendations which takes into
account index maintenance overhead and additional space consumption.
snippet
Any ideas why I am getting ORA-06502 error?
Thanks in advance
Rogers

Bug 14407401 - ORA-6502 from index recommendation section of DBMS_SQLTUNE output (Doc ID 14407401.8)
Fixed:
The fix for 14407401 is first included in
12.1.0.1 (Base Release)

Similar Messages

  • SQL Tuning Advisor  Error

    I wanted to use the SQL Tuning Advisor feature of the SQL Worksheet. The DBA granted me ADVISOR system privilege. But when I tried to use the feature, I get the following errors:
    An error was encountered performing the requested operation:
    ORA-06550: line 20, column 101:
    PLS-00103: Encountered the symbol "ANYDATA" when expecting one of the folllowing:
    .(),*%&=-+</> at in is mod remainder not rem
    <an exponenet (**) <> or != or ~= >= <> and or like LIKE2_
    LIKE4_LIKEC_between|| multiset member SUBMULTISET_
    The symbol "." was substituted for "ANYDATA" to continue.
    ORA-6550: line 20, column 140:
    PLS-00103: Encountered the symbol "ANYDATA" when expecting one of the folllowing:
    .(),*%&=-+</> at in is mod remainder not rem
    <an exponenet (**) <> or != or ~= >= <> and or like LIKE2_
    LIKE4_LIKEC_between|| mul
    ORA-6550:line 20, column 179:
    PLS-00103: Encountered the symbol "ANYDATA" when expecting one of the folllowing:
    .(),*%&=-+</> at in is mod remainder not rem
    <an exponenet (**) <> or != or ~= >= <> and or like LIKE2_
    LIKE4_LIKEC_between|| multiset
    06550,00000 - "line %s, column %s:\n%s"
    *Cause: Usually a PL/SQL compilation error.
    *Action:
    Vendor code 6550Then I get this right after the previous one:
    An error was encountered performing the requested operation:
    ORA-13605: The specified task or boject staName12325 does not exist for the current user.
    ORA-06512: at "SYS.DBMS_SYS_ERROR", line 86
    ORA-06512: at "SYS.PRVT_ADVISOR", line 4841
    ORA-06512: at "SYS.DBMS_SQLTUNE", line 1093
    ORA-06512: at line 2
    13605.0000 - "The specified task or object %s does not exist for the current user."
    *Cause:   The user attempted to reference an advisor task or object
        using a anme that does not exist in the Advisor repository.
    *Action:  Adjust the name and retry the operation.
    Vendor code 13605Can someone please help me? I am not a DBA so I stumped by these error codes.
    Oracle SQL Developer 3.0.04 Build MAIn-04.34
    Oracle Database 10g Enterprise Edition Release 10.2.0.5.0
    Robert

    The query is
    select      "V_CDR_OUTGOING_CALLS"."FIRST_NAME" as "FIRST_NAME",
          "V_CDR_OUTGOING_CALLS"."MIDDLE_INITIAL" as "MIDDLE_INITIAL",
          "V_CDR_OUTGOING_CALLS"."LAST_NAME" as "LAST_NAME",
          "V_CDR_OUTGOING_CALLS"."ORG_UNIT" as "ORG_UNIT",
          "V_CDR_OUTGOING_CALLS"."DEPT_DESC" as "DEPT_DESC",
          "V_CDR_OUTGOING_CALLS"."FROM_NUMBER" as "FROM_NUMBER",
          "V_CDR_OUTGOING_CALLS"."TO_NUMBER" as "TO_NUMBER",
          "V_CDR_OUTGOING_CALLS"."TO_CITY" as "TO_CITY",
          "V_CDR_OUTGOING_CALLS"."TO_STATE" as "TO_STATE",
          "V_CDR_OUTGOING_CALLS"."DATETIME_CONNECT" as "DATETIME_CONNECT",
          "V_CDR_OUTGOING_CALLS"."DURATION_MIN" as "DURATION_MIN"
    from      "V_CDR_OUTGOING_CALLS" "V_CDR_OUTGOING_CALLS"
    where :P12_PHONE_NUMBER  = FROM_NUMBER or :P12_PHONE_NUMBER = TO_NUMBER
    AND "V_CDR_OUTGOING_CALLS"."DATETIME_CONNECT" BETWEEN to_date(:P12_START_DATE,'MM/DD/YYYY') AND to_date(:P12_END_DATE,'MM/DD/YYYY')The view is
    CREATE OR REPLACE FORCE VIEW "VOIP"."V_CDR_OUTGOING_CALLS" ("ID", "EMPID", "FIRST_NAME", "MIDDLE_INITIAL", "LAST_NAME", "ORG_UNIT", "DEPT_DESC", "PHONE", "FROM_NUMBER", "TO_NUMBER", "TO_CITY", "TO_STATE", "DATETIME_CONNECT", "DATETIME_DISCONNECT", "DURATION_SEC", "DURATION_MIN")
    AS
      SELECT c.ID,
        e.empid empid,
        e.first_name,
        e.middle_initial,
        e.last_name,
        e.org_descr,
        e.dept_desc,
        e.full_telephone,
        c.from_number,
        c.to_number,
        x.city to_city,
        x.state to_state,
        c.datetime_connect,
        c.datetime_disconnect,
        c.duration_sec,
        c.duration_min
      FROM v_cdr c ,
        v_cdr_emp e,
        telephone_exchanges x
      WHERE c.from_number         = e.phone
      AND SUBSTR(c.to_number,1,7) = x.EXCHANGE
      AND LENGTH(c.to_number)     > 7;The table and views are defined as:
    CREATE TABLE "VOIP"."TELEPHONE_EXCHANGES"
        "EXCHANGE" VARCHAR2(7 BYTE) NOT NULL ENABLE,
        "CITY"     VARCHAR2(200 BYTE),
        "STATE"    VARCHAR2(2 BYTE),
        CONSTRAINT "TELEPHONE_EXCHANGES_PK" PRIMARY KEY ("EXCHANGE") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "VOIPDATA" ENABLE
      PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING STORAGE
        INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT
      TABLESPACE "VOIPDATA" ;
    CREATE OR REPLACE FORCE VIEW "VOIP"."V_CDR" ("ID", "FROM_NUMBER", "TO_NUMBER", "DATETIME_CONNECT", "DATETIME_DISCONNECT", "DURATION_SEC", "DURATION_MIN", "PKID", "DATE_OF_CALL")
    AS
      SELECT ID,
        DECODE( LENGTH(CALLINGPARTYNUMBER),6, SUBSTR(CALLINGPARTYNUMBER,1,2)
        || '-'
        ||SUBSTR(CALLINGPARTYNUMBER,3) ,10, SUBSTR(CALLINGPARTYNUMBER,1,3)
        || '-'
        ||SUBSTR(CALLINGPARTYNUMBER,4,3)
        || '-'
        ||SUBSTR(CALLINGPARTYNUMBER,7) ,CALLINGPARTYNUMBER)FROM_NUMBER,
        DECODE( LENGTH(ORIGINALCALLEDPARTYNUMBER), 6, SUBSTR( ORIGINALCALLEDPARTYNUMBER,1,2)
        || '-'
        ||SUBSTR(ORIGINALCALLEDPARTYNUMBER,3) , 10, SUBSTR( ORIGINALCALLEDPARTYNUMBER,1,3)
        || '-'
        ||SUBSTR(ORIGINALCALLEDPARTYNUMBER,4,3)
        || '-'
        ||SUBSTR(ORIGINALCALLEDPARTYNUMBER,7) , 12, SUBSTR( ORIGINALCALLEDPARTYNUMBER,3,3)
        || '-'
        ||SUBSTR(ORIGINALCALLEDPARTYNUMBER,6,3)
        || '-'
        ||SUBSTR(ORIGINALCALLEDPARTYNUMBER,9) , ORIGINALCALLEDPARTYNUMBER) TO_NUMBER,
        new_time(to_date(TO_CHAR(to_date('01.01.70','dd.mm.rr')+ (DATETIMECONNECT/( 60 *60*24)), 'mm-dd-yyyy hh24:mi:ss'),'mm-dd-yyyy hh24:mi:ss'),'GMT','EDT') DATETIME_CONNECT,
        new_time(to_date(TO_CHAR(to_date('01.01.70','dd.mm.rr')+ ( DATETIMEDISCONNECT /(60*60*24)), 'mm-dd-yyyy hh24:mi:ss'),'mm-dd-yyyy hh24:mi:ss'),'GMT','EDT') DATETIME_DISCONNECT,
        duration Duration_sec,
        ROUND(duration/60,2) Duration_MIN,
        pkid,
        to_date(TO_CHAR(new_time(to_date(TO_CHAR(to_date('01.01.70','dd.mm.rr')+ (DATETIMECONNECT/( 60 *60*24)), 'mm-dd-yyyy hh24:mi:ss'),'mm-dd-yyyy hh24:mi:ss'),'GMT','EDT'),'DD-MON-YYYY')) date_of_call
      FROM CALL_DETAILS_CDR C
      WHERE datetimeconnect <> 0;
    The above view is based on table CALL_DETAILS_CDR defined as:
    CREATE TABLE "VOIP"."CALL_DETAILS_CDR"
        "ID"                             NUMBER NOT NULL ENABLE,
        "CDRRECORDTYPE"                  NUMBER,
        "G_CALLMANAGERID"                NUMBER,
        "G_CALLID"                       NUMBER,
        "O_LEGCALLIDENTIFIER"            NUMBER,
        "DATETIMEORIGINATION"            NUMBER,
        "O_NODEID"                       NUMBER,
        "O_SPAN"                         NUMBER,
        "O_IPADDR"                       NUMBER,
        "CALLINGPARTYNUMBER"             VARCHAR2(50 BYTE),
        "CALLINGPARTY_USERID"            VARCHAR2(128 BYTE),
        "O_CAUSE_LOCATION"               NUMBER,
        "O_CAUSE_VALUE"                  NUMBER,
        "O_PRECEDENCELEVEL"              NUMBER,
        "O_MEDIATRANSPORTADDR_IP"        NUMBER,
        "O_MEDIATRANSPORTADDR_PORT"      NUMBER,
        "O_MCAP_PAYLOADCAPABILITY"       NUMBER,
        "O_MCAP_MAXFRAMESPERPACKET"      NUMBER,
        "O_MCAP_G723BITRATE"             NUMBER,
        "O_VCAP_CODEC"                   NUMBER,
        "O_VCAP_BANDWIDTH"               NUMBER,
        "O_VCAP_RESOLUTION"              NUMBER,
        "O_VIDEOTRANSPORTADDR_IP"        NUMBER,
        "O_VIDEOTRANSPORTADDR_PORT"      NUMBER,
        "O_RSVPAUDIOSTAT"                VARCHAR2(64 BYTE),
        "O_RSVPVIDEOSTAT"                VARCHAR2(64 BYTE),
        "DESTLEGIDENTIFIER"              NUMBER,
        "DESTNODEID"                     NUMBER,
        "DESTSPAN"                       NUMBER,
        "DESTIPADDR"                     NUMBER,
        "ORIGINALCALLEDPARTYNUMBER"      VARCHAR2(50 BYTE),
        "FINALC_PARTYNUMBER"             VARCHAR2(50 BYTE),
        "FINALC_PARTY_USERID"            VARCHAR2(128 BYTE),
        "DESTCAUSE_LOCATION"             NUMBER,
        "DESTCAUSE_VALUE"                NUMBER,
        "DESTPRECEDENCELEVEL"            NUMBER,
        "DESTMEDIATRANSPORTADDR_IP"      NUMBER,
        "DESTMEDIATRANSPORTADDR_PORT"    NUMBER,
        "DESTMCAP_PAYLOADCAPABILITY"     NUMBER,
        "DESTMCAP_MAXFRAMESPERPACKET"    NUMBER,
        "DESTMCAP_G723BITRATE"           NUMBER,
        "DV_CAP_CODEC"                   NUMBER,
        "DV_CAP_BANDWIDTH"               NUMBER,
        "DV_CAP_RESOLUTION"              NUMBER,
        "DV_TRANSPORTADDR_IP"            NUMBER,
        "DV_TRANSPORTADDR_PORT"          NUMBER,
        "DESTRSVPAUDIOSTAT"              VARCHAR2(64 BYTE),
        "DESTRSVPVIDEOSTAT"              VARCHAR2(64 BYTE),
        "DATETIMECONNECT"                NUMBER,
        "DATETIMEDISCONNECT"             NUMBER,
        "LASTREDIRECTDN"                 VARCHAR2(50 BYTE),
        "PKID"                           VARCHAR2(4000 BYTE),
        "O_INALCALLEDPARTYNUM_PARTITION" VARCHAR2(50 BYTE),
        "CALLINGPARTYNUM_PARTITION"      VARCHAR2(50 BYTE),
        "FINALC_PARTYNUM_PARTITION"      VARCHAR2(50 BYTE),
        "LASTREDIRECTDNPARTITION"        VARCHAR2(50 BYTE),
        "DURATION"                       NUMBER,
        "O_DEVICENAME"                   VARCHAR2(129 BYTE),
        "DESTDEVICENAME"                 VARCHAR2(129 BYTE),
        "O_CALLTERMINATION_BEHALF"       NUMBER,
        "DESTCALLTERMINATION_BEHALF"     NUMBER,
        "O_CALLEDPARTYREDIRECT_BEHALF"   NUMBER,
        "LASTREDIRECTREDIRECT_BEHALF"    NUMBER,
        "O_CALLEDPARTYREDIRECTREASON"    NUMBER,
        "LASTREDIRECTREDIRECTREASON"     NUMBER,
        "DESTCONVERSATIONID"             NUMBER,
        "G_CALLID_CLUSTERID"             VARCHAR2(50 BYTE),
        "JOIN_BEHALF"                    NUMBER,
        "COMMENTS"                       VARCHAR2(2048 BYTE),
        "AUTHCODEDESCRIPTION"            VARCHAR2(50 BYTE),
        "AUTHORIZATIONLEVEL"             NUMBER,
        "CLIENTMATTERCODE"               VARCHAR2(32 BYTE),
        "O_DTMFMETHOD"                   NUMBER,
        "DESTDTMFMETHOD"                 NUMBER,
        "CALLSECUREDSTATUS"              NUMBER,
        "O_CONVERSATIONID"               NUMBER,
        "O_MCAP_BANDWIDTH"               NUMBER,
        "DESTMCAP_BANDWIDTH"             NUMBER,
        "AUTHORIZATIONCODEVALUE"         VARCHAR2(32 BYTE),
        "OUTPULSEDCALLINGPARTYNUMBER"    VARCHAR2(50 BYTE),
        "OUTPULSEDCALLEDPARTYNUMBER"     VARCHAR2(50 BYTE),
        "O_IPV4V6ADDR"                   VARCHAR2(64 BYTE),
        "DESTIPV4V6ADDR"                 VARCHAR2(64 BYTE),
        "O_VCAP_CODEC_CHAN2"             NUMBER,
        "O_VCAP_BANDWIDTH_CHAN2"         NUMBER,
        "O_VCAP_RESOLUTION_CHAN2"        NUMBER,
        "O_V_TRANSPORTADDR_IP_CHAN2"     NUMBER,
        "O_V_TRANSPORTADDR_PORT_CHAN2"   NUMBER,
        "O_V_OCHANNEL_ROLE_CHAN2"        NUMBER,
        "DV_CAP_CODEC_CHAN2"             NUMBER,
        "DV_CAP_BANDWIDTH_CHAN2"         NUMBER,
        "DV_CAP_RESOLUTION_CHAN2"        NUMBER,
        "DV_TRANSPORTADDR_IP_CHAN2"      NUMBER,
        "DV_TRANSPORTADDR_PORT_CHAN2"    NUMBER,
        "DV_CHANNEL_ROLE_CHAN2"          NUMBER,
        "DATE_CREATED" DATE,
        CONSTRAINT "CALL_DETAILS_CDR_PK" PRIMARY KEY ("ID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "VOIPDATA" ENABLE,
        CONSTRAINT "PKID_UNIQUE" UNIQUE ("PKID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 167 COMPUTE STATISTICS STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "VOIPDATA" ENABLE
      PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING STORAGE
        INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT
      TABLESPACE "VOIPDATA" ;
    CREATE INDEX "VOIP"."CALL_DETAILS_CDR_INDEX3" ON "VOIP"."CALL_DETAILS_CDR"
        "ORIGINALCALLEDPARTYNUMBER",
        "DATETIMECONNECT"
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE
        INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT
      TABLESPACE "VOIPDATA" ;
    CREATE INDEX "VOIP"."CALL_DETAILS_CDR_INDEX2" ON "VOIP"."CALL_DETAILS_CDR"
        "CALLINGPARTYNUMBER",
        "DATETIMECONNECT"
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE
        INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT
      TABLESPACE "VOIPDATA" ;
    CREATE UNIQUE INDEX "VOIP"."CALL_DETAILS_CDR_PK" ON "VOIP"."CALL_DETAILS_CDR"
        "ID"
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE
        INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT
      TABLESPACE "VOIPDATA" ;
    CREATE UNIQUE INDEX "VOIP"."PKID_UNIQUE" ON "VOIP"."CALL_DETAILS_CDR"
        "PKID"
      PCTFREE 10 INITRANS 2 MAXTRANS 167 COMPUTE STATISTICS STORAGE
        INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT
      TABLESPACE "VOIPDATA" ;
    The view, V_CDR_EMP, is defined as:
    CREATE OR REPLACE FORCE VIEW "VOIP"."V_CDR_EMP" ("EMPID", "FIRST_NAME", "MIDDLE_INITIAL", "LAST_NAME", "ORG", "ORG_DESCR", "DEPT", "DEPT_DESC", "ADDRESS", "PHONE", "FULL_TELEPHONE")
    AS
      SELECT e.empid,
        e.First_name,
        e.Middle_Initial,
        e.Last_name,
        e.Org,
        o.org_descr,
        e.Dept,
        d.Dept_desc,
        e.Address,
        DECODE (SUBSTR(e.address,1,6),'ONEMAD','10-'
        || SUBSTR (e.telephone,9), '225PAS','10-'
        || SUBSTR (e.telephone,9), '233PAS','10-'
        || SUBSTR (e.telephone,9), '115BWA','10-'
        || SUBSTR (e.telephone,9), DECODE(SUBSTR(e.address,1,4),'PATC','11-'
        || SUBSTR (e.telephone,9), 'JAMS','12-'
        || SUBSTR (e.telephone,9), 'JSTC','12-'
        || SUBSTR (e.telephone,9), 'PABT','19-'
        || SUBSTR (e.telephone,9), 'TLPT','08-'
        || SUBSTR (e.telephone,9), 'HCMF','12-'
        || SUBSTR (e.telephone,9), DECODE(SUBSTR(e.address,1,3),'GWB','17-'
        || SUBSTR (e.telephone,9), 'LGA','13-'
        || SUBSTR (e.telephone,9), 'EWR','14-'
        || SUBSTR (e.telephone,9), 'JFK','15-'
        || SUBSTR (e.telephone,9), 'SIB','18-'
        || SUBSTR (e.telephone,9), 'MVP','14-'
        || SUBSTR (e.telephone,9), 'WTC','10-'
        || SUBSTR (e.telephone,9), 'CON','12-'
        || SUBSTR (e.telephone,9), DECODE(SUBSTR(e.address,1,2),'HT','11-'
        || SUBSTR (e.telephone,9), 'BP','06-'
        || SUBSTR (e.telephone,9), 'LT','16-'
        || SUBSTR (e.telephone,9), 'PN','07-'
        || SUBSTR (e.telephone,9), DECODE(SUBSTR(e.address,1,5),'2GWAY','04-'
        || SUBSTR (e.telephone,9), '3GWAY','04-'
        || SUBSTR (e.telephone,9), DECODE(SUBSTR(e.address,1,10),'PORT IVORY','07-'
        || SUBSTR (e.telephone,9),e.telephone) ) ) ) ) ) phone,
        e.telephone full_telephone
      FROM [email protected] e ,
        [email protected] d ,
        [email protected] o
      WHERE e.active = 'Y'
      AND e.dept     = d.dept
      AND e.org      = o.org;Robert

  • Sql Tuning advisor Misc message

    HI I am using SQL Tuning advisor to tune one of my queries.I am gettin following recommendation
    Miscellaneous     The optimizer could not merge the view at line ID 4 of the execution plan.
    I am attaching my execution plan .Please let me know what does that mean and what action i have to take
    Execution Plan
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Tim
    | 0 | SELECT STATEMENT | | | | 10130 (100)|
    | 1 | HASH GROUP BY | | 56 | 15848 | 10130 (1)| 00:
    | 2 | VIEW | | 56 | 15848 | 10129 (1)| 00:
    | 3 | WINDOW BUFFER | | 56 | 63280 | 10129 (1)| 00:
    | 4 | VIEW | | 56 | 63280 | 10129 (1)| 00:
    | 5 | WINDOW SORT | | 56 | 24752 | 10129 (1)| 00:
    | 6 | NESTED LOOPS | | 56 | 24752 | 10128 (1)| 00:
    | 7 | NESTED LOOPS | | 55 | 22165 | 10018 (1)| 00:
    | 8 | NESTED LOOPS | | 58 | 21866 | 9902 (1)| 00:
    | 9 | NESTED LOOPS | | 60 | 21060 | 9781 (1)| 00:
    | 10 | NESTED LOOPS | | 60 | 19020 | 9661 (1)| 00:
    | 11 | NESTED LOOPS | | 63 | 18333 | 9534 (1)| 00:
    | 12 | NESTED LOOPS | | 67 | 17755 | 9400 (1)| 00:
    | 13 | NESTED LOOPS | | 67 | 12931 | 9333 (1)| 00:
    | 14 | NESTED LOOPS | | 67 | 11725 | 9266 (1)| 00:
    | 15 | HASH JOIN | | 67 | 10854 | 9198 (1)| 00:
    | 16 | HASH JOIN | | 67 | 10117 | 9160 (1)| 00:
    | 17 | HASH JOIN | | 67 | 9581 | 9154 (1)| 00:
    | 18 | TABLE ACCESS BY INDEX ROWID | T_FACT_AGGR_TAX_RPTG | 1355 | 178K| 9149 (1)| 00:
    | 19 | NESTED LOOPS | | 67 | 9045 | 9149 (1)| 00:
    | 20 | MAT_VIEW ACCESS FULL | MV_T_DIM_INSTM | 1 | 43 | 53 (4)| 00:
    | 21 | BITMAP CONVERSION TO ROWIDS| | | | |
    | 22 | BITMAP INDEX SINGLE VALUE | XB_T_FACT_AGGR_TAX_RPTG_N5 | | | |
    | 23 | MAT_VIEW ACCESS FULL | MV_T_DIM_CURR | 457 | 3656 | 5 (0)| 00:
    | 24 | MAT_VIEW ACCESS FULL | MV_T_DIM_CURR | 457 | 3656 | 5 (0)| 00:
    | 25 | VIEW | index$_join$_007 | 3480 | 38280 | 38 (6)| 00:
    | 26 | HASH JOIN | | | | |
    | 27 | INDEX FAST FULL SCAN | XPK_MV_ORIG_T_DIM_MNGMT_ENT | 3480 | 38280 | 10 (0)| 00:
    | 28 | INDEX FAST FULL SCAN | X_MV_CUR_T_DIM_MNGMT_ENT_N1 | 3480 | 38280 | 27 (4)| 00:
    | 29 | TABLE ACCESS BY INDEX ROWID | T_DIM_DATE | 1 | 13 | 1 (0)| 00:
    | 30 | INDEX UNIQUE SCAN | XPK_T_DIM_DATE | 1 | | 0 (0)|
    | 31 | MAT_VIEW ACCESS BY INDEX ROWID | MV_T_DIM_EXTL_PARTY | 1 | 18 | 1 (0)| 00:
    | 32 | INDEX UNIQUE SCAN | XPK_MV_T_DIM_EXTL_PARTY | 1 | | 0 (0)|
    | 33 | MAT_VIEW ACCESS BY INDEX ROWID | MV_T_DIM_LGL_ENT_BR | 1 | 72 | 1 (0)| 00:
    | 34 | INDEX UNIQUE SCAN | XPK_MV_O_LGL_ENT_BR | 1 | | 0 (0)|
    | 35 | TABLE ACCESS BY INDEX ROWID | T_FACT_DAILY_RATE | 1 | 330 | 2 (0)| 00:
    | 36 | INDEX UNIQUE SCAN | XPK_T_FACT_DAILY_RATE | 1 | | 1 (0)| 00:
    | 37 | TABLE ACCESS BY INDEX ROWID | T_FACT_DAILY_RATE | 1 | 356 | 2 (0)| 00:
    | 38 | INDEX UNIQUE SCAN | XPK_T_FACT_DAILY_RATE | 1 | | 1 (0)| 00:
    | 39 | MAT_VIEW ACCESS BY INDEX ROWID | MV_T_DIM_TRD | 1 | 34 | 2 (0)| 00:
    | 40 | INDEX UNIQUE SCAN | XPK_MV_T_DIM_TRD | 1 | | 1 (0)| 00:
    | 41 | TABLE ACCESS BY INDEX ROWID | T_FACT_DAILY_RATE | 1 | 382 | 2 (0)| 00:
    | 42 | INDEX UNIQUE SCAN | XPK_T_FACT_DAILY_RATE | 1 | | 1 (0)| 00:
    | 43 | TABLE ACCESS BY INDEX ROWID | T_FACT_DAILY_RATE | 1 | 442 | 2 (0)| 00:
    | 44 | INDEX UNIQUE SCAN | XPK_T_FACT_DAILY_RATE | 1 | | 1 (0)| 00:
    | 45 | TABLE ACCESS BY INDEX ROWID | T_FACT_AGGR_WGT_AVG_RATE | 1 | 39 | 2 (0)| 00:
    | 46 | INDEX UNIQUE SCAN | XPK_T_FACT_AGGR_WGT_AVG_RATE | 1 | | 1 (0)| 00:
    Thanks
    Pramod Garre

    No version number? Why? And I am not interested in manually formatting your post to make it readable.
    In the FAQ which you should have read there is a clear explanation of how to use tags so that what you copy in retains its formatting.
    Please read the FAQ and correct what you posted as well as providing more information such as the type of application, the DML being executed, and why you are using the tuning advisor at all?
    There doesn't seem to be much here that couldn't be far more easily created with:
    explain plan for
    <your SQL statement>
    followed by:
    SELECT * FROM TABLE(dbms_xplan.display);                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Oracle 10g SQL Tuning Advisor

    I am working as a junior DBA. I tried to tune a query using SQL Tuning Advisor that is with DBMS_SQLTUNE.I have created the tuning task successfully with DBMS_SQLTUNE.create_tuning_task.But when i execute the tuning task with EXEC DBMS_SQLTUNE.execute_tuning_task() i got an error like
    SQL> EXEC DBMS_SQLTUNE.execute_tuning_task(task_name => 'rep_three');
    BEGIN DBMS_SQLTUNE.execute_tuning_task(task_name => 'rep_three'); END;
    ERROR at line 1:
    ORA-00081: address range [0x60000000000A7D70, 0x60000000000A7D74) is not
    readable
    ORA-00600: internal error code, arguments: [kesatmGetSqlStats:optCost], [], [],
    ORA-06512: at "SYS.PRVT_ADVISOR", line 1624
    ORA-06512: at "SYS.DBMS_ADVISOR", line 186
    ORA-06512: at "SYS.DBMS_SQLTUNE", line 1008
    ORA-06512: at line 1The oracle version is Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bi. The OS is HP-UX. The version is HP-UX B.11.23 U ia64.
    I tried to execute DBMS_SQLTUNE as DWH user.I have granted the advisor,DROP ANY SQL PROFILE,ALTER ANY SQL PROFILE,CREATE ANY SQL PROFILE privileges and DBA roles to the DWH user. The way i ran DBMS_SQLTUNE is, first i logged in as DWH user and i tried to execute the query for getting the SQL_ID for the query. For getting the SQL_ID i selected the SQL_ID column value for the DWH user session from v$session.I kept that query executing and meanwhile i opened another session as DWH user and created the tuning task as follows
    DECLARE
      l_sql_tune_task_id  VARCHAR2(100);
    BEGIN
      l_sql_tune_task_id := DBMS_SQLTUNE.create_tuning_task (
                              sql_id      => 'b65fj39dkkb9v',
                              scope       => DBMS_SQLTUNE.scope_limited,
                              time_limit  => 3600,
                              task_name   => 'rep_three',
                              description => 'Report Tuning');
      DBMS_OUTPUT.put_line('l_sql_tune_task_id: ' || l_sql_tune_task_id);
    END;
    /The creation of tuning task was successful.And i executed the tuning task as follows
    EXEC DBMS_SQLTUNE.execute_tuning_task(task_name => 'rep_three');The above mentioned errors came when i executed the tuning task.
    I am also adding the query which i have tried to tune
    select * from dwh.beneficiary_dim BEN_DIM,
                     (Select adr_dp_id,
                   adr_account_no,
                   ADR_ADDRESS_LINE_1 || ' ' ||
                   ADR_ADDRESS_LINE_2 || ' ' ||
                   ADR_ADDRESS_LINE_3 || ' ' ||
                   ADR_ADDRESS_LINE_4 as ADDRESS,
                   adr_pin_code,adr_phone_no,adr_fax_no
              from dwh.beneficiary_address_dim where adr_type_id = 1) PERMANENT_ADD_DIM,
           (Select adr_dp_id,
                   adr_account_no,
                   ADR_ADDRESS_LINE_1 || ' ' ||
                   ADR_ADDRESS_LINE_2 || ' ' ||
                   ADR_ADDRESS_LINE_3 || ' ' ||
                   ADR_ADDRESS_LINE_4 as ADDRESS,
                   adr_pin_code,adr_phone_no,adr_fax_no
              from dwh.beneficiary_address_dim where adr_type_id = 2) BANK_ADD_DIM,
           (Select adr_dp_id,
                   adr_account_no,
                   ADR_ADDRESS_LINE_1 || ' ' ||
                   ADR_ADDRESS_LINE_2 || ' ' ||
                   ADR_ADDRESS_LINE_3 || ' ' ||
                   ADR_ADDRESS_LINE_4 as ADDRESS,
                   adr_pin_code,adr_phone_no,adr_fax_no
              from dwh.beneficiary_address_dim where adr_type_id = 3) NOM_GUARDIAN_ADD_DIM,
           (Select adr_dp_id,
                   adr_account_no,
                   ADR_ADDRESS_LINE_1 || ' ' ||
                   ADR_ADDRESS_LINE_2 || ' ' ||
                   ADR_ADDRESS_LINE_3 || ' ' ||
                   ADR_ADDRESS_LINE_4 as ADDRESS,
                   adr_pin_code,adr_phone_no,adr_fax_no
              from dwh.beneficiary_address_dim where adr_type_id = 4) CORR_ADD_DIM,
           (Select adr_dp_id,
                   adr_account_no,
                   ADR_ADDRESS_LINE_1 || ' ' ||
                   ADR_ADDRESS_LINE_2 || ' ' ||
                   ADR_ADDRESS_LINE_3 || ' ' ||
                   ADR_ADDRESS_LINE_4 as ADDRESS,
                   adr_pin_code,adr_phone_no,adr_fax_no
              from dwh.beneficiary_address_dim where adr_type_id = 6) MINOR_ADDRESS,
                     (Select rp.requestid as requestid,
    decode(rp.value,'ALL','ALL','','ALL',decode(substr(rp.value,1,instr(rp.value,'|',1,1)-1),'','ALL',substr(rp.value,1,instr(rp.value,'|',1,1)-1))) as Name,
    decode(rp.value,'ALL','ALL','','ALL',decode(substr(rp.value,(instr(rp.value,'|',1,1)+1),((instr(rp.value,'|',1,2))-(instr(rp.value,'|',1,1)+1))),'','ALL',substr(rp.value,(instr(rp.value,'|',1,1)+1),((instr(rp.value,'|',1,2))-(instr(rp.value,'|',1,1)+1))))) as Address,
    decode(rp.value,'ALL','ALL','','ALL',decode(substr(rp.value,(instr(rp.value,'|',1,2)+1)),'','ALL',substr(rp.value,(instr(rp.value,'|',1,2)+1)))) as PAN
                      from disadmin.requestparameters rp, disadmin.requestparameters rps, disadmin.reportrequests rr
                     where rp.parameterid = 'CNAS_PARAM_VALUE'   
                       and rr.status = 'A'
                       and rp.requestid = rr.id
                       and rp.id = rps.id) P_PARAM_VALUE,
                     (Select rp.requestid as requestid, rp.value as Type
                        from disadmin.requestparameters rp, disadmin.reportrequests rr
                       where rp.parameterid = 'CNAS_NAME_TYPE'
                         and rr.status = 'A'
                         and rp.requestid = rr.id)  P_NAME_TYPE,
                     (Select rp.requestid as requestid, rp.value as Addtype
                        from disadmin.requestparameters rp, disadmin.reportrequests rr
                       where rp.parameterid = 'CNAS_ADDRESS_TYPE'
                         and rr.status = 'A'
                         and rp.requestid = rr.id) P_ADDRESS_TYPE    
       where ( 1= case when P_NAME_TYPE.Type = 'F' then
                   case when BEN_DIM.BDM_FIRST_HOLDER_NAME like DECODE(P_PARAM_VALUE.Name,'ALL','%'||BEN_DIM.BDM_FIRST_HOLDER_NAME||'%','%'||P_PARAM_VALUE.Name||'%')
                             or BEN_DIM.BDM_FIRST_HOLDER_SURNAME like DECODE(P_PARAM_VALUE.Name,'ALL','%'||BEN_DIM.BDM_FIRST_HOLDER_SURNAME||'%','%'||P_PARAM_VALUE.Name||'%')
                        then 1
                   else null end
                 else            
                   case when P_NAME_TYPE.Type = 'ALL' then
                     case when (BEN_DIM.BDM_FIRST_HOLDER_NAME like DECODE(P_PARAM_VALUE.Name,'ALL','%'||BEN_DIM.BDM_FIRST_HOLDER_NAME||'%','%'||P_PARAM_VALUE.Name||'%')
                                or BEN_DIM.BDM_FIRST_HOLDER_SURNAME like DECODE(P_PARAM_VALUE.Name,'ALL','%'||BEN_DIM.BDM_FIRST_HOLDER_SURNAME||'%','%'||P_PARAM_VALUE.Name||'%'))
                                and BEN_DIM.BDM_SECOND_HOLDER_NAME like DECODE(P_PARAM_VALUE.Name,'ALL','%'||BEN_DIM.BDM_SECOND_HOLDER_NAME||'%','%'||P_PARAM_VALUE.Name||'%')
                                and BEN_DIM.BDM_THIRD_HOLDER_NAME like DECODE(P_PARAM_VALUE.Name,'ALL','%'||BEN_DIM.BDM_THIRD_HOLDER_NAME||'%','%'||P_PARAM_VALUE.Name||'%')
                          then 1
                     else null end
                   else null end 
                 end )                    
         and BEN_DIM.BDM_IT_PAN like DECODE(P_PARAM_VALUE.PAN,'ALL','%'||BEN_DIM.BDM_IT_PAN||'%','%'||P_PARAM_VALUE.PAN||'%')
         and (1 = case when P_ADDRESS_TYPE.ADDTYPE = 1 then
                         case when instr(PERMANENT_ADD_DIM.ADDRESS, DECODE(P_PARAM_VALUE.ADDRESS,'ALL',PERMANENT_ADD_DIM.ADDRESS, P_PARAM_VALUE.ADDRESS)) <> 0
                              then 1
                         else null end
                       when P_ADDRESS_TYPE.ADDTYPE = 3 then
                         case when instr(NOM_GUARDIAN_ADD_DIM.ADDRESS, DECODE(P_PARAM_VALUE.ADDRESS,'ALL',NOM_GUARDIAN_ADD_DIM.ADDRESS, P_PARAM_VALUE.ADDRESS)) <> 0 
                           then 1
                         else null end 
                       when P_ADDRESS_TYPE.ADDTYPE = 4 then
                         case when instr(CORR_ADD_DIM.ADDRESS, DECODE(P_PARAM_VALUE.ADDRESS,'ALL',CORR_ADD_DIM.ADDRESS, P_PARAM_VALUE.ADDRESS)) <> 0 
                           then 1
                         else null end
                       when P_ADDRESS_TYPE.ADDTYPE = 6 then
                         case when instr(MINOR_ADDRESS.ADDRESS, DECODE(P_PARAM_VALUE.ADDRESS,'ALL',MINOR_ADDRESS.ADDRESS, P_PARAM_VALUE.ADDRESS)) <> 0 
                           then 1
                         else null end 
                  else null end );The above query also tries to access some tables from another user DISADMIN. Could you please help me in solving this problem while using SQL Tuning Advisor ? I am the only DBA here.

    will the rows really be updated just by using the package?Considering DMLs
    SQL> select * from test
      2  /
            NO
             1
             2
    SQL> ed
    Wrote file afiedt.buf
      1  DECLARE
      2   my_task_name VARCHAR2(30);
      3  my_sqltext   CLOB;
      4  BEGIN
      5  my_sqltext := 'insert into test values (3)';
      6  my_task_name := DBMS_SQLTUNE.CREATE_TUNING_TASK(
      7   sql_text    => my_sqltext,
      8  task_name   => 'my_sql_tuning_task');
      9* end;
    SQL> /
    PL/SQL procedure successfully completed.
    SQL> BEGIN
      2  DBMS_SQLTUNE.EXECUTE_TUNING_TASK( task_name => 'my_sql_tuning_task' );
      3  END;
      4  /
    PL/SQL procedure successfully completed.
    SQL> select * from test
      2  /
            NO
             1
             2
    SQL> SELECT DBMS_SQLTUNE.REPORT_TUNING_TASK( 'my_sql_tuning_task')
      2    FROM DUAL;
    DBMS_SQLTUNE.REPORT_TUNING_TASK('MY_SQL_TUNING_TASK')
    GENERAL INFORMATION SECTION
    Tuning Task Name   : my_sql_tuning_task
    Tuning Task Owner  : TEST
    Scope              : COMPREHENSIVE
    Time Limit(seconds): 1800
    Completion Status  : COMPLETED
    Started at         : 03/27/2008 05:16:14
    Completed at       : 03/27/2008 05:16:16
    DBMS_SQLTUNE.REPORT_TUNING_TASK('MY_SQL_TUNING_TASK')
    Schema Name: TEST
    SQL ID     : gwkmgmyj9824t
    SQL Text   : insert into test values (3)
    There are no recommendations to improve the statement.
    -------------------------------------------------------------------------------Adith

  • SQL tuning Advisor for old statements

    Hi all,
    i've identified SQL ID (through snapshots AWR) that make me performance problem. This is a old select statement (Mar 10, 2008) and when i try to run sql tuning advisor, it shows me this error:
    "There was a problem creating a SQL tuning task. ORA-13780: SQL statement does not exist. ORA-06512"
    I've set AWR for retain 60 days of Snapshot Retention, why i can't run tuning advisor for this statement??
    thanks very much for answers.
    Andrea

    Hi
    The problem is that the information of AWR is based on Historical information that Oracle retrieve of historical tables . AWR means Automatic Workload Repository.
    But when you execute the SQL tuning advisor task, Oracle needs retrieve the information of sql statement from SHARED POOL.
    The Library Cache is a part of Shared pool and contains an area named SQLAREA that stored information of execution plan for sql statements. This memory area is managed by LRU alghoritm.(last recently used) and the error is produced because this sql statement not is stored in this memory area.
    When the sql stament not reside in memory Oracle can't build the execution plan and then the error appear
    Regards

  • Sql tuning advisor 11g

    Dear all,
    We have installed oracle 11g on solaris. We have configured EM with this DB.. Is there anyway I can check a query using sql tuning advisor in oracle 11g. ? .. I tried, but I couldn't find the exact navigation ?. I need to submit th query and get the advise from sql tuninig advisor ?
    Please guide
    Kai

    OEM db console ?
    Am doing this for educational purpose and not in production
    kai

  • Change automatic SQL Tuning Advisor time

    Hi All,
    can anyone help me in changing "automatic SQL Tuning Advisor" job timingsm because currently it is scheduled during peak hours , i want to change it to evening 6 pm daily.Because during peak hours it is taking more cpu and taking one hour.
    Wed May 08 08:00:10 2013
    Begin automatic SQL Tuning Advisor run for special tuning task "SYS_AUTO_SQL_TUNING_TASK"
    Wed May 08 08:05:47 2013
    thanks
    Mapps

    Hello,
    Here's what you can do,
    Create a new window to the time you want it to run:
    EXEC dbms_scheduler.create_window(window_name => 'YOUR_WINDOW_NAME',
    duration => numtodsinterval(1, 'hour'),
    resource_plan => 'DEFAULT_MAINTENANCE_PLAN',
    repeat_interval => 'FREQ=DAILY;BYHOUR=18;BYMINUTE=0;BYSECOND=0');>
    The above window would be in effect from 6 pm to 7 pm.
    Then, disable automatic sql_tuning and then re-enable it to run on the window you just created:
    EXEC DBMS_AUTO_TASK_ADMIN.DISABLE(client_name => 'sql tuning advisor',
    operation => NULL,
    window_name => NULL);>
    and now set it to run to your window:
    EXEC DBMS_AUTO_TASK_ADMIN.ENABLE(client_name => 'sql tuning advisor',
    operation => NULL,
    window_name => 'YOUR_WINDOW_NAME');

  • Differernce between SQL Tuning Pack and SQL Tuning Advisor, Access Advisor

    Hi. all.
    I have been using "TKPROF" in order to tune SQL till now.
    I am learning 10g, and would like to know the difference
    between "1. SQL Tuning Pack" and "2. SQL Tuning Advisor, Access Advisor".
    Are they same thing? If not, what are the differences in their "functionality"?
    All I know is that SQL Tuning Pack is not free, and SQL Tuning Advisor
    is packed with default installation. Right???
    Could you give me some html links or your "any advice and experience"?
    Thanks in advance. Have a good day.
    Best Regards.

    Hi,
    There are alternatives to the Oracle tuning packs, and remember the SQL advisors are relatuively simple, finding missing indexes and recommending MV's.
    A human can do a better job if you use the right techniques.
    BTW, you can get a SQLTuning advisor license online for only $3k:
    http://www.dba-oracle.com/oracle_news/2005_3_17_dql_tuning_access_advisor_licenses_available_online.htm
    SHAMELESS PITCH! - I wrote a book that describes techniques for tuning with scripts, instead of the advisors, if you are interested:
    http://www.rampant-books.com/book_2005_1_awr_proactive_tuning.htm
    Hope this helps. . . .
    Donald K. Burleson
    Oracle Press author

  • Feature option request - SQL Tuning Advisor

    Hi,
    Love the ability we can run SQL Tuning Advisor so easily in SQL Developer, this is how it should be simple. However we can not specify a few parameter like: time_limit, task_name and description. Would be helpful to have these options, especially increasing the time_limit option!

    At least the limit will be increased: 3.0 Tuning Advisor Times Out
    Regards,
    K.

  • [OCP exam] doubt about Automatic SQL Tuning Advisor

    Hi,
    Sorry for my poor english.
    I am currently preparing for the OCP  11g exam.
    For that, I have bought some training tools  to help me prepare the exam.
    But, in the chapter related to the SQL tuning advisor, some explanation really confuse me .
    Extract :
    <<
    the SQL automatic tuning  job runs every night during the maintenance window.
    By default, the job makes SQL profile recommendations, tests them, and automatically implements them if they provide better performance improvement)
    >>
    I was persuaded it was the opposite.
    I check several databases/documentation, and it's seems to be always the opposite.
    By default,new sql profile are tested but not implemented automatically (you have to set a parameter ACCEPT_SQL_PROFILES TO TRUE to activate this option)
    But the exam is validated on oracle 11.2.0.1, and I only have 11.2.0.2/11.2.0.3 db available.
    So may be oracle changed the value of the default parameter in the new releases.
    Can someone confirm if I am right or not ?

    I would rather accept what is in the documentation:
    "If a SQL profile is recommended, the database tests the new profile by executing the SQL statement both with and without the profile. If the performance improvement improves at least threefold, then the database accepts the SQL profile, but only if the ACCEPT_SQL_PROFILES task parameter is set to TRUE. Otherwise, the automatic SQL tuning reports merely report the recommendation to create a SQL profile." Automatic SQL Tuning
    "If automatic implementation of SQL profiles is enabled (the default is disabled), then the database implements any SQL profiles that promise a great performance benefit. The implementation occurs at tuning time so that the database can immediately benefit from the new plan. You can enable or disable automatic implementation by using the SET_AUTO_TUNING_TASK_PARAMETER API to set the ACCEPT_SQL_PROFILES parameter." DBMS_AUTO_SQLTUNE

  • Reg: SQL Tuning Advisor -

    Hi Experts,
    A quick question regarding this utility: SQL Tuning Advisor.
    Does this need any special license to use?
    Or, any special Grants/Privileges required for it?
    Please provide pointers for this.
    -- Ranit

    Or, any special Grants/Privileges required for it?
    Grant-wise , a user needs the privilege ADVISOR

  • What is this SQL Tuning Advisor's Advice means

    HI ,
    I am Tuning a query wit hthe help of ORACLE 10 g 's SQL Tuning Advisor.I got the following recommendation .
    **Consider removing the disconnected table or view from this statement or add a join condition which refers to it.**
    I didn't understand what does this mean.
    Can anyone please help me
    Thanks,
    Pramod.
    Edited by: Pramod Garre on Jul 15, 2009 6:20 AM

    Simply saying if i apply that profile i will get Good plan.But I want to change the SQL itself rather than applying profile.in that case what can be done.Automatic SQL Tuning deals with this problem with its SQL Profiling capability. The Automatic Tuning Optimizer creates a profile of the SQL statement called a SQL Profile, consisting of auxiliary statistics specific to that statement. The query optimizer under normal mode makes estimates about cardinality, selectivity, and cost that can sometimes be off by a significant amount resulting in poor execution plans. SQL Profile addresses this problem by collecting additional information using sampling and partial execution techniques to verify and, if necessary, adjust these estimates.During SQL Profiling, the Automatic Tuning Optimizer also uses execution history information of the SQL statement to appropriately set optimizer parameter settings, such as changing the OPTIMIZER_MODE initialization parameter setting from ALL_ROWS to FIRST_ROWS for that SQL statement.
    If you want to change the SQL, You can re-write the SQL and evaluate the Performance recommendations SQL tuning Advisor.

  • SQL Tuning Advisor (STA) recommends indexes that already exists?

    I have enabled the STA to run twice a week, while we are going live with a new application in a new database. I want to insure we have good performance as the load goes up. I was not involved in the original design, which there not not much of, I've discovered. Since we are licensed for it, it seemed like a safe thing to turn on.
    The STA ran last night and the report tells me it looked at 736 SQLs with findings, 143 without findings, and skipped 0.
    What puzzles me is that, in the "Statistics Finding Summary", it's reporting stale stats on some tables which I know are up to date, as I ran stats on them yesterday and there were no updates to them.
    Worse, in the "Index Finding Summary", it reports indexes needed that already do, in fact, exist.
    Is there some reason for this? Is there some way to get the STA to be aware of these and avoid the erroneous findings so that I can concentrate on real ones?
    Thanks in advance for any suggestions.
    PDP

    Hi Mark,
    Thanks for your interest, yes, the index is being used . Here is the evidence that you were asking about.
    It has existed for many weeks, now as the info below will show.
    Here is the STA run info, the run was from 2011-07-28 at 11 PM:
    ========================================
    Advisory Type Name Description User Status Start Time Duration (seconds) Expires In (days)
    SQL Tuning Advisor SYS_AUTO_SQL_TUNING_TASK Automatic SQL Tuning Task SYS COMPLETED Jul 28, 2011 11:00:03 PM 865 UNLIMITED
    Here is part of the Index Finding Summary
    =========================================
    Index Finding Summary
    Table Name Schema References Index Columns
    EINSTANCE_ARCH EINTAKE 74 GLOBAL_PATIENT_ID
    Drilling into that table, we see the following SQL_ID listed first, "g9uf2kmyvc66y" which is just one of many.
    Here is 1 if the sqls, which use the "global_patient_id" as a predicate
    (with the many columns that are actually selected not listed as they are not germain:
    =====================================================================================
    SELECT *
    FROM (SELECT '0' AS locked,
    (... a whole lot of columns selected)
    FROM einstance_arch a
    LEFT OUTER JOIN
    patient d
    ON a.global_patient_id = d.patient_id
    LEFT OUTER JOIN
    referral e
    ON a.instance_id = e.einstance_id,
    einstance_states_arch b
    WHERE a.current_state = b.inst_state_id
    AND a.current_state_id != 15
    AND ( a.global_patient_id = 496 )
    ORDER BY a.instance_id ASC)
    WHERE ROWNUM <= :1
    Here's an explain plan extracted from Toad, the index in question is identified by ==>:
    ======================================================
    Plan
    SELECT STATEMENT ALL_ROWS Cost: 19 Bytes: 4,528 Cardinality: 4
    1 INDEX UNIQUE SCAN INDEX (UNIQUE) EINTAKE.STATES_PK Cost: 0 Bytes: 14 Cardinality: 1
    3 SORT AGGREGATE Bytes: 6 Cardinality: 1
    2 INDEX RANGE SCAN INDEX EINTAKE.DOCUMENT_ATTR_LNK_INST_ID_IDX2 Cost: 1 Bytes: 6 Cardinality: 1
    18 COUNT STOPKEY
    17 VIEW EINTAKE. Cost: 19 Bytes: 4,528 Cardinality: 4
    16 SORT ORDER BY STOPKEY Cost: 19 Bytes: 1,544 Cardinality: 4
    15 NESTED LOOPS
    13 NESTED LOOPS Cost: 18 Bytes: 1,544 Cardinality: 4
    11 NESTED LOOPS OUTER Cost: 10 Bytes: 1,296 Cardinality: 4
    8 HASH JOIN OUTER Cost: 9 Bytes: 1,228 Cardinality: 4
    5 TABLE ACCESS BY INDEX ROWID TABLE EINTAKE.EINSTANCE_ARCH Cost: 6 Bytes: 1,152 Cardinality: 4
    ==> 4 INDEX RANGE SCAN INDEX EINTAKE.EINSTANCE_ARCH_GLBL_PT_ID_IDX3 Cost: 1 Cardinality: 5
    7 TABLE ACCESS BY INDEX ROWID TABLE EINTAKE.PATIENT Cost: 2 Bytes: 19 Cardinality: 1
    6 INDEX UNIQUE SCAN INDEX (UNIQUE) EINTAKE.PATIENT_PK Cost: 1 Cardinality: 1
    10 TABLE ACCESS BY INDEX ROWID TABLE EINTAKE.REFERRAL Cost: 1 Bytes: 17 Cardinality: 1
    9 INDEX RANGE SCAN INDEX EINTAKE.REFERRAL_EINSTANCE_ID Cost: 0 Cardinality: 1
    12 INDEX UNIQUE SCAN INDEX (UNIQUE) EINTAKE.EINSTANCE_STATES_ARCH_PK Cost: 1 Cardinality: 1
    14 TABLE ACCESS BY INDEX ROWID TABLE EINTAKE.EINSTANCE_STATES_ARCH Cost: 2 Bytes: 62 Cardinality: 1
    Here is the DDL info on the index in question:
    ============================
    select object_name, created, last_ddl_time from user_objects where object_name = 'EINSTANCE_ARCH_GLBL_PT_ID_IDX3';
    OBJECT_NAME CREATED LAST_DDL_TIME
    EINSTANCE_ARCH_GLBL_PT_ID_IDX3 2011 07 11 11:22:36 2011 07 11 11:22:36
    1 row selected.
    Regards,
    Paul

  • Sql tuning advisor question on bind values

    Hi guys,
    I used the sql tuning wizard in Oracle 11g to get recommendation on how to improve performance on a long running query. Here is the recommendation I received:
    At least one important bind value was missing for this sql statement. The
    accuracy of the advisor's analysis may depend on all important bind values
    being supplied.
    Could someone please help me understand what it means? For example, what is a bind value, why was it missing, and why are they important?
    Thanks!

    I've seen this message maybe once before but I've never investigated it - I don't tend to run the SQL tuning advisor.
    The best thing you could do is investigate the circumstances yourself, maybe trace the tuning advisor and see where it's getting its data from internally.
    As mentioned, where it gets its data from depends on how you populate the tuning advisor - from cursor cache, awr, etc.
    If it's from AWR as you mentioned, have a look at DBA_HIST_SQLSTAT.BIND_DATA for example? Or maybe DBA_HIST_SQLBIND? Etc.
    You can check what the advisor probably pulls out of AWR using something like this:
    select *
    from   table(dbms_Sqltune.select_workload_repository
                 (begin_snap   => 6441,
                  end_snap     => 6443,
                  basic_filter => 'sql_id = ''gr5tqfnz07sxk'''));If the bind_list is empty then you know what it's complaining about.
    I just tried it with an example sql it that I can see has bind data in DBA_HIST_SQLSTAT and DBA_HIST_SQLBIND and the BIND_LIST in the SQLSET returned by the SQL set above is null so that raises some questions ( I might be doing something wrong but as mentioned, it's not really something I tend to use).
    The BIND_DATA raw is populated for me (although the bind_list collection isn't hence why original comment above).
    If you know a representative set of binds, you can kick off your own tuning task manually and supply your own set of binds - see DBMS_SQLTUNE.CREATE_TUNING_TASK.
    You can also extract and inspect the RAW BIND_DATA into a set of binds using DBMS_SQLTUNE.EXTRACT_BINDS.
    e.g. to inspect:
    select x.*
    from   v$sql s
    ,      table(dbms_sqltune.extract_binds(s.bind_data)) x
    where  sql_id = '<sql_id>';Edited by: Dom Brooks on May 17, 2012 5:59 PM

  • SQL Tuning Advisor evaluates statement using wrong plan_hash_value

    The execution plan for one of my SQL statements changed this morning. The statement is in a third-party package. The new plan runs worse than the old plan. I had the SQL tuning advisor evaluate the statement. I ran it three times. Each time it evaluated the original plan, not the new one. I can tell that because the plan_hash_value shown in the advisor's recommendations is the old plan's plan_hash_value. The old plan no longer appears in DBA_HIST_SQL_PLAN. I do not understand why the advisor is using the original plan, nor where it is getting it. It does not show up in Oracle Enterprise Manager either.
    Has anyone see this before?
    Do you have any suggestions how I can force the advisor to evaluate the new execution plan?
    I am running Oracle Database Server 10gR2 Enterprise Edition.
    Thanks,
    Bill

    Following advice given earlier, I ran the SQL Tuning Advisor by executing DBMS_SQLTUNE from within a SQL*Plus session instead of via Oracle Enterprise Manager. The problem I originally encountered in OEM also happened using DBMS_SQLTUNE. Using DBMS_SQLTUNE I specified plan_hash_value => '3657286666' but the results of running create_tuning_task shows that the utility used a different plan_hash_value. See below:
    Based on this, I think the problem I originally blamed on OEM's creation of a SQL Tuning Advisor job was misdirected. I now believe that OEM supplied the proper information to the advisor, but the advisor did not correctly use what is was given.
    Below is what I submitted when I ran create_tuning_task and execute_tuning_task. Note that the value assigned to plan_hash_value is 3657286666. Following the messages from execute_tuning_task, see the output produced by the execution of report_tuning_task. In EXPLAIN PLANS SECTION heading 1 - ORIGINAL, note that Plan Hash Value = 3541843898.
    I submitted instructions to use plan_hash_value 3657286666 but instead it used 3541843898. Why did it do this??????
    I have not found a published bug that describes this condition.
    Thanks,
    Bill
    SQL> DECLARE
    2 stmt_task VARCHAR2(64);
    3 BEGIN
    4 stmt_task:=dbms_sqltune.create_tuning_task(sql_id => 'ab30ujpshkur3', plan_hash_
    value => '3657286666', time_limit => 3600, task_name => 'Tune_ab30ujpshkur3_3657286666'
    , description => 'Task to tune sql_id ab30ujpshkur3 plan_hash_value 3657286666');
    5 END;
    6 /
    PL/SQL procedure successfully completed.
    SQL> EXECUTE dbms_sqltune.execute_tuning_task('Tune_ab30ujpshkur3_3657286666');
    PL/SQL procedure successfully completed.
    Here is the output produced by report_tuning_task:
    SQL> SET linesize 200
    SQL> SET LONG 999999999
    SQL> SET pages 1000
    SQL> SET longchunksize 20000
    SQL> SELECT dbms_sqltune.report_tuning_task('Tune_ab30ujpshkur3_3657286666', 'TEXT', 'ALL') FROM dual;
    SELECT dbms_sqltune.script_tuning_task('Tune_ab30ujpshkur3_3657286666', 'ALL')
    FROM dual;
    DBMS_SQLTUNE.REPORT_TUNING_TASK('TUNE_AB30UJPSHKUR3_3657286666','TEXT','ALL')
    GENERAL INFORMATION SECTION
    Tuning Task Name : Tune_ab30ujpshkur3_3657286666
    Tuning Task Owner : EXPTEST
    Tuning Task ID : 110190
    Scope : COMPREHENSIVE
    Time Limit(seconds) : 3600
    Completion Status : COMPLETED
    Started at : 08/03/2012 14:47:45
    Completed at : 08/03/2012 14:48:54
    Number of Index Findings : 1
    Schema Name: EXPTEST
    SQL ID : ab30ujpshkur3
    SQL Text : SELECT ATTACHED_ACC_ID FROM SERVICE_EVENTS WHERE TSERV_ID = :B4
    AND EQ_NBR = :B3 AND ASSOC_EQ_NBR = :B2 AND (PERFORMED <= :B1 +
    1/1440 AND PERFORMED >= :B1 - 1/1440)
    FINDINGS SECTION (1 finding)
    1- Index Finding (see explain plans section below)
    The execution plan of this statement can be improved by creating one or more
    indices.
    Recommendation (estimated benefit: 100%)
    - Consider running the Access Advisor to improve the physical schema design
    or creating the recommended index.
    create index EXPTEST.IDX$$_1AE6E0001 on
    EXPTEST.SERVICE_EVENTS('EQ_NBR','ASSOC_EQ_NBR');
    Rationale
    Creating the recommended indices significantly improves the execution plan
    of this statement. However, it might be preferable to run "Access Advisor"
    using a representative SQL workload as opposed to a single statement. This
    will allow to get comprehensive index recommendations which takes into
    account index maintenance overhead and additional space consumption.
    EXPLAIN PLANS SECTION
    1- Original
    Plan hash value: 3541843898
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)|
    Time |
    | 0 | SELECT STATEMENT | | 1 | 32 | 4 (0)|
    00:00:01 |
    |* 1 | FILTER | | | | |
    |
    |* 2 | TABLE ACCESS BY INDEX ROWID| SERVICE_EVENTS | 1 | 32 | 4 (0)|
    00:00:01 |
    |* 3 | INDEX RANGE SCAN | SEVENTS_PERFORMED | 18 | | 2 (0)|
    00:00:01 |
    Query Block Name / Object Alias (identified by operation id):
    1 - SEL$1
    2 - SEL$1 / SERVICE_EVENTS@SEL$1
    3 - SEL$1 / SERVICE_EVENTS@SEL$1
    Predicate Information (identified by operation id):
    1 - filter(:B1+.000694444444444444444444444444444444444444>=:B1-.0006944444444444444
    444
    44444444444444444444)
    2 - filter("EQ_NBR"=:B3 AND "ASSOC_EQ_NBR"=:B2 AND "TSERV_ID"=:B4)
    3 - access("PERFORMED">=:B1-.000694444444444444444444444444444444444444 AND
    "PERFORMED"<=:B1+.000694444444444444444444444444444444444444)
    Column Projection Information (identified by operation id):
    1 - "ATTACHED_ACC_ID"[VARCHAR2,12]
    2 - "ATTACHED_ACC_ID"[VARCHAR2,12]
    3 - "SERVICE_EVENTS".ROWID[ROWID,10]
    2- Using New Indices
    Plan hash value: 2568062050
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| T
    ime |
    | 0 | SELECT STATEMENT | | 1 | 32 | 2 (0)| 0
    0:00:01 |
    |* 1 | FILTER | | | | |
    |
    |* 2 | TABLE ACCESS BY INDEX ROWID| SERVICE_EVENTS | 1 | 32 | 2 (0)| 0
    0:00:01 |
    |* 3 | INDEX RANGE SCAN | IDX$$_1AE6E0001 | 1 | | 2 (0)| 0
    0:00:01 |
    Query Block Name / Object Alias (identified by operation id):
    1 - SEL$1
    2 - SEL$1 / SERVICE_EVENTS@SEL$1
    3 - SEL$1 / SERVICE_EVENTS@SEL$1
    Predicate Information (identified by operation id):
    1 - filter(:B1+.000694444444444444444444444444444444444444>=:B1-.0006944444444444444
    4
    4444444444444444444444)
    2 - filter("TSERV_ID"=:B4 AND "PERFORMED">=:B1-.000694444444444444444444444444444444
    4
    44444 AND "PERFORMED"<=:B1+.000694444444444444444444444444444444444444)
    3 - access("EQ_NBR"=:B3 AND "ASSOC_EQ_NBR"=:B2)
    Column Projection Information (identified by operation id):
    1 - "ATTACHED_ACC_ID"[VARCHAR2,12]
    2 - "ATTACHED_ACC_ID"[VARCHAR2,12]
    3 - "SERVICE_EVENTS".ROWID[ROWID,10]
    SQL> 2
    DBMS_SQLTUNE.SCRIPT_TUNING_TASK('TUNE_AB30UJPSHKUR3_3657286666','ALL')
    -- Script generated by DBMS_SQLTUNE package, advisor framework --
    -- Use this script to implement some of the recommendations --
    -- made by the SQL tuning advisor. --
    -- NOTE: this script may need to be edited for your system --
    -- (index names, privileges, etc) before it is executed. --
    create index EXPTEST.IDX$$_1AE6E0001 on EXPTEST.SERVICE_EVENTS('EQ_NBR','ASSOC_EQ_NBR')
    ;

Maybe you are looking for