ADDM recommendation regarding SQL Tuning

Hi all.
Several times, I've seen this recommendation when I run ADDM:
Recommendation 1: SQL Tuning
Estimated benefit is 1.78 active sessions, 4.93% of total activity.
Action
Tune the PL/SQL block with SQL_ID "9f9y14fzgg9a9". Refer to the "Tuning
PL/SQL Applications" chapter of Oracle's "PL/SQL User's Guide and
Reference".
Related Object
SQL statement with SQL_ID 9f9y14fzgg9a9.
declare
rc__ number;
simple_list__ owa_util.vc_arr;
complex_list__ owa_util.vc_arr;
begin
owa.init_cgi_env(:n__,:nm__,:v__);
htp.HTBUF_LEN := 255;
null;
null;
simple_list__(1) := 'sys.%';
simple_list__(2) := 'dbms\_%';
simple_list__(3) := 'utl\_%';
simple_list__(4) := 'owa\_%';
simple_list__(5) := 'owa.%';
simple_list__(6) := 'htp.%';
simple_list__(7) := 'htf.%';
simple_list__(8) := 'wpg_docload.%';
if ((owa_match.match_pattern('adhoc_run.submit_rep', simple_list__,
complex_list__, true))) then
rc__ := 2;
else
null;
null;
adhoc_run.submit_rep(NAME_ARRAY=>:NAME_ARRAY,VALUE_ARRAY=>:VALUE_ARRA
Y);
if (wpg_docload.is_file_download) then
rc__ := 1;
wpg_docload.get_download_file(:doc_info);
null;
null;
null;
commit;
else
rc__ := 0;
null;
null;
null;
commit;
owa.get_page(:data__,:ndata__);
end if;
end if;
:rc__ := rc__;
end;
Rationale
SQL statement with SQL_ID "9f9y14fzgg9a9" was executed 206 times and had
an average elapsed time of 46 seconds.
My understanding is that this is an embedded APEX routine I can't control.
Question for the gurus out there:
- Have you seen this before?
- Is there any way to tune this (any parameter, etc.)? Any recommendation?
Thanks a lot,
Ignacio.

Hi,
How about SQL Profiles? Have thought in this direction?
Some info is here http://www.oracle-base.com/articles/10g/AutomaticSQLTuning10g.php
Regards,

