Hint and Explain Plan

Hi,
in 11.2.0.3 I run a query  with hint and withou but the executed query plan from DBMS_XPLAN.DISPLAY_CURSOR
are the same (any idea) even if i flushed shared pool :
SQL_ID  gh0mjh2ap7maf, child number 0                                                                                                                                                                                                                                                                       
SELECT SETID, BUSINESS_UNIT, BANK_CD, BANK_ACCT_KEY,                                                                                                                                                                                                                                                        
PRCR_DOC_ID, PRCR_DOC_TYPE, CB_SELECT_PO, CURRENCY_CD,                                                                                                                                                                                                                                                      
CURRENCY_CD_BASE, TO_CHAR(DOCSTAT_DATE,'YYYY-MM-DD'), DESCR,                                                                                                                                                                                                                                                
STATUS_FIELD, VENDOR_ID, VENDOR_SETID, VNDR_LOC, INVOICE_ID FROM                                                                                                                                                                                                                                            
PS_PRCR_DS_VC_SRCH A WHERE EXISTS (SELECT 'X' FROM                                                                                                                                                                                                                                                          
PS_VOUCHER_LINE VL, PS_RTV_LN_DISTRIB RT WHERE A.BUSINESS_UNIT =                                                                                                                                                                                                                                            
VL.BUSINESS_UNIT AND A.PRCR_DOC_ID = VL.VOUCHER_ID AND                                                                                                                                                                                                                                                      
VL.BUSINESS_UNIT_RTV = RT.BUSINESS_UNIT AND VL.RTV_ID =                                                                                                                                                                                                                                                     
RT.RTV_ID AND VL.RTV_LN_NBR = RT.RTV_LN_NBR AND RT.BUSINESS_UNIT                                                                                                                                                                                                                                            
= 'X01' AND RT.RTV_ID =0000000188 ) ORDER BY SETID,                                                                                                                                                                                                                                                       
BUSINESS_UNIT, BANK_CD, BANK_ACCT_KEY, PRCR_DOC_ID, PRCR_DOC_TYPE                                                                                                                                                                                                                                           
Plan hash value: 3867296312                                                                                                                                                                                                                                                                                 
| Id  | Operation                      | Name              | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |                                                                                                                                                                                                
|   0 | SELECT STATEMENT               |                   |       |       |       |  1234K(100)|          |                                                                                                                                                                                                
|   1 |  SORT ORDER BY                 |                   |     1 |    67 |    28M|  1234K  (1)| 04:06:59 |                                                                                                                                                                                                
|*  2 |   FILTER                       |                   |       |       |       |            |          |                                                                                                                                                                                                
|*  3 |    TABLE ACCESS FULL           | PS_VOUCHER        |   308K|    19M|       |  9313   (1)| 00:01:52 |                                                                                                                                                                                                
|   4 |    NESTED LOOPS                |                   |     1 |    44 |       |     4   (0)| 00:00:01 |                                                                                                                                                                                                
|*  5 |     INDEX RANGE SCAN           | PS_RTV_LN_DISTRIB |     1 |    20 |       |     1   (0)| 00:00:01 |                                                                                                                                                                                                
|*  6 |     TABLE ACCESS BY INDEX ROWID| PS_VOUCHER_LINE   |     1 |    24 |       |     3   (0)| 00:00:01 |                                                                                                                                                                                                
|*  7 |      INDEX RANGE SCAN          | PS_VOUCHER_LINE   |     1 |       |       |     2   (0)| 00:00:01 |                                                                                                                                                                                                
Predicate Information (identified by operation id):                                                                                                                                                                                                                                                         
2 - filter( IS NOT NULL)                                                                                                                                                                                                                                                                                    
3 - filter("A"."ENTRY_STATUS"<>'X')                                                                                                                                                                                                                                                                         
5 - access("RT"."BUSINESS_UNIT"='IFP01')                                                                                                                                                                                                                                                                    
filter(TO_NUMBER(SYS_OP_UNDESCEND("RT"."SYS_NC00066$"))=188)                                                                                                                                                                                                                                                
6 - filter(("VL"."BUSINESS_UNIT_RTV"='IFP01' AND                                                                                                                                                                                                                                                            
"VL"."RTV_ID"=SYS_OP_UNDESCEND("RT"."SYS_NC00066$") AND "VL"."RTV_LN_NBR"="RT"."RTV_LN_NBR"))                                                                                                                                                                                                               
7 - access("VL"."BUSINESS_UNIT"=:B1 AND "VL"."SYS_NC00206$"=SYS_OP_DESCEND(:B2))                                                                                                                                                                                                                            
filter(SYS_OP_UNDESCEND("VL"."SYS_NC00206$")=:B1)                                                                                                                                                                                                                                                           
41 lignes sélectionnées
Elapsed: 00:00:00.015
'AVECINDEX'
avec index
Elapsed: 00:00:00.000
PLAN_TABLE_OUTPUT                                                                                                                                                                                                                                                                                         
SQL_ID  4g6j5avbz9jh7, child number 0                                                                                                                                                                                                                                                                       
SELECT /*+INDEX (SYSADM.PS_VOUCHER_LINE, SYSADM.IDX$$_1E0A0001) */                                                                                                                                                                                                                                          
SETID, BUSINESS_UNIT, BANK_CD, BANK_ACCT_KEY,              PRCR_DOC_ID,                                                                                                                                                                                                                                     
PRCR_DOC_TYPE, CB_SELECT_PO, CURRENCY_CD,                                                                                                                                                                                                                                                                   
CURRENCY_CD_BASE, TO_CHAR(DOCSTAT_DATE,'YYYY-MM-DD'), DESCR,                                                                                                                                                                                                                                                
STATUS_FIELD, VENDOR_ID, VENDOR_SETID, VNDR_LOC, INVOICE_ID FROM                                                                                                                                                                                                                                            
PS_PRCR_DS_VC_SRCH A WHERE EXISTS (SELECT 'X' FROM                                                                                                                                                                                                                                                          
PS_VOUCHER_LINE VL, PS_RTV_LN_DISTRIB RT WHERE A.BUSINESS_UNIT =                                                                                                                                                                                                                                            
VL.BUSINESS_UNIT AND A.PRCR_DOC_ID = VL.VOUCHER_ID AND                                                                                                                                                                                                                                                      
VL.BUSINESS_UNIT_RTV = RT.BUSINESS_UNIT AND VL.RTV_ID =                                                                                                                                                                                                                                                     
RT.RTV_ID AND VL.RTV_LN_NBR = RT.RTV_LN_NBR AND RT.BUSINESS_UNIT                                                                                                                                                                                                                                            
= 'X01' AND RT.RTV_ID =0000000188 ) ORDER BY SETID,                                                                                                                                                                                                                                                       
BUSINESS_UNIT, BANK_CD, BANK_ACCT_KEY, PRCR_DOC_ID, PRCR_DOC_TYPE                                                                                                                                                                                                                                           
Plan hash value: 3867296312                                                                                                                                                                                                                                                                                 
| Id  | Operation                      | Name              | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |                                                                                                                                                                                                
|   0 | SELECT STATEMENT               |                   |       |       |       |  1234K(100)|          |                                                                                                                                                                                                
|   1 |  SORT ORDER BY                 |                   |     1 |    67 |    28M|  1234K  (1)| 04:06:59 |                                                                                                                                                                                                
|*  2 |   FILTER                       |                   |       |       |       |            |          |                                                                                                                                                                                                
|*  3 |    TABLE ACCESS FULL           | PS_VOUCHER        |   308K|    19M|       |  9313   (1)| 00:01:52 |                                                                                                                                                                                                
|   4 |    NESTED LOOPS                |                   |     1 |    44 |       |     4   (0)| 00:00:01 |                                                                                                                                                                                                
|*  5 |     INDEX RANGE SCAN           | PS_RTV_LN_DISTRIB |     1 |    20 |       |     1   (0)| 00:00:01 |                                                                                                                                                                                                
|*  6 |     TABLE ACCESS BY INDEX ROWID| PS_VOUCHER_LINE   |     1 |    24 |       |     3   (0)| 00:00:01 |                                                                                                                                                                                                
|*  7 |      INDEX RANGE SCAN          | PS_VOUCHER_LINE   |     1 |       |       |     2   (0)| 00:00:01 |                                                                                                                                                                                                
Thanks for your ideas.

