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

Similar Messages

  • Any tool or shortcut to get SQL tuning suggestion???????

    Hi I have to tune an application and need to go throught alot many SQL their PLAN and ti tune them.
    I want to know ether is there any tool online or may be from oracle to get the tuning suggestions straighytway.my oracle version is 9206
    Can i use 10g SQL tuning advisor with 9i database????
    Thanks
    Gagan

    Hi Gagan,
    Can i use 10g SQL tuning advisor with 9i databaseNo, but you can do the same thing manually, and often do a better job:
    Tune SQL with optimizer parms:
    http://www.dba-oracle.com/t_sql_optimizer_parameters.htm
    Find missing indexes:
    1 - Search for unnecessary large-table, full-table scans
    2 - Compare consistent gets to rows returned
    http://www.dba-oracle.com/art_sql_tune.htm
    Hope this helps. . . .
    Donald K. Burleson
    Oracle Press author

  • SQL Tuning Advisor against the session (is it poosible)

    My Company customer has observed that there is job that are running longer than expected running(5 days).
    They did not gave any information.they want me to run
    SQL Tuning Advisor against the session running this job.
    can you run sql tunning advisor against running session?
    if so how
    Please suggest me your valuable tips so that I approach this work properly.
    DB = 11g
    OS= Solaris 10

    >
    ...SQL Tuning Advisor against the session running this job.
    can you run sql tunning advisor against running session?
    >
    SQL Tuning Advisor is run on statements and not sessions. I don't do much with SQL Tuning Advisor, but I'd consider that current running sessions a lost cause until it completes or you kill it. You can see the "estimate" of how long that current running SQL is going to take in v$session_longops. You can use a script like Tanel's sw.sql
    http://blog.tanelpoder.com/2008/01/08/updated-session-wait-script/
    to see what the wait interface has to say.
    >
    Please suggest me your valuable tips so that I approach this work properly.
    >
    My approach for this would be to determine what the current explain plan is and compare it to one that ran (correctly) in the past and then try to determine why it changed. (bad stats, dropped index, parameter changes, etc).
    Cheers.

  • IIR 2.8.0.7 performance tuning suggestions / documents for Oracle 11?

    Would we have any hints or white papers that would support a customer in IIR matching server tuning for initial load performance,
    beyond the Siebel specific
    Performance Tuning Guidelines for Siebel CRM Application on Oracle Database (Doc ID 781927.1)
    which does NOT generate any statistics on the Informatica Schema?
    Customer is starting production data load into Siebel UCM of over 5 million customer records . Their current bottle neck seems to be IIR queries and high IIR host resources usage.
    This would be for Siebel 8.1.1.4 [21225] on Oracle 11.1.0.6; I currently do not know if ACR 475 with its EBC access is used or not; I'd be looking for any performance tuning suggestions on the Informatica & database side - I have not found anything helpful in the informatica knowledgebase and in the 2.8.0.7 docs the only performance tuning suggestions seem to be on IDT loads.
    Obviously performance can be influenced by the matching fields used, but this customer will be looking for performance tuning suggestions keeping the matching fields and thresholds they got approved from the business side.
    Any documents we could share?

    Hi Varad,
    Well, Oracle Metalink actually got it fixed for me! Got to give them credit.
    I ran the 1st bit of SQL they sent me and it fixed it so I think it was only cosmetic. I've enclosed all of their response in case others may find themselves in similar situation.
    Thanks again for YOUR help too.
    Perry
    ==========================================================
    1. Do you see any invalid objects in the database?
    2. Please update the SR with the output of running the commands below
    1.Connect as SYS.
    set serveroutput on (This will let you see if any check fails)
    exec validate_apex; (If your version is 2.0 or above)
    If all are fine, the registry should be changed to VALID for APEX and you should see the following
    message:
    PL/SQL procedure successfully completed.
    Note : The procedure validate_apex should always complete successfully.
    With serveroutput on, it should show why Application Express is listed as invalid.It should show output like:
    FAILED CHECK FOR <<obect_name>>
    Or
    FAILED EXISTENCE CHECK FOR <<object_name>>

  • Best Oracle SQL Tuning Books

    All,
    I am new in SQL Tuning. Can anyone suggests any good book / pdfs / links to start the work in tuning.
    Regards
    ND

    Besides the documentation that BluShadow provided I would suggest the following books:
    Cost-Based Oracle Fundamentals (ISBN-13 978-1590596364)
    Troubleshooting Oracle Performance (ISBN-13 978-1590599174)
    Optimizing Oracle Performance (ISBN-13 978-0596005276)
    Expert Oracle Database Architecture (ISBN-13 978-1590595305)

  • Sql Tuning using OEM and Logon triggers

    OEM = 10.2.0.4/Agent 10.2.0.4
    Target = 10.2.0.3 Db
    We have several db users that have session level adjustments made by use of logon triggers. When OEM is used to review one of those session's performance and sql tuning opportunities - are the logon triggers and the session level settings taken into consideration? Another way to ask is if the suggested changes from the sql profiler are making decisions based on the user's session level settings?
    Thank you in advance.
    -abe

    Your logon triggers affect the new sessions. When you monitor with OEM, it is no affect on OEM's activity. Hoping that, your logon trigger did not affect the user which OEM uses to connect to repository DB.

  • DBA+Sql tuning

    hello everyone i am an oracle developer working in oracle Forms and reports i have a keen interest in this database and would like to become a DBA.. pls suggest me some good books which can teach me about the whole oracle architecture and the other details.
    Apart from that i want to study Sql tuning too for oracle 10g database.. please suggest me some good books regarding both these two topics.

    Hi,
    Apart from that i want to study Sql tuning too for oracle 10g database.. please suggest me some good books regarding both these two topics.Apart from Oracle Documentation, there are many good references available in the market, go through the review and check the table of contents before deciding which book(s) you want to go with.
    Oracle 10g DBA
    http://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=Oracle+10g+DBA
    Oracle SQL Tuning
    http://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=Oracle+SQL+Tuning
    Regards,
    Hussein

  • Any Good Book on SQL , PL/SQL Tuning?

    Hi,
    Please suggest me some good book on SQL , PL/SQL Tuning?
    Thanks.
    --Sam                                                                                                                                                                               

    Anything specific you be looking for?
    Good SQL Books
    Good Online PL SQL Books, Examples &Tutorials
    Good Books for  learning PL/SQL
    good tuning links and books
    Need Assistance for choosing good Pl/SQL books
    Adith

  • Need a SQL tuning tool!! Urgent

    Hi,
    does anyone know any good SQL tuning tool on Oracle?? I need one urgently for a large project.
    I've tried Quest SQLLab and it can't solve my problems. It only "advice" me. I need something more powerful!!
    Any suggestions??
    Many thanks
    Bosco

    all the other columns used in query will not be indexed!
    IMSDBA     IMS_TRDE_HSTRY_INDX_ARCH     IMSDBA     IMS_TRDE_HSTRY     ARCHIVEDT     1     7     0     ASC
    IMSDBA     IMS_TRDE_HSTRY_INDX1     IMSDBA     IMS_TRDE_HSTRY     IMS_TRDE_OID     1     16     16     ASC
    IMSDBA     PK_IMS_TRDE     IMSDBA     IMS_TRDE     IMS_TRDE_OID     1     16     16     ASC
    IMSDBA     IMS_TRDE_INDX_ARCH     IMSDBA     IMS_TRDE     ARCHIVEDT     1     7     0     ASCAlso,the table is a very big table indeed:
    SEGMENT_NAME                   BYTES/1024/1024/1024
    IMS_TRDE_HSTRY                             30.28125GBthanks
    Edited by: PhoenixBai on Oct 14, 2009 5:14 PM

  • Tuning sql automatic using SQL Tuning Advisor Tool

    I need to work on Automatic sql tuning..
    Please give suggestion for the below
    1) I have installed oracle11g client version. confirm this is okey for my project. because i heard we should have oracle enterprise edition for this.
    2) User with only sys privelage can work on this automatic sql tuning using sql tuning advisior tool.
    Please clarify above suggestions.
    ALso suggest me best way to proceed further
    S

    Sunny kichloo wrote:
    This docs will help
    http://www.oracle-base.com/articles/10g/automatic-sql-tuning-10g.php
    http://www.oracle-base.com/articles/11g/automatic-sql-tuning-11gr1.php
    Thanks for your link. i already seen this link.
    Could u pls answer my question on above with " Yes" or "No"
    Kindly reply
    S

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

  • 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

  • Sql tuning advisor-10g

    Dear all,
    DB : 10.2.0.4.
    Solaris 5.10
    One of the monthly process had a problem and one of the select statements was taking a lot of time and when I ran sql tuning advisor, initially it advised me to accept the new sql profile. then since there is no improvements, I proceeded with running sql tuning advisor again which resulted in
    Optimizer statistics for index "USER"."CDR_BITMAP_IDX" are stale. Consider collecting optimizer statistics for this index. The optimizer requires up-to-date statistics for the index in order to select a good execution plan.
    Miscellaneous SQL Profile "SYS_SQLPROF_02492cc266e98000" exists for this statement and was ignored during the tuning process.
    select b.custno ,b.contrno ,b.rowid  ,a.subscr_type ,a.area ,a.subno ,
      nvl(a.imsi_no,:"SYS_B_00") ,a.extn ,a.b_subno ,a.chargetype ,a.tariffclass ,
      a.cdrcode ,to_char(a.transdate,'YYYYMMDD') ,to_char(nvl(a.transdate_to,
      a.transdate),'YYYYMMDD') ,nvl(a.no_of_calls,:"SYS_B_01") ,nvl(a.duration,
      :"SYS_B_02") ,nvl(a.act_duration,:"SYS_B_03") ,a. time  ,a.time_data ,
      a.act_time ,a.cdrtext ,a.ar_cdrtext ,a.cdramount ,a.cdramount_int ,
      a.gross_amount ,a.gross_amount_int ,nvl(adv_cdramount,:"SYS_B_04") ,
      nvl(adv_gross_amount,:"SYS_B_05") ,to_char(nvl(adv_transdate,transdate),
      'YYYYMMDD') ,to_char(nvl(adv_transdate_to,transdate_to),'YYYYMMDD') ,
      a.factor ,a.factor_int ,to_char(a.upddate,'YYYYMMDD') ,a.tax_class ,
      a.vol_group ,nvl(a.table_gen,:"SYS_B_06") ,a.call_type ,
      to_char(a.ltd,'YYYYMMDD') ,nvl(a.equipgroup,:"SYS_B_07") ,
      nvl(a.equipid,:"SYS_B_08") ,dest_code ,rate_type ,org_tariff_group ,
      tariff_group ,rate_pos ,nvl(a.tariff_profile,:"SYS_B_09") ,a.rowid  ,
      nvl(a.adv_cdred,:"SYS_B_10") ,a.SPLIT_TARIFFCLASS ,a.SPLIT_DURATION ,
      a.SPLIT_cdrAMOUNT ,a.SPLIT_cdrAMOUNT_INT
    from
    cdr_master a ,cdr_control b where (((((b.ltd=to_date(:b0,
      :"SYS_B_11") and a.contrno=b.contrno) and b.run_group=:b1) and b.cdr_flag=
      :"SYS_B_12") and nvl(a.cdred,:"SYS_B_13")<>:"SYS_B_14") and
      (((trunc(a.transdate)<=to_date(:b0,:"SYS_B_15") or ((trunc(a.upddate)<=
      to_date(:b0,:"SYS_B_16") and chargetype=:"SYS_B_17") and (((a.cdred is
      not null  and a.cdred=:"SYS_B_18") and nvl(adv_cdred,:"SYS_B_19")=
      :"SYS_B_20") or (((a.cdred is  not null  and a.cdred=:"SYS_B_21") and
      nvl(adv_cdred,:"SYS_B_22")=:"SYS_B_23") and adv_transdate_to<=to_date(:b0,
      :"SYS_B_24"))))) or ((a.cdred is  not null  and a.cdred=:"SYS_B_25") and
      nvl(adv_cdred,:"SYS_B_26")=:"SYS_B_27")) or (((a.cdred is  not null  and
      a.cdred=:"SYS_B_28") and nvl(adv_cdred,:"SYS_B_29")=:"SYS_B_30") and
      adv_transdate_to<=to_date(:b0,:"SYS_B_31")))) order by a.contrno,a.subno,
      a.subscr_type,a.area,nvl(a.equipgroup,:"SYS_B_32"),a.chargetype,a.cdrcode
      for update of a.cdred nowait
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        0      0.00       0.00          0          0          0           0
    Execute      5    451.99    1997.19     596620   37306277    3351623           0
    Fetch      404      0.96       0.84          0          0          0       39900
    total      409    452.95    1998.04     596620   37306277    3351623       39900
    Misses in library cache during parse: 0
    Optimizer mode: ALL_ROWS
    Parsing user id: 185
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      SQL*Net message to client                     404        0.00          0.00
      SQL*Net more data to client                  3219        0.00          0.03
      SQL*Net message from client                   404        0.00          0.22
      gc current block 2-way                      34454        0.27         21.77
      gc cr multi block request                    2649        0.27          1.06
      db file sequential read                    596211        0.15       1561.81
      gc cr block busy                               16        0.00          0.02
      db file parallel read                          11        0.00          0.04
      db file scattered read                         50        0.01          0.10
      gc cr block 2-way                               2        0.00          0.00
      gc current grant 2-way                          6        0.00          0.00
      latch: cache buffers chains                     9        0.00          0.00
      gc current block congested                      6        0.00          0.02
      gc current grant busy                         257        0.00          0.17
      latch: object queue header operation            3        0.00          0.00
      log file switch completion                     22        0.82          2.52
      latch free                                     27        0.00          0.00
      log buffer space                                7        0.24          0.83
      log file switch (checkpoint incomplete)        10        0.98          1.47
      gc cr grant 2-way                               2        0.00          0.00Any idea what am missing ?
    Kai

    Hi,
    Try to Update the Stats of the Source tables and re-reun the Advisor, that might give or suggest different things further.
    Second thing, check that Referred SQL profile and I would suggest if it not used, then drop that and check.
    Surprised to see huge wait event on "db file sequential read"
    - Pavan Kumar N

  • SQL Tuning Advisor Report

    Hello All,
    I am using Oracle SQL Developer 3.0.04 Build MAIN-04.34. I have tried SQL Tuning Advisor to tune one of the query we have. SQL Tuning advisor has completed its processing after 10 minutes. I would like to save the result of SQL Tuning advisor for my future comaprisions and other purposes. Is there anyway i can export whatever SQL Tuning Advisor shows on the screen?
    Very much appreciate all your inputs.
    Thanks.

    Santosh,
    I suggest you to look into the "Oracle Database Performance Tuning Guide". May be you can download from OTN. You will get information about the Performance Tuning that includes SQL Tuning Advisor also.
    Access Path means the path by which data is retrieved from a database. For example, a query using an index and a query using a full table scan use different access paths.
    Predicate is the WHERE condition in a SQL statement.
    Thanks.
    -Ramesh

Maybe you are looking for

  • Skydrive pro and powershell

    Hi guys, just wondering if there was any powershell cmdlets for controlling syncing with skydrive pro? I would prefer to automate the setup process rather than have our users click on the sync button thanks

  • Nokia 6270 during lost connection now mobile not w...

    I tried to update nokia 6270 software in middle of update its says u lost the connection to mobile and pop up a msg saying 'power off mobile remove usb cable and battery/charger for 5 sec then put battery in and USB cable do power on and retry update

  • Keynote exporting to quicktime

    When quicktime video is embedded on a slide and entire project is exported to quicktime the exported video plays almost all the way through then freezes for a long time. The transition finally plays(the time for this is also pushed back as much as a

  • Filling the Bucket of Select-option as DEFAULT??

    Hi Experts, Pls. clarify my doubt reg. Selection screen, When I, <i><b>F8</b></i> the my_z_report, the selection screen is coming with default values (say,  A; B; C; D) in the bucket of <i><b>multiple selection</b></i> of the <b><i>select option s_do

  • Internet directory clients

    I have installed and the server works fine. The demo shows two client interfaces through the ldap interface. One is an applet used in the demo to create a new user, the other is an internet directory gateway using servlets and displaying HTML. where