Similar Messages

  • Question Regarding SQL logic error!

    Hello everyone,
    I get the following error when executing an Informatica mapping with teh following SQL in the Source Qualifier.
    error - OR- 00936: missing expression.
    Can anyone help please!
    SELECT
    PS_CUSTOMER.SETID
    , PS_CUSTOMER.CUST_ID
    , PS_CUSTOMER.CUST_STATUS
    , PS_CUSTOMER.ADD_DT
    , PS_CUSTOMER.NAME1
    , PS_CUSTOMER.TAXPAYER_ID
    , PS_CUSTOMER.WEB_URL
    , PS_CUSTOMER.LAST_MAINT_OPRID
    , PS_CUSTOMER.DATE_LAST_MAINT
    , PS_CUST_SIC_CODES.SIC_CD_QUAL
    , PS_CUST_SIC_CODES.SIC_CODE
    , PS_CUST_CGRP_LNK.CUST_GRP_TYPE
    , PS_CUST_CGRP_LNK.CUSTOMER_GROUP
    , PS_CUST_CGRP_LNK.LASTUPDDTTM
    , PS_CUST_ID_NBRS.STD_ID_NUM
    , PS_CUSTOMER.SUBCUST_QUAL1
    FROM PS_CUSTOMER
    select SIC1.SETID, SIC1.CUST_ID, MAX(SIC1.SIC_CODE) SIC_CODE, SIC1.SIC_CD_QUAL
    from PS_CUST_SIC_CODES SIC1
    where SIC1.SIC_CD_QUAL =
    ( select MAX(SIC_CD_QUAL)
    from PS_CUST_SIC_CODES SIC2
    where SIC2.CUST_ID = SIC1.CUST_ID
    and SIC2.SETID = SIC1.SETID
    group by SETID, CUST_ID, SIC1.SIC_CD_QUAL
    ) PS_CUST_SIC_CODES
    select A.CUST_ID, A.SETID, A.CUST_GRP_TYPE
    , MAX(A.CUSTOMER_GROUP) CUSTOMER_GROUP, A.LASTUPDDTTM
    from PS_CUST_CGRP_LNK A
    where A.CUST_GRP_TYPE =
    SELECT MAX(CUST_GRP_TYPE)
    FROM PS_CUST_CGRP_LNK B
    WHERE A.CUST_ID = B.CUST_ID
    AND A.SETID = B.SETID
    AND A.LASTUPDDTTM = B.LASTUPDDTTM
    AND B.LASTUPDDTTM =
    SELECT MAX(LASTUPDDTTM)
    FROM PS_CUST_CGRP_LNK C
    WHERE C.CUST_ID = B.CUST_ID
    AND C.SETID = B.SETID
    GROUP BY CUST_ID, SETID, CUST_GRP_TYPE, LASTUPDDTTM
    ) PS_CUST_CGRP_LNK
    select SETID, CUST_ID, STD_ID_NUM
    from PS_CUST_ID_NBRS
    where STD_ID_NUM_QUAL = 'DNS'
    ) PS_CUST_ID_NBRS
    WHERE
    { PS_CUSTOMER
    LEFT OUTER JOIN
    PS_CUST_SIC_CODES ON
    PS_CUSTOMER.SETID = PS_CUST_SIC_CODES.SETID
    AND PS_CUSTOMER.CUST_ID = PS_CUST_SIC_CODES.CUST_ID
    LEFT OUTER JOIN
    PS_CUST_CGRP_LNK ON
    PS_CUSTOMER.SETID = PS_CUST_CGRP_LNK.SETID
    AND PS_CUSTOMER.CUST_ID = PS_CUST_CGRP_LNK.CUST_ID
    LEFT OUTER JOIN
    PS_CUST_ID_NBRS ON
    PS_CUSTOMER.SETID = PS_CUST_ID_NBRS.SETID
    AND PS_CUSTOMER.CUST_ID = PS_CUST_ID_NBRS.CUST_ID
    ORDER BY PS_CUSTOMER.CUST_ID , PS_CUSTOMER.SETID
    Thanks,
    Ajay.

    Kramer wrote:
    Hi
    So.. do we have to pay for the feature regarding sql tuning advisor?
    Can we use the dbms_sqltune package for free in oracle?
    No, you need the license. Please read below,
    http://download.oracle.com/docs/cd/E11882_01/license.112/e10594/options.htm#CIHFIHFG
    I `m doing below test on my Linux. I installed an oracle on it and only for study purpose so didn`t pay.
    As you can see. I got no output.
    SQL> exec dbms_sqltune.execute_tuning_task('TASK_1634');
    PL/SQL procedure successfully completed.
    SQL> select dbms_sqltune.report_tuning_task('TASK_1634') from dual;
    DBMS_SQLTUNE.REPORT_TUNING_TASK('TASK_1634')
    GENERAL INFORMATION SECTION
    Please read the below link to learn how to use the STA.
    http://download.oracle.com/docs/cd/E11882_01/server.112/e16638/sql_tune.htm
    HTH
    Aman....

  • SQL Tuning Advisor reports in EM10g Grid

    Is there a quick way to get the Recommendations from SQL Tuning Advisor into a formatted HTML report, similar to the ones in EM 9.2?
    This is a useful tool for reporting problems to Developers, but only if you can get a report off.
    Thanks
    Steve

    You can copy the result and paste into Word Document, then save as HTML.
    Also you can (be very carefull with this depending on which users) create Oracle/EM Users, that only have with limited access privileges to View Monitor reports. Then copy and send the URL of the completed Report Recommendations to them via email. When they click on it, it will prompt them for EM username and password, then Oracle User Name and Password.

  • SQL tuning advisor in 11G.

    Hi,
    our dev guys given poor performance query to me to tune.
    Can any one able to provide me steps to get recommendation from SQL tuning advisor by creating tuning task for a manually specified statement.
    Version : 11.1.0.6.0
    OS : SunOS 5.10
    Thanks in advance!
    Govin

    Hi,
    Thanks for your reply,
    Creation of SQL Tuning Task failed due to below one,
    "to_char(max(r.ts), 'mm/dd/yyyy') viewrequest_lastdate"
    saying like
    ERROR at line 8:
    ORA-06550: line 8, column 22:
    PLS-00103: Encountered the symbol "MM" when expecting one of the following:
    * & = - + ; < / > at in is mod remainder not rem
    <an exponent (**)> <> or != or ~= >= <= <> and or like like2
    like4 likec between || member submultiset
    The symbol "*" was substituted for "MM" to continue.
    Then i have replaced with
    "to_char(max(r.ts), :bnd) viewrequest_lastdate". After this task is created & executed. Right now, im getting below error.. plz advice.
    GENERAL INFORMATION SECTION
    Tuning Task Name : my_sql_tuning_task
    Tuning Task Owner : SYS
    Workload Type : Single SQL Statement
    Scope : COMPREHENSIVE
    Time Limit(seconds) : 60
    Completion Status : COMPLETED
    Started at : 10/26/2010 13:36:09
    Completed at : 10/26/2010 13:36:13
    Schema Name: METRICS
    SQL ID : 71kzxnt9vb91q
    SQL Text : select p.prfl_id profile_id, p.prfl_src profile_source,
    p.prfl_nme profile_name,getDistinctUserIDTypes
    (wm_concat(distinct u.usr_ty_cd)) user_id_type,count(distinct
    u.usr_id || u.usr_id_src) userid_count, count(e.nttl_id)
    entitlement_count,to_char(max(r.ts), :bnd) viewrequest_lastdate
    from TABLE1 d, TABLE2 a,TABLE 3 u, TABLE4
    e, TABLE 5 r,TABLE6 p, TABLE7 z where
    d.dept_id = a.dept_id and d.dept_id = z.dept_id (+) and
    a.glbl_id = u.glbl_id and u.usr_id = e.usr_id and u.usr_id_src =
    e.usr_id_src and e.prfl_id = p.prfl_id and e.prfl_src =
    p.prfl_src and e.lst_rvw_rqst_id = r.rqst_id(+) and (d.mgr_glbid
    = :bnd OR z.TO_GLBL_ID = :bnd) and p.prfl_id is not null group
    by p.prfl_id, p.prfl_src, p.prfl_nme order by p.prfl_id
    ERRORS SECTION
    - ORA-01008: not all variables bound
    Thanks
    Govin

  • SQL Tuning Advisor  Recommends New Explain Plan

    Hi:
    I have to believe this has been asked before but didn't see it in a forum search so I'll ask here. I had SQL Tuning Advisor look at a query and it is recommending a new plan for a 50+% improvement (hazah!). The trouble is, I don't want Oracle to re-write the plan to execute the query better, I want to know how I can re-write the query to generate that more optimal plan in the first place because I have similar systems in the field that I would like to also be optimized. What are my options?
    Thanks.

    Sorry Gaff I know where you are talking about but I don't have your answer, but it may be a good start going over the 19g reference guide for these dictionary views -
    SQL> select view_name from dba_views where view_name like 'DBA%ADVISOR%' ;
    VIEW_NAME
    DBA_ADVISOR_DEFINITIONS
    DBA_ADVISOR_COMMANDS
    DBA_ADVISOR_OBJECT_TYPES
    DBA_ADVISOR_USAGE
    DBA_ADVISOR_TASKS
    DBA_ADVISOR_TEMPLATES
    DBA_ADVISOR_LOG
    ...Best regards.

  • 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 suggestions.

    Hi
    I am not a sql programmer and developers have given me this sql to have a look. I made the following recommendations after going through the sql. Is there anything else that can be added . I did not add about stats because they are representative and up to date.
    SELECT /*+ PARALLEL(q1,4) */ *
    FROM
    (SELECT /*+ FIRST_ROWS(20) */
    br.resource_id,
    br.resource_code,
    x.resource_seq_num employee_resource_number,
    br.organization_id,
    bd.department_id,
    bd.department_code,
    pf.full_name employee_name,
    (SELECT xxdl_eam_util_pkg.xxdl_eam_get_resource_code(pf.person_id, bd.department_id)
    FROM dual)
    maximum_cost_resource,
    pf.person_id,
    x.wip_entity_id wo_id,
    (SELECT weo1.wip_entity_name
    FROM wip_eam_work_orders_v weo1
    WHERE weo1.wip_entity_id = x.wip_entity_id)
    wo_number,
    CAST(x.start_date AS
    TIMESTAMP) start_date,
    CAST(x.completion_date AS
    TIMESTAMP) completion_date,
    wor.operation_seq_num wo_operation_number,
    wor.resource_seq_num wo_resource_number,
    wor.usage_rate_or_amount HOURS,
    BRE.effective_start_date instance_start_date,
    BRE.effective_end_date instance_end_date,
    BRE.instance_id,
    crc.resource_rate AS
    resource_cost,
    (SELECT xxdl_eam_util_pkg.xxdl_eam_get_all_res_code(pf.person_id, bd.department_id)
    FROM dual)
    all_resources
    FROM per_all_people_f pf,
    wip_eam_work_orders_v weo,
    wip_operations wo,
    wip_operation_resources wor,
    (SELECT instance_id,
    wip_entity_id,
    operation_seq_num,
    resource_seq_num,
    start_date,
    completion_date
    FROM wip_op_resource_instances_v) x,
    bom_dept_res_instances bdri,
    bom_resource_employees BRE,
    bom_department_resources bdr,
    bom_resources br,
    cst_resource_costs crc,
    bom_departments bd
    WHERE br.organization_id = bd.organization_id
    AND bdr.resource_id = br.resource_id
    AND bdr.department_id = bd.department_id
    AND BRE.resource_id = br.resource_id
    AND pf.effective_start_date <=sysdate
    AND pf.effective_end_date >= sysdate
    AND pf.person_id = BRE.person_id
    AND wo.department_id = bd.department_id
    AND wor.operation_seq_num(+) = wo.operation_seq_num
    AND wor.wip_entity_id(+) = wo.wip_entity_id
    AND wor.organization_id(+) = wo.organization_id
    AND weo.wip_entity_id = wo.wip_entity_id
    AND weo.organization_id = wo.organization_id
    -- AND weo.organization_id = 6921
    AND DECODE(bd.disable_date,null, sysdate,bd.disable_date) >= sysdate
    AND DECODE(br.disable_date,null, sysdate,br.disable_date) >= sysdate
    AND DECODE(wo.disable_date,null, sysdate,wo.disable_date) >= sysdate
    AND crc.resource_id(+) = BRE.resource_id
    AND x.wip_entity_id = wor.wip_entity_id
    AND x.operation_seq_num = wor.operation_seq_num
    AND x.resource_seq_num = wor.resource_seq_num
    AND x.instance_id(+) = BRE.instance_id
    AND bdri.department_id = bd.department_id
    AND bdri.resource_id = br.resource_id
    AND weo.organization_id = 6921
    AND bdri.department_id = 5004
    UNION
    SELECT /*+ FIRST_ROWS(20) */ DISTINCT NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    pf.full_name employee_name,
    NULL,
    pf.person_id,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL HOURS,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL
    FROM per_all_people_f pf,
    wip_eam_work_orders_v weo,
    wip_operations wo,
    wip_operation_resources wor,
    bom_dept_res_instances bdri,
    bom_resource_employees BRE,
    bom_department_resources bdr,
    bom_resources br,
    cst_resource_costs crc,
    bom_departments bd
    WHERE br.organization_id = bd.organization_id
    AND bdr.resource_id = br.resource_id
    AND bdr.department_id = bd.department_id
    AND BRE.resource_id = br.resource_id
    AND pf.effective_start_date <=sysdate
    AND pf.effective_end_date >= sysdate
    AND pf.person_id = BRE.person_id
    AND wo.department_id = bd.department_id
    AND wor.operation_seq_num(+) = wo.operation_seq_num
    AND wor.wip_entity_id(+) = wo.wip_entity_id
    AND wor.organization_id(+) = wo.organization_id
    AND weo.wip_entity_id = wo.wip_entity_id
    AND weo.organization_id = wo.organization_id
    AND DECODE(bd.disable_date,null, sysdate,bd.disable_date) >= sysdate
    AND DECODE(br.disable_date,null, sysdate,br.disable_date) >= sysdate
    AND DECODE(wo.disable_date,null, sysdate,wo.disable_date) >= sysdate
    AND crc.resource_id(+) = BRE.resource_id
    AND bdri.department_id = bd.department_id
    AND bdri.resource_id = br.resource_id
    AND weo.organization_id = 6921
    AND bdri.department_id = 5004
    AND NOT EXISTS
    (SELECT instance_id,
    wip_entity_id operation_seq_num,
    resource_seq_num
    FROM wip_op_resource_instances_v)
    ) q1
    ORDER BY department_id,
    resource_code,
    employee_name,
    wo_number
    My suggestions:
    . Try to use UNION ALL instead of UNION. If you can eliminate UNION all together and flatten the query that will be even better.
    2. You are using the function in a select statement xxdl_eam_util_pkg.xxdl_eam_get_resource_code(pf.person_id, bd.department_id)This will slow the performance. Try to get rid of this. Function calls in select are expensive.
    3. Dont use the parallel hint and optimize. It wont get you consistent results.
    4. Use of per_all_people_F is expensive. The UNION again complicates things. per_all_people_f has to be scanned 2x times.
    5. Where does the application get the values for department id? Whether user inputs a value or whether it is hard coded . Most likely user will input value and each time it may be different. If that is the case, then you may be hitting bind peeking. There is not much hope for this. Not much can be done. Whatever you do this can happen. Only way is to pin the plan if you can use literals instead of binds. But that is not possible I think.
    6. AND DECODE(bd.disable_date,null, sysdate,bd.disable_date) >= sysdate
    AND DECODE(br.disable_date,null, sysdate,br.disable_date) >= sysdate
    AND DECODE(wo.disable_date,null, sysdate,wo.disable_date) >= sysdate
    Those statements, if you can rewrite would be good. If there are indexes on any of those columns, they are more than likely not used.
    7. Are the outer joins really required. If not required remove them.
    8. There is a 'WITH' clause in 10g . Try to use that for your subqueries or main query where applicable. It will save some I/O.
    9. Try to tune without any hints. Remove the first rows as well and see the difference.
    I know that the sql is definately bad and can be rewritten but I am not able to exactly write it for them.
    Any inputs or thoughts?
    MSK

    Hi,
    Any suggestions for reading on Sql tuning
    I am looking for a practical book with solutions .
    And books showing the Sql internal workings ?Take a look on Amazon some Jonathan Lewis books.
    I will also recommend you to take a look on the following blogs:
    - http://jonathanlewis.wordpress.com/
    - http://www.juliandyke.com/
    - http://richardfoote.wordpress.com/
    - http://tkyte.blogspot.com/
    And also any good interview based good Oracle DBA books ?You can take a look on my blog for some common DBA interview questions.
    http://oraclenz.com/category/interview-tips/
    Regards,
    Francisco Munoz Alvarez
    www.oraclenz.com

  • 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

  • SQL tuning guide

    Hello Gurus,
    We have 10.2.04 RAC database running in production.The application does lot of DML.I need to tune query regularly.
    Could anybody sugggest a good book for Oracle SQl tuning.
    Thanks and Regards,
    jitender
    Edited by: user10552550 on Feb 22, 2010 5:53 AM

    The Oracle Database Performance Tuning Guide in the Oracle Database documentation library has a lot of information. Several chapters have "SQL" in their titles, including "SQL Tuning Overview".
    However, if you're looking for third-party books, I don't know know enough about them to recommend one versus another.

  • SQL Tuning Advisor says I have old statistics but they were collected today

    Hi all,
    Oracle 10.2.0.4.0 64-bit
    Win 2003 Standard Edition 64-bit
    I was looking at some problem code of ours earlier through Enterprise Manager, and decided to use the advisor to see what it recommended about one statement. (Apologies at this point for being 100% on the name of the advisor as I am working in Spanish, but I guess it may be "SQL Tuning Advisor"?)
    The recommendations were all to do with gathering optimizer statistics on the various tables and indexes involved as they were "out-dated". I have checked the LAST_ANALYZED columns in DBA_TABLES and they were collected automatically, as always, at 0230 today. The advisor task was run at about 1030.
    Has anyone else seen this? Is it a bug? Or is the advisor very intelligent and suggesting that the data in the tables has changed dramatically since 0230 this morning and that yes, those stats really need collecting again?
    Regards,
    Ados

    Hi Niall,
    Thanks for replying. My guess was that it was probably doing something based on how much the content of the table had changed, but I didn't know about the 10% threshold. Thanks for that.
    However, would it be looking in the STALE_STATS column in ALL/DBA_TAB_STATISTICS and ALL/DBA_IND_STATISTICS to see this?
    (This is how I woud do it, however I am a mere mortal, unlike the Oracle advisor.. )
    I checked there already and all of the tables and indexes in question have the value "NO".
    So I still don't get it
    ?:|
    Regards,
    Ados

  • About Automatic SQL Tuning.

    Hii all,
                   I have tuned one query by using SQL Tuning  Advisor in SQL Developer Tool. I have seen much improvement in Explain plan in advisor .. After tuning finished i executed following script.
    {code}
    select dbms_sqltune.report_tuning_task('staName47421') as Rems
    from dual;
    {code}
    I seen an explain plan but i am not able to see recommended changes in query .. Is it possible to get the query directly from any view ..
    I tried and checked in many dynamic views by keeping plan_hash_value as reference .. I found records in some dynamic views like dba_sqltune_plans and dba_advisor_sqlstats but i am unable to find exact sqltext .. Kindly advice if possible to get that query .. My query was taking 17 mins but it got reduced to 2 mins by seeing sql tuned explain plan so i want to see as what are the changes been done .
    Regards,
    Nitesh.

    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

  • 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)

  • SQL Tuning for Exadata

    Hi,
    I would like to know any SQL tuning methods specific to Oracle exadata so that they could improve the performance of the database?
    I am aware that oracle exadata runs with Oracle 11g, but i would like to know wheather there is any tuning scope w.r.t to SQL's on exadata?
    regards
    sunil

    Well there are some things that are very different about Exadata. All the standard Oracle SQL tuning you have learned already should not be forgotten as Exadata is running standard 11g database code, but there are many optimizations that have been added that you should be aware of. At a high level, if you are doing OLTP type work you should be trying to make sure that you take advantage of Exadata Smart Flash Cache which will significantly speed up your small I/O's. But long running queries are where the big benefits show up. The high level tuning approach for them is as follows:
    1. Check to see if you are getting Smart Scans.
    2. If you aren't, fix what ever is preventing them from being used.
    We've been involved in somewhere between 25-30 DB Machine installations now and in many cases, a little bit of effort changes performance dramatically. If you are only getting 2 to 3X improvement over your previous platform on these long running queries you are probably not getting the full benefit of the Exadata optimizations. So the first step is learning how to determine if you are getting Smart Scans or not and on what portions of the statement. Wait events, session statistics, V$SQL, SQL Monitoring are all viable tools that can show you that information.

  • ? Regarding 'SQL user-defined function' execution performance ?

    Hi All,
    I have an user-defined function in SQL which am using in a SQL select statement and i found that the execution time taken by the user-defined function is 9-10 minutes as a result of which my whole query execution time is affected.
    How to i improvise the execution time. Should i do some sort of scheduling for executing the user-defined functions only. Am new to the database world. Your early response with a good suggestion would really be appreciated.
    Thanks in Advance.

    Try to read SQL tuning documents along with TkProf. Then only you will be able to detect the problem.
    There is no instant method by which you can solve this problem.
    But, you can get idea from this samples.
    Tuning:
    http://www.dba-oracle.com/art_sql_tune.htm
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::NO::P11_QUESTION_ID:8764517459743
    Reading TkProf:
    http://www.dbspecialists.com/presentations/use_explain.html
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:920429344869
    Regards.
    Satyaki De.

  • 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

Maybe you are looking for