Yes, seems the main problem was not to use schema :
SQL_ID  96wfx2fu9h5uy, child number 0                                                                                                                                                                                                                                                                      
SELECT SETID, BUSINESS_UNIT, BANK_CD, BANK_ACCT_KEY,                                                                                                                                                                                                                                                       
PRCR_DOC_ID, PRCR_DOC_TYPE, CB_SELECT_PO, CURRENCY_CD,                                                                                                                                                                                                                                                     
CURRENCY_CD_BASE, TO_CHAR(DOCSTAT_DATE,'YYYY-MM-DD'), DESCR,                                                                                                                                                                                                                                               
STATUS_FIELD, VENDOR_ID, VENDOR_SETID, VNDR_LOC, INVOICE_ID FROM                                                                                                                                                                                                                                           
PS_PRCR_DS_VC_SRCH A WHERE EXISTS (SELECT /*+ INDEX(VL,                                                                                                                                                                                                                                                    
IDX$$_1E0A0001) */ 'X' FROM              PS_VOUCHER_LINE VL,                                                                                                                                                                                                                                               
PS_RTV_LN_DISTRIB RT WHERE A.BUSINESS_UNIT =                                                                                                                                                                                                                                                               
VL.BUSINESS_UNIT AND A.PRCR_DOC_ID = VL.VOUCHER_ID AND                                                                                                                                                                                                                                                     
VL.BUSINESS_UNIT_RTV = RT.BUSINESS_UNIT AND VL.RTV_ID =                                                                                                                                                                                                                                                    
RT.RTV_ID AND VL.RTV_LN_NBR = RT.RTV_LN_NBR AND RT.BUSINESS_UNIT                                                                                                                                                                                                                                           
= 'X01' AND RT.RTV_ID =0000000188 ) ORDER BY SETID,                                                                                                                                                                                                                                                      
BUSINESS_UNIT, BANK_CD, BANK_ACCT_KEY, PRCR_DOC_ID, PRCR_DOC_TYPE                                                                                                                                                                                                                                          
Plan hash value: 730776856                                                                                                                                                                                                                                                                                 
| Id  | Operation                      | Name              | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |                                                                                                                                                                                               
|   0 | SELECT STATEMENT               |                   |       |       |       |  1235K(100)|          |                                                                                                                                                                                               
|   1 |  SORT ORDER BY                 |                   |     1 |    67 |    28M|  1235K  (1)| 04:07:03 |                                                                                                                                                                                               
|*  2 |   FILTER                       |                   |       |       |       |            |          |                                                                                                                                                                                               
|*  3 |    TABLE ACCESS FULL           | PS_VOUCHER        |   308K|    19M|       |  9313   (1)| 00:01:52 |                                                                                                                                                                                               
|   4 |    NESTED LOOPS                |                   |     1 |    44 |       |     4   (0)| 00:00:01 |                                                                                                                                                                                               
|*  5 |     INDEX RANGE SCAN           | PS_RTV_LN_DISTRIB |     1 |    20 |       |     1   (0)| 00:00:01 |                                                                                                                                                                                               
|*  6 |     TABLE ACCESS BY INDEX ROWID| PS_VOUCHER_LINE   |     1 |    24 |       |     3   (0)| 00:00:01 |                                                                                                                                                                                               
|*  7 |      INDEX RANGE SCAN          | IDX$$_1E0A0001    |     1 |       |       |     2   (0)| 00:00:01 |                                                                                                                                                                                               

Similar Messages

  • Saving/exporting autotrace and explain plan

    Is it at all possible to export or save the explain plan and/or autotrace information from Oracle SQL Developer to text?

    You must first click Explain icon or Autotrace Icon to generate them before you can check under the tab.

  • Autotrace and explain plan just show a green dot

    When I click on the AUTOTRACE and the EXPLAIN PLAN tabs in SQL Developer all I get is a green dot. I do have PLUSTRCE roll defined to my signon. I am running SQL DEVELOPER 1.5.1 on Windows XP Professional Patch 3.

    You must first click Explain icon or Autotrace Icon to generate them before you can check under the tab.

  • Efficient way to read through big explain plan and genterate html explain plan for sql id's executed in past

    Hi,
    I have a sql which is recently having a performance problems in Production. I have generated a explain plan for it trying to find out what it is doing but plan itself is close to 1000 lines. I want to check if there is any efficient way to go through big plan like this one and quickly find the damaging areas..
    2) I also wanted to know if there is way to generate explain plans in HTML format which executed in past and have entry in dba_hist_sqltext.
    3) I also have two sql_monitor reports which I want to compare. is there any efficient way to do it as well?
    Please share your thoughts!
    Thanks in advance!
    Regards,
    Suman-

    Hi,
    I suggest you can try running sql advisor on the query maybe something fruitful comes up
    http://www.oracle-base.com/articles/11g/sql-access-advisor-11gr1.php
    I am not sure about the explain plan being printed in html format but
    You may also want to try the sqlhistory.sql query from below page
    http://evdbt.com/scripts/
    I have used it many times to check on executions and explain plans which may have changed over the period
    I have faced it many times , the query picks up a bad explain plan and performs poorly

  • Oem explain plan produced doesn't correspond to explain plan with tkprof

    Hello all,
    I am running OEM on a 10.2.0.3 database and I have a very slow query with cognos 8 BI on my data warehouse.
    I went to the dbconsole through OEM and connected to target database I went to look at the query execution and then got an explain plan.
    Then I did a trace file and ran it throught tkprof.
    When I look at both produced explain plan, I can see the tree looks the same exept the corresponding values. In OEM, it says I am going throug 18000 rows and in the tkprof result it says more like millions of records.
    As anybody had these kind of results?
    Shall I have more confidence in TKprof then OEM?
    It is very important to me since I am being chalanged by an external DBA.

    I would recommend you to get Christian Antogini´s book "Troublshooting Oracle Performance", (http://www.antognini.ch/top/) which explains everything you need to know when analyzing Oracle SQL Performance and Explain Plans.
    If you properly trace your SQL Statement, you will get "STAT" lines in the trace file. These stat lines show you the actual number of rows processed per row source operation. Explain plan per default does only show you the "estimated" row counts for the row source operations no matter whether you use "explain=" in the tkprof call or OEM to get the explain plan. Tkprof reads the STAT lines from the trace and outputs a section which is similar to an execution plan but contains the "real" number of rows.
    However, if you want to troubleshoot Oracle Performance, I would recommend you to run the statement with the hint /*+ GATHER_PLAN_STATISTICS */ or set statistics_level=ALL in your session (not database-wide!).
    If you do, you can get an excellent execution plan with DBMS_XPLAN.DISPLAY_CURSOR containing both estimated rows as well as actual rows combined with the "number of starts" for e.g. nested loop joins.
    Get the book, read it, and you will be able to discuss this issue with your external dba in a professional way. ;-)
    Regards,
    Martin
    www.ora-solutions.net

  • Understand the output of explain plan

    I am trying to understand the output of explain plan. I have 2 plans below and don't understand it completely.
    In below SQL I would expect optimizer to fetch "ROWNUM < 500" first and then do the outer join. But below explain plan doesn't list it as No. 1. So I don't really understand how to intepret the sequence from the explain plan:
    select TASK0_.TASK_ID from
    (  select TASK0_.TASK_ID from
      ( select task0_.task_id  from task task0_) TASK0_ where ROWNUM < 500 ) TASK0_ 
    left outer join f_message_task task0_1_ on task0_.task_id=task0_1_.task_id
    left outer join b_a_task task0_2_ on task0_.task_id=task0_2_.task_id
    left outer join i_task task0_3_ on task0_.task_id=task0_3_.task_id
    left outer join o_task task0_4_ on task0_.task_id=task0_4_.task_id
    left outer join r_transmission_task task0_5_ on task0_.task_id=task0_5_.task_id
    left outer join s_error_task task0_6_ on task0_.task_id=task0_6_.task_id
    PLAN_TABLE_OUTPUT     
    Plan hash value: 707970537     
    | Id  | Operation                    | Name                     | Rows  | Bytes | Cost (%CPU)| Time     |     
    |   0 | SELECT STATEMENT             |                          |   499 | 19461 |  1042   (6)| 00:00:13 |     
    |*  1 |  HASH JOIN OUTER             |                          |   499 | 19461 |  1042   (6)| 00:00:13 |     
    |*  2 |   HASH JOIN OUTER            |                          |   499 | 16966 |   757   (6)| 00:00:10 |     
    |   3 |    NESTED LOOPS OUTER        |                          |   499 | 14471 |   589   (4)| 00:00:08 |     
    |   4 |     NESTED LOOPS OUTER       |                          |   499 | 12475 |   588   (4)| 00:00:08 |     
    |   5 |      NESTED LOOPS OUTER      |                          |   499 | 10479 |   588   (4)| 00:00:08 |     
    |   6 |       NESTED LOOPS OUTER     |                          |   499 |  8982 |   588   (4)| 00:00:08 |     
    |   7 |        VIEW                  |                          |   499 |  2495 |   588   (4)| 00:00:08 |     
    |*  8 |         COUNT STOPKEY        |                          |       |       |            |          |     
    |   9 |          INDEX FAST FULL SCAN| PK_TASK                  |   697K|  3403K|   588   (4)| 00:00:08 |     
    |* 10 |        INDEX UNIQUE SCAN     | PK_r_TRANSMISSION |     1 |    13 |     0   (0)| 00:00:01 |     
    |* 11 |       INDEX UNIQUE SCAN      | PK_b_a_TASK          |     1 |     3 |     0   (0)| 00:00:01 |     
    |* 12 |      INDEX UNIQUE SCAN       | PK_s_ERROR_TASK     |     1 |     4 |     0   (0)| 00:00:01 |     
    |* 13 |     INDEX UNIQUE SCAN        | PK_i_TASK    |     1 |     4 |     0   (0)| 00:00:01 |     
    |  14 |    INDEX FAST FULL SCAN      | PK_o_TASK           |   347K|  1695K|   161   (6)| 00:00:02 |     
    |  15 |   INDEX FAST FULL SCAN       | PK_f_MESSAGE        |   392K|  1917K|   276   (4)| 00:00:04 |     
    Predicate Information (identified by operation id):     
       1 - access("TASK0_"."TASK_ID"="TASK0_1_"."TASK_ID"(+))     
       2 - access("TASK0_"."TASK_ID"="TASK0_4_"."TASK_ID"(+))     
       8 - filter(ROWNUM<500)     
      10 - access("TASK0_"."TASK_ID"="TASK0_5_"."TASK_ID"(+))     
      11 - access("TASK0_"."TASK_ID"="TASK0_2_"."TASK_ID"(+))     
      12 - access("TASK0_"."TASK_ID"="TASK0_6_"."TASK_ID"(+))     
      13 - access("TASK0_"."TASK_ID"="TASK0_3_"."TASK_ID"(+))     
    In below SQL I expect rownum to be applied at the end but it gets applied first:
    select *  from (  select TASK0_.TASK_ID from ( select task0_.task_id  from task task0_ 
    left outer join f_message_task task0_1_ on task0_.task_id=task0_1_.task_id
    left outer join b_a_task task0_2_ on task0_.task_id=task0_2_.task_id
    left outer join i_task task0_3_ on task0_.task_id=task0_3_.task_id
    left outer join o_task task0_4_ on task0_.task_id=task0_4_.task_id
    left outer join r_t_task task0_5_ on task0_.task_id=task0_5_.task_id
    left outer join s_error_task task0_6_ on task0_.task_id=task0_6_.task_id
    ) TASK0_ where ROWNUM < 500 ) TASK0_;
    PLAN_TABLE_OUTPUT     
    Plan hash value: 673345378     
    | Id  | Operation                    | Name                     | Rows  | Bytes | Cost (%CPU)| Time     |     
    |   0 | SELECT STATEMENT             |                          |   499 |  6487 |   507   (1)| 00:00:07 |     
    |   1 |  VIEW                        |                          |   499 |  6487 |   507   (1)| 00:00:07 |     
    |*  2 |   COUNT STOPKEY              |                          |       |       |            |          |     
    |   3 |    NESTED LOOPS OUTER        |                          |   501 | 19539 |   507   (1)| 00:00:07 |     
    |   4 |     NESTED LOOPS OUTER       |                          |   501 | 17034 |     5  (20)| 00:00:01 |     
    |   5 |      NESTED LOOPS OUTER      |                          |   501 | 15030 |     5  (20)| 00:00:01 |     
    |   6 |       NESTED LOOPS OUTER     |                          |   501 | 13026 |     5  (20)| 00:00:01 |     
    |   7 |        NESTED LOOPS OUTER    |                          |   501 | 11523 |     5  (20)| 00:00:01 |     
    |   8 |         NESTED LOOPS OUTER   |                          |   501 |  5010 |     5  (20)| 00:00:01 |     
    |   9 |          INDEX FAST FULL SCAN| PK_TASK                  |   499 |  2495 |     2   (0)| 00:00:01 |     
    |* 10 |          INDEX UNIQUE SCAN   | PK_o_TASK           |     1 |     5 |     1   (0)| 00:00:01 |     
    |* 11 |         INDEX UNIQUE SCAN    | PK_r_T |     1 |    13 |     0   (0)| 00:00:01 |     
    |* 12 |        INDEX UNIQUE SCAN     | PK_b_a_TASK          |     1 |     3 |     0   (0)| 00:00:01 |     
    |* 13 |       INDEX UNIQUE SCAN      | PK_s_ERROR_TASK     |     1 |     4 |     0   (0)| 00:00:01 |     
    |* 14 |      INDEX UNIQUE SCAN       | PK_i_TASK    |     1 |     4 |     0   (0)| 00:00:01 |     
    |* 15 |     INDEX UNIQUE SCAN        | PK_f_MESSAGE        |     1 |     5 |     1   (0)| 00:00:01 |     
    Predicate Information (identified by operation id):     
       2 - filter(ROWNUM<500)     
      10 - access("TASK0_"."TASK_ID"="TASK0_4_"."TASK_ID"(+))     
      11 - access("TASK0_"."TASK_ID"="TASK0_5_"."TASK_ID"(+))     
      12 - access("TASK0_"."TASK_ID"="TASK0_2_"."TASK_ID"(+))     
      13 - access("TASK0_"."TASK_ID"="TASK0_6_"."TASK_ID"(+))     
      14 - access("TASK0_"."TASK_ID"="TASK0_3_"."TASK_ID"(+))     
      15 - access("TASK0_"."TASK_ID"="TASK0_1_"."TASK_ID"(+))Edited by: user628400 on Feb 20, 2009 12:14 PM
    Edited by: user628400 on Feb 20, 2009 12:15 PM

    Please read the FAQ: http://forums.oracle.com/forums/help.jspa
    And learn how to post code and explain plans using the tags.                                                                                                                                                                                                                                                                           

  • Time column of an explain plan

    Hi,
    I'm using Oracle version 10.2.0.3.0. I have 2 tables with 10 million records each. The DDL is as follows.
    create table bigtable(col1 varchar2(20), col2 varchar2(20))
    create table bigtablechild(col1 varchar2(20), col2 varchar(20))
    bigtablechild.col1 is a foreign key to bigtable.col1. Below is the query and explain plan. Over several executions, the query runs for about 20 seconds before returning results. Could anyone please explain what the time column represents? It doesn't match the time it took to return results.
    SQL> set autotrace on
    SQL>
    SQL> select b.col2
      2  from bigtable a, bigtablechild b
      3  where a.col1 = b.col1
      4  and a.col1 = 'ABC6554';
    COL2
    XYZ6554
    XYZ6554
    XYZ6554
    XYZ6554
    XYZ6554
    Execution Plan
    Plan hash value: 4210396901
    | Id  | Operation          | Name          | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT   |               |     5 |   150 | 21538   (4)| 00:04:19 |
    |*  1 |  HASH JOIN         |               |     5 |   150 | 21538   (4)| 00:04:19 |
    |*  2 |   TABLE ACCESS FULL| BIGTABLE      |     1 |    10 | 13124   (4)| 00:02:38 |
    |*  3 |   TABLE ACCESS FULL| BIGTABLECHILD |     5 |   100 |  8413   (5)| 00:01:41 |
    Predicate Information (identified by operation id):
       1 - access("A"."COL1"="B"."COL1")
       2 - filter("A"."COL1"='ABC6554')
       3 - filter("B"."COL1"='ABC6554')
    Statistics
              0  recursive calls
              0  db block gets
          93672  consistent gets
          91845  physical reads
              0  redo size
            463  bytes sent via SQL*Net to client
            396  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
              5  rows processed

    Hi,
    the values in the TIME column are calculated from cost using system I/O statistics. If dbms_stats.gather_system_stats has never been run, then these stats have default values which may be very far from the truth. In your case, the optimizer expects a single-block I/O read to take about 12 ms, while in reality it is closer to 1 ms, thus the discrepancy between the prediction and actual results.
    In general, TIME column is not very helpful not just because of potentially incorrect I/O time estimates, but also because it is hard to predict how much data will be found in cash, so I would recommend not to pay too much attention to it (note, however, that A-time column, on the other hand, is extremely useful, but it's only available if rowsource statistics for the plan have been populated).
    Best regards,
    Nikolay

  • EXPLAIN PLAN option disabled

    Hi,
    When I take an Explain Plan using TKPROF it gives the following error:
    Error in CREATE TABLE of EXPLAIN PLAN table: APPS.prof$plan_table
    ORA-00955: name is already used by an existing object
    parse error offset: 18
    EXPLAIN PLAN option disabled.
    And the Explain Plan is snot displayed in the o/p file for all the queries.
    Can any one help me on this.
    Thanks,
    Kiran

    Hi kiran
    When I take an Explain Plan using TKPROF it gives the following error:
    Error in CREATE TABLE of EXPLAIN PLAN table: APPS.prof$plan_table
    ORA-00955: name is already used by an existing object
    parse error offset: 18
    EXPLAIN PLAN option disabled.
    ********************************************************************************What is your Db verssion and EBS? What is your kprof syntax. By the way please check those doc adn see its helpful:
    Run Adadmin To Recreate Grants And Synonyms ORA-20000 ORA-00955 In Synonyms Loop:create_synonym(GL,PLAN_TABLE,APPS,PLAN_TABLE) [ID 437714.1]
    TKPROF With Explain Fails With ORA-00903 invalid table name [ID 257294.1]
    OERR: ORA 955 is already used by an existing object [ID 18549.1]
    Also check:
    Re: TKPROF and Explain Plan
    Regard
    Helios

  • Explain plan for Query performance

    Hi Gurus,
    I need to improve the performance of a procedure. The procedure has the below QUery. I dont have Idea on how to imrpove the perf by seeing the explain plan. Can anyone please help me to explain where I need to change the code.
    The below are the code and Explain plan for the same.
    -----------Code----------------------------
    SELECT IV_STORECODE AS STORECODE,
                                   TO_CHAR(RD.ITEMCODE) AS ITEMCODE,
                                   C.ITEMCATEGORYNAME,
                                   ISUB.ITEMSUBCATEGORY1NAME
                              FROM RECEIPTS R
                             INNER JOIN RECEIPTDETAILS RD
                                ON R.RECEIPTID = RD.RECEIPTID
                             INNER JOIN ITEMCOMPANY IC
                                ON IC.ITEMCODE = RD.ITEMCODE
                             INNER JOIN ITEMCATEGORY C
                                ON IC.ITEMCATEGORY = C.ITEMCATEGORYID
                             LEFT OUTER JOIN ITEMSUBCATEGORY1 ISUB
                                ON ISUB.ITEMSUBCATEGORY1ID = IC.ITEMSUBCATEGORY1
                               AND ISUB.ITEMSUBCATEGORY1ID IN
                                   (SELECT ITEMSUBCATEGORY1ID
                                      FROM ITEMSUBCATEGORY1
                                     WHERE ITEMCATEGORYID = IV_ITEMCATEGORY)
                             INNER JOIN STORE SE
                                ON SE.STORECODE = R.STORECODE
                             WHERE R.STORECODE = IV_STORECODE
                               AND SE.HOSPITALID = IV_HOSPITALID
                               AND TRUNC(R.CREATEDDATE) BETWEEN V_FROMDATE AND
                                   V_TODATE
                               AND R.STATUSID NOT IN (99, 5)
                                  AND
                                   (IV_DRUGTYPE IS NULL OR
                                   IC.DRUGTYPECATEGORYID = IV_DRUGTYPE)
                            UNION
                            SELECT IV_STORECODE AS STORECODE,
                                   TO_CHAR(STD.ITEMCODE) AS ITEMCODE,
                                   C.ITEMCATEGORYNAME,
                                   ISUB.ITEMSUBCATEGORY1NAME
                              FROM STOCKTRANSACTION ST
                             INNER JOIN STOCKTRANSACTIONDETAILS STD
                                ON ST.STOCKTRANSACTIONID = STD.STOCKTRANSACTIONID
                             INNER JOIN ITEMCOMPANY IC
                                ON IC.ITEMCODE = STD.ITEMCODE
                             INNER JOIN ITEMCATEGORY C
                                ON IC.ITEMCATEGORY = C.ITEMCATEGORYID
                              LEFT OUTER JOIN ITEMSUBCATEGORY1 ISUB
                                ON ISUB.ITEMSUBCATEGORY1ID = IC.ITEMSUBCATEGORY1
                               AND ISUB.ITEMSUBCATEGORY1ID IN
                                   (SELECT ITEMSUBCATEGORY1ID
                                      FROM ITEMSUBCATEGORY1
                                     WHERE ITEMCATEGORYID = IV_ITEMCATEGORY)
                             INNER JOIN STORE SE
                                ON SE.STORECODE = ST.STORECODE
                             WHERE ST.STORECODE = IV_STORECODE
                               AND SE.HOSPITALID = IV_HOSPITALID
                               AND TRUNC(ST.CREATEDDATE) BETWEEN V_FROMDATE AND
                                   V_TODATE
                               AND ST.STATUS <> 99
                               AND STD.ITEMCODE NOT LIKE '%#%'
                               AND                   
                                   (IV_DRUGTYPE IS NULL OR
                                   IC.DRUGTYPECATEGORYID = IV_DRUGTYPE)
                            UNION
                            SELECT D.STORECODE,
                                   TO_CHAR(D.ITEMCODE) AS ITEMCODE,
                                   C.ITEMCATEGORYNAME,
                                   ISUB.ITEMSUBCATEGORY1NAME
                              FROM DAILYINVENTORY D
                             INNER JOIN ITEMCOMPANY IC
                                ON IC.ITEMCODE = D.ITEMCODE
                             INNER JOIN ITEMCATEGORY C
                                ON IC.ITEMCATEGORY = C.ITEMCATEGORYID
                              LEFT OUTER JOIN ITEMSUBCATEGORY1 ISUB
                                ON ISUB.ITEMSUBCATEGORY1ID = IC.ITEMSUBCATEGORY1
                               AND ISUB.ITEMSUBCATEGORY1ID IN
                                   (SELECT ITEMSUBCATEGORY1ID
                                      FROM ITEMSUBCATEGORY1
                                     WHERE ITEMCATEGORYID = IV_ITEMCATEGORY)
                             INNER JOIN STORE SE
                                ON SE.STORECODE = D.STORECODE
                             WHERE D.STORECODE = IV_STORECODE
                               AND SE.HOSPITALID = IV_HOSPITALID
                               AND TRUNC(D.UPDATEDDATE) <= V_TODATE
                               AND D.QTY > 0
                               AND D.ITEMCODE NOT LIKE '%#%'
                               AND C.ITEMCATEGORYID = IV_ITEMCATEGORY
                                  AND (IV_DRUGTYPE IS NULL OR
                                   IC.DRUGTYPECATEGORYID = IV_DRUGTYPE)
                               AND (IV_SUBITEMCATEGORY IS NULL OR
                                   ISUB.ITEMSUBCATEGORY1ID = IV_SUBITEMCATEGORY) Will post the explain plan ..
    Thanks in advance..

    Ensure you also include all the other information people will need to help you, e.g. database version, table structures/relationships and cardinalities, row counts etc.
    See the two threads linked to in the FAQ: {message:id=9360003}

  • Need help understanding Explain Plan from 10046 trace

    Below is a query and Explain Plan from a 10046 trace shown with trcanlzr.sql.
    In the explain plan I don't understand what's happining at line ID 10 and 11. Specifically, is the result at line 11 rowids from lines 12 & 14? and then what? Are those rowids somehow used in line ID 10?
    SELECT cp.cred_process_id, cp.provider_id,
           brdg_credentialing.get_appl_specialist(cp.cred_process_id,'R') specialist_name,
           brdg_cred_report_pkg.provider_name(cp.cred_process_id) provider_name,
           ctc_apptype.description appl_type_desc,
           TRUNC (brdg_credentialing.get_appl_received_dt(cp.cred_process_id)) init_received_dt,
           brdg_code_util.code_descr(brdg_credentialing.get_appl_status_cd_ctc_id(cp.cred_process_id)) appl_status_desc,
           brdg_credentialing.get_appl_prac_specialties(cp.cred_process_id,'Y') primary_specialty,
           cwh.city practice_city,
           UPPER (cwh.state) practice_state,
           TRUNC (ch.event_dt) specialist_assign_dt,
           DECODE (ctc_apptype.code,'INITPPO', TRUNC (brdg_credentialing.get_appl_received_dt(cp.cred_process_id)),
                   'REAPP', TRUNC (brdg_credentialing.get_appl_received_dt(cp.cred_process_id)),
                   'SPECCRED', TRUNC (brdg_credentialing.get_appl_received_dt(cp.cred_process_id)),
                   'TRANS', TRUNC (brdg_credentialing.get_appl_received_dt(cp.cred_process_id)),
                   'RECPPO', p.next_recred_dt,
                   'RECAPP', p.next_recred_dt, NULL) sort_date,
                   p.next_recred_dt
      FROM brdg_cred_app_open_vw cp,
           brdg_cat_type_codes ctc_apptype,
           brdg_cred_work_history cwh,
           brdg_cred_history ch,
           brdg_providers p
    WHERE cp.type_cd_ctc_id = ctc_apptype.cat_type_code_id
       AND ctc_apptype.category_cd = 'CRED'
       AND ctc_apptype.type_cd = 'APPTYPE'
       AND cp.cred_process_id = cwh.cred_process_id (+)
       AND cwh.primary_practice_flag (+) = 'Y'
       AND cp.cred_process_id = ch.cred_process_id
       AND ch.cred_history_id = (SELECT MAX(cred_history_id)
                                   FROM brdg_cred_history
                                  WHERE cred_process_id = cp.cred_process_id
                                    AND event_cd_ctc_id = brdg_credentialing.get_event_ctc_id ('SEVENT','SPESTCHG'))
       AND cp.provider_id = p.provider_id (+)
       and brdg_credentialing.get_appl_specialist_id(cp.cred_process_id) = 5
    ORDER BY 3 ASC, 3, 5, 12, 6
            Explain Plan Operation
    ID   PID    Card     Rows    Cost      SearchCols  /   Indexed Cols     Predicates 
    0:    1                       36   SELECT STATEMENT   
    1:    0     1       139       36    SORT ORDER BY   
    2:    1             139            . FILTER   [+]  
    3:    2     1       311       11   .. NESTED LOOPS OUTER   
    4:    3     1       311       10   ... NESTED LOOPS OUTER   
    5:    4     1       311        9   .... NESTED LOOPS   
    6:    5     1       311        8   ....+ NESTED LOOPS   
    7:    6     4        16        1   ....+. TABLE ACCESS BY INDEX ROWID CAT_TYPE_CODES   
    8:    7     4        16        1   ....+.. INDEX RANGE SCAN CAT_TYPE_CODE_UK 2/3 [+]   [+]  
    9:    6     1       311        2   ....+. TABLE ACCESS BY INDEX ROWID CRED_PROCESSES   [+]  
    10:    9   183     61927        1   ....+.. INDEX RANGE SCAN CDPR_CTCD_FK1 1/1 [+]   [+]  
    11:   10     1         3        2   ....+... NESTED LOOPS   
    12:   11     1        16        1   ....+.... TABLE ACCESS BY INDEX ROWID CAT_TYPE_CODES   
    13:   12     1        16        1   ....+....+ INDEX UNIQUE SCAN CTCD_PK 1/1 [+]   [+]  
    14:   11     1         3        1   ....+.... INDEX UNIQUE SCAN CAT_TYPE_CODE_UK 3/3 [+]   [+]  
    15:    5     1        11        1   ....+ TABLE ACCESS BY INDEX ROWID CRED_HISTORY   [+]  
    16:   15     1       311        1   ....+. INDEX UNIQUE SCAN CDHT_PK 1/1 [+]   [+]  
    17:   16     1       311            ....+.. SORT AGGREGATE   
    18:   17     1       526        2   ....+... TABLE ACCESS BY INDEX ROWID CRED_HISTORY   [+]  
    19:   18    23      9950        1   ....+.... INDEX RANGE SCAN CDHT_CDPR_FK 1/1 [+]   [+]  
    20:    4     1       219        1   .... TABLE ACCESS BY INDEX ROWID PROVIDERS   
    21:   20     1       219        1   ....+ INDEX UNIQUE SCAN PROV_PK 1/1 [+]  [+]  
    22:    3     1       311        1   ... TABLE ACCESS BY INDEX ROWID CRED_WORK_HISTORY   [+] 
    23:   22     3      1057        1   .... INDEX RANGE SCAN CDWH_CDPR_FK 1/1 [+]   [+]  
    24:    2   172                      .. INLIST ITERATOR   
    25:   24     1       172        1   ... INDEX UNIQUE SCAN CAT_TYPE_CODE_UK 3/3 [+]   [+]  
    26:    2     1         0        2   .. TABLE ACCESS BY INDEX ROWID CRED_HISTORY   [+]  
    27:   26    23      2004        1   ... INDEX RANGE SCAN CDHT_CDPR_FK 1/1 [+]   [+]  
    (1) X/Y: Where X is the number of searched columns from index, which has a total of Y columns.
    (2) Actual rows returned by operation (average if there were more than 1 execution).
       2 - filter( NOT EXISTS (SELECT 0 FROM "PPO"."CAT_TYPE_CODES" "BRDG_CAT_TYPE_CODES" WHERE
                  "CODE"="BRDG_CODE_UTIL"."ID_CODE"("BRDG_CREDENTIALING"."GET_APPL_STATUS_CD_CTC_ID"(:B1)) AND
                  ("TYPE_CD"='APPROVAL' OR "TYPE_CD"='DENIED' OR "TYPE_CD"='INACTIVE' OR "TYPE_CD"='TERMED') AND
                  "CATEGORY_CD"='APPSTAT') AND  NOT EXISTS (SELECT 0 FROM "PPO"."CRED_HISTORY" "BRDG_CRED_HISTORY"
                  WHERE "CRED_PROCESS_ID"=:B2 AND "EVENT_CD_CTC_ID"="BRDG_CODE_UTIL"."GET_ID"('CRED','SEVENT','MSODC
       8 - access("CTC_APPTYPE"."CATEGORY_CD"='CRED' AND "CTC_APPTYPE"."TYPE_CD"='APPTYPE')
       9 - filter("BRDG_CREDENTIALING"."GET_APPL_SPECIALIST_ID"("CP"."CRED_PROCESS_ID")=5 AND
                  ("CP"."INS_DT">=TO_DATE(' 2007-12-20 17:00:00', 'syyyy-mm-dd hh24:mi:ss') OR
                  "CP"."TYPE_CD_CTC_ID"<>"BRDG_CODE_UTIL"."GET_ID"('CRED','APPTYPE','RECPPO')))
      10 - access("CP"."TYPE_CD_CTC_ID"="CTC_APPTYPE"."CAT_TYPE_CODE_ID")
           filter( NOT EXISTS (SELECT 0 FROM "PPO"."CAT_TYPE_CODES"
                  "CTC_APPTYPE","PPO"."CAT_TYPE_CODES" "CTC_TYPE" WHERE "CTC_TYPE"."CAT_TYPE_CODE_ID"=:B1 AND
                  "CTC_TYPE"."CODE"="CTC_APPTYPE"."CODE" AND "CTC_APPTYPE"."TYPE_CD"='APPSENT' AND
                  "CTC_APPTYPE"."CATEGORY_CD"='APPTYPE'))
      13 - access("CTC_TYPE"."CAT_TYPE_CODE_ID"=:B1)
      14 - access("CTC_APPTYPE"."CATEGORY_CD"='APPTYPE' AND "CTC_APPTYPE"."TYPE_CD"='APPSENT' AND
                  "CTC_TYPE"."CODE"="CTC_APPTYPE"."CODE")
      15 - filter("CP"."CRED_PROCESS_ID"="CH"."CRED_PROCESS_ID")
      16 - access("CH"."CRED_HISTORY_ID"= (SELECT MAX("CRED_HISTORY_ID") FROM "PPO"."CRED_HISTORY"
                  "BRDG_CRED_HISTORY" WHERE "CRED_PROCESS_ID"=:B1 AND
                  "EVENT_CD_CTC_ID"="BRDG_CREDENTIALING"."GET_EVENT_CTC_ID"('SEVENT','SPESTCHG')))
      18 - filter("EVENT_CD_CTC_ID"="BRDG_CREDENTIALING"."GET_EVENT_CTC_ID"('SEVENT','SPESTCHG'))
      19 - access("CRED_PROCESS_ID"=:B1)
      21 - access("CP"."PROVIDER_ID"="P"."PROVIDER_ID"(+))
      22 - filter("CWH"."PRIMARY_PRACTICE_FLAG"(+)='Y')
      23 - access("CP"."CRED_PROCESS_ID"="CWH"."CRED_PROCESS_ID"(+))
      25 - access("CATEGORY_CD"='APPSTAT' AND ("TYPE_CD"='APPROVAL' OR "TYPE_CD"='DENIED' OR
                  "TYPE_CD"='INACTIVE' OR "TYPE_CD"='TERMED') AND "CODE"="BRDG_CODE_UTIL"."ID_CODE"("BRDG_CREDENTIAL
                  ING"."GET_APPL_STATUS_CD_CTC_ID"(:B1)))
      26 - filter("EVENT_CD_CTC_ID"="BRDG_CODE_UTIL"."GET_ID"('CRED','SEVENT','MSODC'))
      27 - access("CRED_PROCESS_ID"=:B1)

    Welcome to the forums!
    user11987210 wrote:
    In the explain plan I don't understand what's happining at line ID 10 and 11. Specifically, is the result at line 11 rowids from lines 12 & 14? and then what? Are those rowids somehow used in line ID 10?
    9:    6     1       311        2   ....+. TABLE ACCESS BY INDEX ROWID CRED_PROCESSES   [+]  
    10:    9   183     61927        1   ....+.. INDEX RANGE SCAN CDPR_CTCD_FK1 1/1 [+]   [+]  
    11:   10     1         3        2   ....+... NESTED LOOPS   
    12:   11     1        16        1   ....+.... TABLE ACCESS BY INDEX ROWID CAT_TYPE_CODES   
    13:   12     1        16        1   ....+....+ INDEX UNIQUE SCAN CTCD_PK 1/1 [+]   [+]  
    14:   11     1         3        1   ....+.... INDEX UNIQUE SCAN CAT_TYPE_CODE_UK 3/3 [+]   [+]   The NESTED LOOPS operation (ID #11) has two children, ID #12 sometimes called the driving source, and ID #14 the inner loop. ID #14 is executed once for each row returned by ID #12. The results of ID #11 are then fed to ID #10 which performs an INDEX RANGE SCAN.
    Hope this helps!

  • A question about explain plan

    here is my sql statement and running result:
    SQL> @bind_variables_peeking_test.sql
    SQL> SET ECHO OFF
    SQL>
    SQL> REM
    SQL> REM Setup test environment
    SQL> REM
    SQL>
    SQL> ALTER SYSTEM FLUSH SHARED_POOL;
    SQL>
    SQL> DROP TABLE t;
    DROP TABLE t
    ERROR at line 1:
    ORA-00942: table or view does not exist
    SQL>
    SQL> CREATE TABLE t
    2 AS
    3 SELECT rownum AS id
    4 FROM dual
    5 CONNECT BY level <= 1000;
    SQL>
    SQL> execute dbms_stats.gather_table_stats(ownname=>user, tabname=>'t');
    SQL> SELECT count(id), count(DISTINCT id), min(id), max(id) FROM t;
    COUNT(ID) COUNT(DISTINCTID) MIN(ID) MAX(ID)
    1000 1000 1 1000
    SQL>
    SQL> PAUSE
    SQL>
    SQL> REM
    SQL> REM Without bind variables different execution plans are used if the value
    SQL> REM used in the WHERE clause change. This is because the query optimizer
    SQL> REM recognize the different selectivity of the two predicates.
    SQL> REM
    SQL>
    SQL> SELECT count(*) FROM t WHERE id < 990;
    COUNT(*)
    989
    SQL>
    SQL> SELECT * FROM table(dbms_xplan.display_cursor(NULL, NULL, 'typical'));
    PLAN_TABLE_OUTPUT
    SQL_ID bspfffaycy92u, child number 0
    SELECT count(*) FROM t WHERE id < 990
    Plan hash value: 2966233522
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | | | 3 (100)| |
    | 1 | SORT AGGREGATE | | 1 | 3 | | |
    |* 2 | TABLE ACCESS FULL| T | 990 | 2970 | 3 (0)| 00:00:01 |
    Predicate Information (identified by operation id):
    2 - filter("ID"<990)
    SQL>
    SQL> PAUSE
    SQL>
    SQL> SELECT count(*) FROM t WHERE id < 10;
    COUNT(*)
    9
    SQL>
    SQL> SELECT * FROM table(dbms_xplan.display_cursor(NULL, NULL, 'typical'));
    PLAN_TABLE_OUTPUT
    SQL_ID 4xfxt0frkj40y, child number 0
    SELECT count(*) FROM t WHERE id < 10
    Plan hash value: 2966233522
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | | | 3 (100)| |
    | 1 | SORT AGGREGATE | | 1 | 3 | | |
    |* 2 | TABLE ACCESS FULL| T | 9 | 27 | 3 (0)| 00:00:01 |
    Predicate Information (identified by operation id):
    2 - filter("ID"<10)
    SQL>
    SQL> PAUSE
    SQL>
    SQL> REM
    SQL> REM With bind variables the same execution plan is used. Depending on the
    SQL> REM peeked value (10 or 990), a full table scan or an index range scan is used.
    SQL> REM
    SQL>
    SQL> EXECUTE :id := 10;
    SQL>
    SQL> SELECT count(*) FROM t WHERE id < :id;
    COUNT(*)
    9
    SQL>
    SQL> SELECT * FROM table(dbms_xplan.display_cursor(NULL, NULL, 'typical'));
    PLAN_TABLE_OUTPUT
    SQL_ID dkva59ypaxa6w, child number 0
    SELECT count(*) FROM t WHERE id < :id
    Plan hash value: 2966233522
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | | | 3 (100)| |
    | 1 | SORT AGGREGATE | | 1 | 3 | | |
    |* 2 | TABLE ACCESS FULL| T | 9 | 27 | 3 (0)| 00:00:01 |
    Predicate Information (identified by operation id):
    2 - filter("ID"<:ID)
    SQL>
    SQL> PAUSE
    SQL>
    SQL> EXECUTE :id := 10;
    SQL>
    SQL> SELECT count(*) FROM t WHERE id < :id;
    COUNT(*)
    9
    SQL>
    SQL> SELECT * FROM table(dbms_xplan.display_cursor(NULL, NULL, 'typical'));
    PLAN_TABLE_OUTPUT
    SQL_ID dkva59ypaxa6w, child number 0
    SELECT count(*) FROM t WHERE id < :id
    Plan hash value: 2966233522
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | | | 3 (100)| |
    | 1 | SORT AGGREGATE | | 1 | 3 | | |
    |* 2 | TABLE ACCESS FULL| T | 9 | 27 | 3 (0)| 00:00:01 |
    Predicate Information (identified by operation id):
    2 - filter("ID"<:ID)
    SQL>
    SQL> PAUSE
    SQL>
    SQL> ALTER SYSTEM FLUSH SHARED_POOL;
    SQL>
    SQL> PAUSE
    SQL>
    SQL> EXECUTE :id := 10;
    SQL> SELECT count(*) FROM t WHERE id < :id;
    COUNT(*)
    9
    SQL> explain plan for SELECT count(*) FROM t WHERE id < :id;
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 2966233522
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 1 | 3 | 3 (0)| 00:00:01 |
    | 1 | SORT AGGREGATE | | 1 | 3 | | |
    |* 2 | TABLE ACCESS FULL| T | 50 | 150 | 3 (0)| 00:00:01 |
    Predicate Information (identified by operation id):
    2 - filter("ID"<TO_NUMBER(:ID))
    SQL>
    SQL> ALTER SYSTEM FLUSH SHARED_POOL;
    SQL> PAUSE
    SQL>
    SQL> EXECUTE :id := 10;
    SQL>
    SQL> SELECT count(*) FROM t WHERE id < :id;
    COUNT(*)
    9
    SQL>
    SQL> SELECT * FROM table(dbms_xplan.display_cursor(NULL, NULL, 'typical'));
    PLAN_TABLE_OUTPUT
    SQL_ID dkva59ypaxa6w, child number 0
    SELECT count(*) FROM t WHERE id < :id
    Plan hash value: 2966233522
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | | | 3 (100)| |
    | 1 | SORT AGGREGATE | | 1 | 3 | | |
    |* 2 | TABLE ACCESS FULL| T | 9 | 27 | 3 (0)| 00:00:01 |
    Predicate Information (identified by operation id):
    2 - filter("ID"<:ID)
    SQL>
    SQL>
    SQL> PAUSE
    SQL>
    SQL> REM
    SQL> REM Cleanup
    SQL> REM
    SQL>
    SQL> UNDEFINE sql_id
    SQL>
    SQL> DROP TABLE t;
    SQL> PURGE TABLE t;
    SQL>
    SQL> spool off;
    please noticed the last two explain plan result,one sql statement but have two result,why?

    what do you mean "invalidated the previous plan"?
    i gather the table statistics information once.
    every time before i run the statement and explain plan, i flush share pool to make sure there are not execution plan to reused.
    so i think i do not invalidated the previous plan and the two result should be same.

  • Explain plan output  for a sql in JSP page

    Hello all,
    I have a requirement to give SQL query as an input and get the output and explain plan in the same JSP page. i could get the SQL result, but i want to get the EXPLAIN Plan.
    can any one help me in this.
    Thanks
    Kiran

    Hello all,
    I have a requirement to give SQL query as an input and get the output and explain plan in the same JSP page. i could get the SQL result, but i want to get the EXPLAIN Plan.
    can any one help me in this.
    Thanks
    Kiran

  • Statspack with explain plan.

    The goal is to obtain the overall system statistics and explain plans for the entire system.
    1. The only tool that I can think of is "StatsPack".
    2. With AWR there are 2 issues:-
    a. It is not free
    b. It does not give Explain plan output.
    3. We can use 10046 / 10053 Trace's however it wont give you as comphrehensive an output as statspack, you would also have to enable trace for each individual application while its running, grab the trace file, look at the report.
    4. We can also use outlines to store the explain plan this was primarily for Oracle version 10g.
    5. The last option we have is sql managed baselines. This is good , however it does not tell me conclusively how my system was executing a sql lets say 10 days back. It wont accept the new sql unless we promote it. Still there is no guarantee that the underlying sql plan will not change.
    So far statspack with level 6 appears to be the only solution.

    Personally I'd spend the money and get AWR.
    The problem with StatsPack is that when you run it, after an issue, it is too late to capture anything of value. With AWR snapshots are taken as often as you wish, 24 hours a day, and then when someone tells you there was a problem at 4:15 in the morning ... you have something to work with.

  • EXPLAIN PLANS

    Hi,
    There are two procedures with similar sql statements hitting the same set of tables.The queries are almost similar with slight modifications.One procedure is taking 2 hours to complete whereas the other is taking 5 minutes to complete.The explain plans are different for each of these sql statements.Is there a way where i can force the first procedure to use the same explain plan as that of the other sql statement present in the other procedure.Is there a way to tell the optimiser to use the same execution plan as that of the other ?
    database version 10.2.0.3
    Edited by: user589320 on Feb 11, 2009 12:30 PM

    The queries are almost similar Therein lies the difference.
    (you'll need to post the queries and explain plans)

  • Explain plan output format

    Dear All,
    Please let me know how to publish my explain plan output properly here. Earlier i used [code]  .....  [/code]
    Thanks,
    Kods

    Who knows?
    Are you just looking at random explain plans to find a problem?
    Or did you look at the explain plan for a specific performance problem?
    Please format code and explain plan output with code tags.
    See also this thread, How to post a SQL tuning request:
    HOW TO: Post a SQL statement tuning request - template posting
    At the end of the day are the row estimates accurate?
    If they are, then everything's probably ok.
    If not, then everything might be ok or it might not be.
    Merge Join Cartesian + Buffer Sort operations are often, but not always, an indication of a problem particularly when the associated estimates are inaccurate for whatever reason.

Maybe you are looking for

  • Why not use the MS works calendar?

    I'm a little confused as to why I can sync my contacts with MS Works, but I cant sync my calendar with MS Works. I understand the iphone doesnt support this, but why? Life would have been so much simpler if I had both my contacts and calendar staring

  • Sales Order Loading Date and Goods Issue Date

    I am getting confused with specific sales orders in our system which have a loading date of 5.11.2008 00:00 and a goods issue of 6.11.2008 00:00, this would imply a loading time of 1 day, I would think. However in our system I look at the shipping po

  • Reg : Unable to open the PDF when opening Notification documents

    Hi All, I used QM03 and then I type in a notification number and then I hit return I get a series of screens and then I click on documents.  I then get to the document tree and then open the RPC file.  from that I get a pdf file.  I click open but I

  • How to make PDF documents that open in Adobe reader open in Preview

    How do I make PDF documents that open in Adobe Acrobat open in Preview?

  • ERROR when using Integration Monitoring FOR XI

    Hello every,after install xi and update the patch to last.when I open  Integration Monitoring web page and use xisuper to login. as soon as i click the Component Monitoring or Message Monitoring  the system tell me that Following error occurred while