Dbms_xplan.diff_plan_awr

Anyone had any luck running this on 11.2 (it is a new feature) ?
I first found you cannot do a
select dbms_xplan.diff_plan_awr('xxx',11,22) from dual;
ERROR at line 1:
ORA-14552: cannot perform a DDL, commit or rollback inside a query or DML
ORA-06512: at "SYS.PRVT_ADVISOR", line 4820
ORA-14551: cannot perform a DML operation inside a query
ORA-06512: at "SYS.DBMS_SQLTUNE_INTERNAL", line 7603
ORA-06512: at "SYS.PRVT_SQLADV_INFRA", line 40
ORA-06512: at "SYS.DBMS_XPLAN", line 6741
ORA-06512: at "SYS.DBMS_XPLAN", line 6927
Then I tried
declare statement_diff varchar2(4000);
begin
statement_diff:= dbms_xplan.diff_plan_awr('xx',11,22) ;
--dbms_output.put_line(statement_diff);
end;
and I get
ERROR at line 1:
ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00214: CDATA section did not end in "]]>"
ORA-06512: at "SYS.PRVT_ADVISOR", line 2693
ORA-06512: at "SYS.DBMS_ADVISOR", line 241
ORA-06512: at "SYS.DBMS_SQLDIAG", line 986
ORA-06512: at "SYS.DBMS_XPLAN", line 6114
ORA-06512: at "SYS.DBMS_XPLAN", line 6938
ORA-06512: at line 4

Here is my actual example (I try not to post "real" information, but sql_id's are kind of generic anyway).
declare statement_diff varchar2(4000);
begin
statement_diff:= dbms_xplan.diff_plan_awr('9t8g4ya227qv4',3439270568,1447207991) ;
--dbms_output.put_line(statement_diff);
end;
I did notice that when there is no data it comes back with 0 rows.. It only get's an error when it executes and finds data.

Similar Messages

  • Is "A-Time" column in dbms_xplan.display_cursor summarized ?

    Hello,
    I did some research on the internet before posting this but I could find sufficient information.
    Is "A-Time" column in dbms_xplan.display_cursor summarized ?
    | Id  | Operation                                                    | Name                           | Starts | E-Rows | A-Rows |   A-Time   | Buffers | Reads  |  OMem |  1Mem | Used-Mem |
    |   0 | SELECT STATEMENT                                             |                                |      1 |        |    155 |00:06:36.28 |    4957K|  34952 |       |       |          |
    |   1 |  SORT ORDER BY                                               |                                |      1 |      1 |    155 |00:06:36.28 |    4957K|  34952 | 55296 | 55296 |49152  (0)|
    |   2 |   NESTED LOOPS                                               |                                |      1 |      1 |    155 |00:06:30.04 |    4957K|  34952 |       |       |          |
    |   3 |    NESTED LOOPS                                              |                                |      1 |      1 |    155 |00:06:30.04 |    4957K|  34952 |       |       |          |
    |   4 |     NESTED LOOPS                                             |                                |      1 |      1 |    155 |00:06:30.04 |    4957K|  34952 |       |       |          |
    |   5 |      NESTED LOOPS                                            |                                |      1 |      1 |    155 |00:06:30.04 |    4956K|  34952 |       |       |          |
    |   6 |       NESTED LOOPS                                           |                                |      1 |      1 |    155 |00:06:30.04 |    4956K|  34952 |       |       |          |
    |   7 |        NESTED LOOPS                                          |                                |      1 |      1 |    155 |00:06:30.03 |    4956K|  34952 |       |       |          |
    |   8 |         NESTED LOOPS                                         |                                |      1 |      1 |    155 |00:06:30.03 |    4956K|  34952 |       |       |          |
    |   9 |          NESTED LOOPS                                        |                                |      1 |      1 |    155 |00:06:30.03 |    4956K|  34952 |       |       |          |
    |  10 |           NESTED LOOPS                                       |                                |      1 |      1 |    155 |00:06:30.03 |    4955K|  34952 |       |       |          |
    |  11 |            NESTED LOOPS                                      |                                |      1 |      1 |    155 |00:06:30.03 |    4955K|  34952 |       |       |          |
    |  12 |             NESTED LOOPS                                     |                                |      1 |      1 |    155 |00:06:30.03 |    4955K|  34952 |       |       |          |
    |  13 |              NESTED LOOPS                                    |                                |      1 |      1 |    155 |00:06:30.03 |    4954K|  34952 |       |       |          |
    |* 14 |               HASH JOIN                                      |                                |      1 |      1 |    155 |00:06:30.03 |    4954K|  34952 |   872K|   872K|  927K (0)|
    |  15 |                VIEW                                          |                                |      1 |     15 |      8 |00:06:28.63 |    1305K|  34883 |       |       |          |
    |* 16 |                 FILTER                                       |                                |      1 |        |      8 |00:06:28.63 |    1305K|  34883 |       |       |          |
    |  17 |                  HASH GROUP BY                               |                                |      1 |     15 |      8 |00:06:28.63 |    1305K|  34883 |   760K|   760K| 1077K (0)|
    |  18 |                   VIEW                                       |                                |      1 |     15 |    341 |00:00:50.44 |    1305K|  34883 |       |       |          |
    |  19 |                    UNION-ALL                                 |                                |      1 |        |    341 |00:00:50.44 |    1305K|  34883 |       |       |          |
    |  20 |                     VIEW                                     | V_POSNR_2011000           |      1 |      7 |    303 |00:00:50.44 |     645K|  31282 |       |       |          |
    |  21 |                      UNION-ALL                               |                                |      1 |        |    303 |00:00:50.44 |     645K|  31282 |       |       |          |
    |  22 |                       VIEW                                   | V_POSNR_0200011           |      1 |      2 |     20 |00:00:50.42 |     429K|  31244 |       |       |          |
    |  23 |                        UNION-ALL                             |                                |      1 |        |     20 |00:00:50.42 |     429K|  31244 |       |       |          |
    |  24 |                         NESTED LOOPS                         |                                |      1 |      1 |     20 |00:00:50.42 |     376K|  28979 |       |       |          |
    |* 25 |                          HASH JOIN                           |                                |      1 |      1 |     20 |00:00:50.42 |     376K|  28979 |  1096K|  1096K| 1348K (0)|
    |* 26 |                           TABLE ACCESS BY INDEX ROWID        | PROPERTIES                     |      1 |      6 |   2651 |00:00:00.02 |    2131 |      0 |       |       |          |
    |* 27 |                            INDEX RANGE SCAN                  | P_SETAALDATE_IDX               |      1 |      6 |   2651 |00:00:00.01 |      21 |      0 |       |       |          |
    |  28 |                           VIEW                               | VW_JF_SET$7992605D             |      1 |      2 |    504 |00:02:30.85 |     374K|  28979 |       |       |          |
    |  29 |                            UNION-ALL                         |                                |      1 |        |    504 |00:02:30.85 |     374K|  28979 |       |       |          |( hope this execution plan is reasonably readable )
    I've been thinking the A-Time Columns shows the time of the particular Operation ( summarizing all time from child operations )
    but this seems different:
    |* 25 |                          HASH JOIN                           |                                |      1 |      1 |     20 |00:00:50.42 |     376K|  28979 |  1096K|  1096K| 1348K (0)|
    |* 26 |                           TABLE ACCESS BY INDEX ROWID        | PROPERTIES                     |      1 |      6 |   2651 |00:00:00.02 |    2131 |      0 |       |       |          |
    |* 27 |                            INDEX RANGE SCAN                  | P_SETAALDATE_IDX               |      1 |      6 |   2651 |00:00:00.01 |      21 |      0 |       |       |          |
    |  28 |                           VIEW                               | VW_JF_SET$7992605D             |      1 |      2 |    504 |00:02:30.85 |     374K|  28979 |       |       |          |The line 25 is a HASH JOIN comprising a (1) tableTABLE ACCESS BY INDEX ROWID and (2) the result from a VIEW
    The Timing of the HASH JOIN (line 25) is 00:00:50.42 but the timing for the VIEW is 00:02:30.85 which would both have to complete before hashing can occur
    So I was thinking the HASH JOIN would (at least) have a timing of the 00:02:30.85 from the VIEW plus the 00:00:00.02 from the TABLE ACCESS BY INDEX ROWID.
    But it seems this is a misconception , can someone shed some light on this ?
    best regards
    Edited by: x45r32 on Apr 4, 2012 8:25 AM
    Edited by: x45r32 on Apr 4, 2012 8:46 AM

    x45r32 wrote:
    First please use codes like in sarting of explain plan and at end put the same.
    I've been thinking the A-Time Columns shows the time of the particular Operation ( summarizing all time from child operations )
    Yes its related to time a operation takes.
    but this seems different:
    |* 25 | HASH JOIN | | 1 | 1 | 20 |00:00:50.42 | 376K| 28979 | 1096K| 1096K| 1348K (0)|
    |* 26 | TABLE ACCESS BY INDEX ROWID | PROPERTIES | 1 | 6 | 2651 |00:00:00.02 | 2131 | 0 | | | |
    |* 27 | INDEX RANGE SCAN | P_SETAALDATE_IDX | 1 | 6 | 2651 |00:00:00.01 | 21 | 0 | | | |
    | 28 | VIEW | VW_JF_SET$7992605D | 1 | 2 | 504 |00:02:30.85 | 374K| 28979 | | | |
    The line 25 is a HASH JOIN comprising a (1) tableTABLE ACCESS BY INDEX ROWID and (2) the result from a VIEW
    The Timing of the HASH JOIN (line 25) is 00:00:50.42 but the timing for the VIEW is 00:02:30.85 which would both have to complete before hashing can occur
    So I was thinking the HASH JOIN would at least take the 00:02:30.85 from the VIEW plus the 00:00:00.02 from the TABLE ACCESS BY INDEX ROWID.
    Why do you think like that? HASH JOIN has occured from output result set from View and Index range scan. So building a hash function of output of these is not likely to take the same time i.e 2:30:85, hash join is other set of operation which took place from result set.
    But it seems this is a misconception , can someone shed some light in this ?
    More importantly i could see that there is difference between A-rows and E-rows from sarting of explain plan
    Optimizer thinks that actual cardinality would be 1(During estimation phase) but on real execution optimizer gave 6 cardinality(during run time), this operation is INDEX RANGE SCAN on P_SETAALDATE_IDX. I think due to this mismatch at starting, optimizer has drifted a little and gave wrong estimaition. So consider fixng this first and them move on.
    Please check if optimizer stats are upto date espacially on index P_SETAALDATE_IDX
    I hope this help                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Using DBMS_XPLAN in version 2.1

    Hello,
    I'm using SQL Developer for a long time now. Especially with the 1.5 versions, the following script worked like a charm.
    set timing on;
    set serveroutput off;
    set termout off;
    select /*+ gather_plan_statistics */ * from emp;
    set termout on;
    select * from table(dbms_xplan.display_cursor(null,null,'COST IOSTATS LAST'));
    Quick explanation:
    Running a SELECT with suppressed output, and giving back its execution plan (from the "current cursor") in a nice ASCII art table.
    My problem now: Running with version 2.1 of SQL Developer, the current cursor is something entirely different, the dbms_xplan package complains:
    cannot fetch plan for SQL_ID: 8kfd4vsgdvxuh, CHILD_NUMBER:1 Please verify value of SQL_ID and CHILD_NUMBER;
    It could also be that the plan is no longer in cursor cache (check v$sql_plan)
    SQL ID 8kfd4vsgdvxuh is this:
    declare
    l_line varchar2(32767);
    l_done number;
    l_buffer varchar2(32767) := '';
    l_lengthbuffer number := 0;
    l_lengthline number := 0;
    begin
    loop
    dbms_output.get_line(
    l_line,l_done);
    if (l_buffer is null) then
    l_lengthbuffer := 0;
    else
    l_lengthbuffer := length(l_buffer);
    end if;
    if (l_line is null)
    then l_lengthline := 0;
    else l_lengthline := length(l_line);
    end if;
    exit when l_lengthbuffer + l_lengthline > :maxbytes
    OR l_lengthbuffer + l_lengthline > 32767
    OR l_done = 1;
    l_buffer := l_buffer || l_line || chr(10);
    end loop;
    :done := l_done;
    :buffer := l_buffer;
    :line := l_line;
    end;
    I think this is something caused by the table() keyword, but I'm not sure.
    Where comes the difference from? 1.5 has had similar problems, but there "set serveroutput off;" helped to avoid it.
    What can I do in 2.1 to make this approach work?
    Thanks a lot
    Martin Klier

    You should be able to get an execution plan using EXPLAIN PLAN - that's what its for. the old way to get execution plans manually
    The idea is to try it manaully: do EXPLAIN PLAN in your work window, then execute dbms_xplan manually Something like
    in command pane
    explain plan for select * from dual;
    select * from table(dbms_xplan.display)in output pane
    Plan hash value: 272002086
    | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |      |     1 |     2 |     2   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS FULL| DUAL |     1 |     2 |     2   (0)| 00:00:01 |
    --------------------------------------------------------------------------

  • Gather_Plan_Statistics + DBMS_XPLAN A-rows for parallel queries

    Looks like gather_plan_statistics + dbms_xplan displays incorrect A-rows for parallel queries. Is there any way to get the correct A-rows for a parallel query?
    Version details:
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bi on HPUX
    Create test tables:
    -- Account table
    create table test_tacprof
    parallel (degree 2) as
    select object_id ac_nr,
           object_name ac_na
    from all_objects;      
    alter table test_tacprof add constraint test_tacprof_pk primary key (ac_nr);
    -- Account revenue table
    create table test_taccrev
    parallel (degree 2) as
    select apf.ac_nr         ac_nr,
           fiv.r             tm_prd,
           apf.ac_nr * fiv.r ac_rev
    from   (select rownum r from all_objects where rownum <= 5) fiv,
           test_tacprof apf;
    alter table test_taccrev add constraint test_taccrev_pk primary key (ac_nr, tm_prd);
    -- Table to hold query results
    create table test_4accrev as
    select apf.ac_nr, apf.ac_na, rev.tm_prd, rev.ac_rev
    from test_taccrev rev,
         test_tacprof apf
    where 1=2;
    Run query with parallel dml/query disabled:
    ALTER SESSION DISABLE PARALLEL QUERY;
    ALTER SESSION DISABLE PARALLEL DML;
    INSERT INTO test_4accrev
       SELECT /*+ gather_plan_statistics */
              apf.ac_nr,
              apf.ac_na,
              rev.tm_prd,
              rev.ac_rev
         FROM test_taccrev rev, test_tacprof apf
        WHERE apf.ac_nr = rev.ac_nr AND tm_prd = 4;
    SELECT *
      FROM TABLE (DBMS_XPLAN.display_cursor (NULL, NULL, 'ALLSTATS LAST'));
    | Id  | Operation          | Name         | Starts | E-Rows | A-Rows |   A-Time   | Buffers |  OMem |  1Mem | Use
    |*  1 |  HASH JOIN         |              |      1 |  30442 |  23412 |00:00:00.27 |     772 |  1810K|  1380K| 2949K (0)|
    |   2 |   TABLE ACCESS FULL| TEST_TACPROF |      1 |  26050 |  23412 |00:00:00.01 |     258 |       |       |    
    |*  3 |   TABLE ACCESS FULL| TEST_TACCREV |      1 |  30441 |  23412 |00:00:00.03 |     514 |       |       |    
    ROLLBACK ;
    A-rows are correctly reported with no parallel.
    Run query with parallel dml/query enabled:
    ALTER SESSION enable PARALLEL QUERY;
    alter session enable parallel dml;
    insert into test_4accrev
    select /*+ gather_plan_statistics */ apf.ac_nr, apf.ac_na, rev.tm_prd, rev.ac_rev
    from test_taccrev rev,
         test_tacprof apf
    where apf.ac_nr = rev.ac_nr
    and   tm_prd = 4;    
    select * from table(dbms_xplan.display_cursor(null,null,'ALLSTATS LAST'));                
    | Id  | Operation                | Name         | Starts | E-Rows | A-Rows |   A-Time   | Buffers |  OMem |  1Mem | Used-M
    |   1 |  PX COORDINATOR          |              |      1 |        |  23412 |00:00:00.79 |       6 |       |       |          |
    |   2 |   PX SEND QC (RANDOM)    | :TQ10001     |      0 |  30442 |      0 |00:00:00.01 |       0 |       |       |          |
    |*  3 |    HASH JOIN             |              |      0 |  30442 |      0 |00:00:00.01 |       0 |  2825K|  1131K|          |
    |   4 |     PX BLOCK ITERATOR    |              |      0 |  30441 |     0 |00:00:00.01 |       0 |       |       |          |
    |*  5 |      TABLE ACCESS FULL   | TEST_TACCREV |      0 |  30441 |      0 |00:00:00.01 |       0 |       |       |       
    |   6 |     BUFFER SORT          |              |      0 |        |      0 |00:00:00.01 |       0 | 73728 | 73728 |          |
    |   7 |      PX RECEIVE          |              |      0 |  26050 |      0 |00:00:00.01 |       0 |       |       |          |
    |   8 |       PX SEND BROADCAST  | :TQ10000     |      0 |  26050 |      0 |00:00:00.01 |       0 |       |       |          |
    |   9 |        PX BLOCK ITERATOR |              |      0 |  26050 |      0 |00:00:00.01 |       0 |       |       |          |
    |* 10 |         TABLE ACCESS FULL| TEST_TACPROF |      0 |  26050 |      0 |00:00:00.01 |       0 |       |       |          |
    rollback;
    A-rows are zero execpt for final step.

    I'm sorry for posting following long test case.
    But it's the most convenient way to explain something. :-)
    Here is my test case, which is quite similar to yours.
    Note on the difference between "parallel select" and "parallel dml(insert here)".
    (I know that Oracle implemented psc(parallel single cursor) model in 10g, but the details of the implementation is quite in mystery as Jonathan said... )
    SQL> select * from v$version;
    BANNER                                                                         
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod               
    PL/SQL Release 10.2.0.1.0 - Production                                         
    CORE     10.2.0.1.0     Production                                                     
    TNS for 32-bit Windows: Version 10.2.0.1.0 - Production                        
    NLSRTL Version 10.2.0.1.0 - Production                                         
    SQL>
    SQL> alter system flush shared_pool;
    System altered.
    SQL>
    SQL> alter table t parallel 4;
    Table altered.
    SQL>
    SQL> select /*+ gather_plan_statistics */ count(*) from t t1, t t2
      2  where t1.c1 = t2.c1 and rownum <= 1000
      3  order by t1.c2;
      COUNT(*)                                                                     
          1000                                                                     
    SQL>
    SQL> select sql_id from v$sqlarea
    where sql_text like 'select /*+ gather_plan_statistics */ count(*) from t t1, t t2%';
    SQL_ID                                                                         
    bx61bkyh9ffb6                                                                  
    SQL>
    SQL> select * from table(dbms_xplan.display_cursor('&sql_id',null,'allstats last'));
    Enter value for sql_id: bx61bkyh9ffb6
    PLAN_TABLE_OUTPUT                                                              
    SQL_ID  bx61bkyh9ffb6, child number 0          <-- Cooridnator and slaves shared the cursor                          
    select /*+ gather_plan_statistics */ count(*) from t t1, t t2 where t1.c1 = t2.c
    1 and rownum <= 1000 order by t1.c2                                            
    Plan hash value: 3015647771                                                    
    PLAN_TABLE_OUTPUT                                                              
    | Id  | Operation                  | Name     | Starts | E-Rows | A-Rows |   A-Time   | Buffers |  OMem |  1Mem | Used-Mem |                               
    |   1 |  SORT AGGREGATE            |          |      1 |      1 |      1 |00:00:00.62 |       6 |       |       |          |                                   
    |*  2 |   COUNT STOPKEY            |          |      1 |        |   1000 |00:00:00.62 |       6 |       |       |          |                                   
    |   3 |    PX COORDINATOR          |          |      1 |        |   1000 |00:00:00.50 |       6 |       |       |          |                                   
    |   4 |     PX SEND QC (RANDOM)    | :TQ10002 |      0 |     16M|      0 |00:00:00.01 |       0 |       |       |          |                                   
    |*  5 |      COUNT STOPKEY         |          |      0 |        |      0 |00:00:00.01 |       0 |       |       |          |                                   
    |*  6 |       HASH JOIN BUFFERED   |          |      0 |     16M|      0 |00:00:00.01 |       0 |  1285K|  1285K|  717K (0)|                                   
    |   7 |        PX RECEIVE          |          |      0 |  10000 |      0 |00:00:00.01 |       0 |       |       |          |                                   
    |   8 |         PX SEND HASH       | :TQ10000 |      0 |  10000 |      0 |00:00:00.01 |       0 |       |       |          |                                   
    |   9 |          PX BLOCK ITERATOR |          |      0 |  10000 |      0 |00:00:00.01 |       0 |       |       |          |                                   
    |* 10 |           TABLE ACCESS FULL| T        |      0 |  10000 |      0 |00:00:00.01 |       0 |       |       |          |                                   
    |  11 |        PX RECEIVE          |          |      0 |  10000 |      0 |00:00:00.01 |       0 |       |       |          |                                   
    |  12 |         PX SEND HASH       | :TQ10001 |      0 |  10000 |      0 |00:00:00.01 |       0 |       |       |          |                                   
    |  13 |          PX BLOCK ITERATOR |          |      0 |  10000 |      0 |00:00:00.01 |       0 |       |       |          |                                   
    |* 14 |           TABLE ACCESS FULL| T        |      0 |  10000 |      0 |00:00:00.01 |       0 |       |       |          |                                   
    38 rows selected.
    SQL>
    SQL> select sql_id, child_number, executions, px_servers_executions
      2  from v$sql where sql_id = '&sql_id';
    SQL_ID                                  CHILD_NUMBER EXECUTIONS                
    PX_SERVERS_EXECUTIONS                                                          
    bx61bkyh9ffb6                                      0          1                
                        8                                                          
    SQL>
    SQL> insert /*+ gather_plan_statistics */ into t select * from t;
    10000 rows created.
    SQL>
    SQL> select sql_id from v$sqlarea
    where sql_text like 'insert /*+ gather_plan_statistics */ into t select * from t%';
    SQL_ID                                                                         
    9dkmu9bdhg5h0                                                                  
    SQL>
    SQL> select * from table(dbms_xplan.display_cursor('&sql_id', null, 'allstats last'));
    Enter value for sql_id: 9dkmu9bdhg5h0
    PLAN_TABLE_OUTPUT                                                              
    SQL_ID  9dkmu9bdhg5h0, child number 0       <-- Coordinator Cursor                         
    insert /*+ gather_plan_statistics */ into t select * from t                    
    Plan hash value: 3050126167                                                    
    | Id  | Operation            | Name     | Starts | E-Rows | A-Rows |   A-Time   | Buffers |                                                                    
    |   1 |  PX COORDINATOR      |          |      1 |        |  10000 |00:00:00.20 |       3 |                                                                    
    |   2 |   PX SEND QC (RANDOM)| :TQ10000 |      0 |  10000 |      0 |00:00:00.01 |       0 |                                                                    
    |   3 |    PX BLOCK ITERATOR |          |      0 |  10000 |      0 |00:00:00.01 |       0 |                                                                    
    |*  4 |     TABLE ACCESS FULL| T        |      0 |  10000 |      0 |00:00:00.01 |       0 |                                                                    
    SQL_ID  9dkmu9bdhg5h0, child number 1        <-- Slave(s)
    insert /*+ gather_plan_statistics */ into t select * from t                    
    PLAN_TABLE_OUTPUT                                                              
    Plan hash value: 3050126167                                                    
    | Id  | Operation            | Name     | Starts | E-Rows | A-Rows |   A-Time  | Buffers |                                                                    
    |   1 |  PX COORDINATOR      |          |      0 |        |      0 |00:00:00.01 |       0 |                                                                    
    |   2 |   PX SEND QC (RANDOM)| :TQ10000 |      0 |  10000 |      0 |00:00:00.01 |       0 |                                                                    
    |   3 |    PX BLOCK ITERATOR |          |      1 |  10000 |   2628 |00:00:00.20 |      16 |                                                                    
    |*  4 |     TABLE ACCESS FULL| T        |      4 |  10000 |   2628 |00:00:00.02 |      16 |                                                                    
    SQL>
    SQL> select sql_id, child_number, executions, px_servers_executions
      2  from v$sql where sql_id = '&sql_id';  <-- 2 child cursors here
    SQL_ID                                  CHILD_NUMBER EXECUTIONS                
    PX_SERVERS_EXECUTIONS                                                          
    9dkmu9bdhg5h0                                      0          1                
                        0                                                          
    9dkmu9bdhg5h0                                      1          0                
                        4                                                          
    SQL>
    SQL> set serveroutput on
    -- check mismatch
    SQL> exec print_table('select * from v$sql_shared_cursor where sql_id = ''&sql_id''');
    Enter value for sql_id: 9dkmu9bdhg5h0
    SQL_ID                        : 9dkmu9bdhg5h0                                  
    ADDRESS                       : 6AD85A70                                       
    CHILD_ADDRESS                 : 6BA596A8                                       
    CHILD_NUMBER                  : 0                                              
    UNBOUND_CURSOR                : N                                              
    SQL_TYPE_MISMATCH             : N                                              
    OPTIMIZER_MISMATCH            : N                                              
    OUTLINE_MISMATCH              : N                                              
    STATS_ROW_MISMATCH            : N                                              
    LITERAL_MISMATCH              : N                                              
    SEC_DEPTH_MISMATCH            : N                                              
    EXPLAIN_PLAN_CURSOR           : N                                              
    BUFFERED_DML_MISMATCH         : N                                              
    PDML_ENV_MISMATCH             : N                                              
    INST_DRTLD_MISMATCH           : N                                              
    SLAVE_QC_MISMATCH             : N                                              
    TYPECHECK_MISMATCH            : N                                              
    AUTH_CHECK_MISMATCH           : N                                              
    BIND_MISMATCH                 : N                                              
    DESCRIBE_MISMATCH             : N                                              
    LANGUAGE_MISMATCH             : N                                              
    TRANSLATION_MISMATCH          : N                                              
    ROW_LEVEL_SEC_MISMATCH        : N                                              
    INSUFF_PRIVS                  : N                                              
    INSUFF_PRIVS_REM              : N                                              
    REMOTE_TRANS_MISMATCH         : N                                              
    LOGMINER_SESSION_MISMATCH     : N                                              
    INCOMP_LTRL_MISMATCH          : N                                              
    OVERLAP_TIME_MISMATCH         : N                                              
    SQL_REDIRECT_MISMATCH         : N                                              
    MV_QUERY_GEN_MISMATCH         : N                                              
    USER_BIND_PEEK_MISMATCH       : N                                              
    TYPCHK_DEP_MISMATCH           : N                                              
    NO_TRIGGER_MISMATCH           : N                                              
    FLASHBACK_CURSOR              : N                                              
    ANYDATA_TRANSFORMATION        : N                                              
    INCOMPLETE_CURSOR             : N                                              
    TOP_LEVEL_RPI_CURSOR          : N                                              
    DIFFERENT_LONG_LENGTH         : N                                              
    LOGICAL_STANDBY_APPLY         : N                                              
    DIFF_CALL_DURN                : N                                              
    BIND_UACS_DIFF                : N                                              
    PLSQL_CMP_SWITCHS_DIFF        : N                                              
    CURSOR_PARTS_MISMATCH         : N                                              
    STB_OBJECT_MISMATCH           : N                                              
    ROW_SHIP_MISMATCH             : N                                              
    PQ_SLAVE_MISMATCH             : N                                              
    TOP_LEVEL_DDL_MISMATCH        : N                                              
    MULTI_PX_MISMATCH             : N                                              
    BIND_PEEKED_PQ_MISMATCH       : N                                              
    MV_REWRITE_MISMATCH           : N                                              
    ROLL_INVALID_MISMATCH         : N                                              
    OPTIMIZER_MODE_MISMATCH       : N                                              
    PX_MISMATCH                   : N                                              
    MV_STALEOBJ_MISMATCH          : N                                              
    FLASHBACK_TABLE_MISMATCH      : N                                              
    LITREP_COMP_MISMATCH          : N                                              
    SQL_ID                        : 9dkmu9bdhg5h0                                  
    ADDRESS                       : 6AD85A70                                       
    CHILD_ADDRESS                 : 6B10AA00                                       
    CHILD_NUMBER                  : 1                                              
    UNBOUND_CURSOR                : N                                              
    SQL_TYPE_MISMATCH             : N                                              
    OPTIMIZER_MISMATCH            : N                                              
    OUTLINE_MISMATCH              : N                                              
    STATS_ROW_MISMATCH            : N                                              
    LITERAL_MISMATCH              : N                                              
    SEC_DEPTH_MISMATCH            : N                                              
    EXPLAIN_PLAN_CURSOR           : N                                              
    BUFFERED_DML_MISMATCH         : N                                              
    PDML_ENV_MISMATCH             : N                                              
    INST_DRTLD_MISMATCH           : N                                              
    SLAVE_QC_MISMATCH             : N                                              
    TYPECHECK_MISMATCH            : N                                              
    AUTH_CHECK_MISMATCH           : N                                              
    BIND_MISMATCH                 : N                                              
    DESCRIBE_MISMATCH             : N                                              
    LANGUAGE_MISMATCH             : N                                              
    TRANSLATION_MISMATCH          : N                                              
    ROW_LEVEL_SEC_MISMATCH        : N                                              
    INSUFF_PRIVS                  : N                                              
    INSUFF_PRIVS_REM              : N                                              
    REMOTE_TRANS_MISMATCH         : N                                              
    LOGMINER_SESSION_MISMATCH     : N                                              
    INCOMP_LTRL_MISMATCH          : N                                              
    OVERLAP_TIME_MISMATCH         : N                                              
    SQL_REDIRECT_MISMATCH         : N                                              
    MV_QUERY_GEN_MISMATCH         : N                                              
    USER_BIND_PEEK_MISMATCH       : N                                              
    TYPCHK_DEP_MISMATCH           : N                                              
    NO_TRIGGER_MISMATCH           : N                                              
    FLASHBACK_CURSOR              : N                                              
    ANYDATA_TRANSFORMATION        : N                                              
    INCOMPLETE_CURSOR             : N                                              
    TOP_LEVEL_RPI_CURSOR          : N                                              
    DIFFERENT_LONG_LENGTH         : N                                              
    LOGICAL_STANDBY_APPLY         : N                                              
    DIFF_CALL_DURN                : Y      <-- Mismatch here. diff_call_durn
    BIND_UACS_DIFF                : N                                              
    PLSQL_CMP_SWITCHS_DIFF        : N                                              
    CURSOR_PARTS_MISMATCH         : N                                              
    STB_OBJECT_MISMATCH           : N                                              
    ROW_SHIP_MISMATCH             : N                                              
    PQ_SLAVE_MISMATCH             : N                                              
    TOP_LEVEL_DDL_MISMATCH        : N                                              
    MULTI_PX_MISMATCH             : N                                              
    BIND_PEEKED_PQ_MISMATCH       : N                                              
    MV_REWRITE_MISMATCH           : N                                              
    ROLL_INVALID_MISMATCH         : N                                              
    OPTIMIZER_MODE_MISMATCH       : N                                              
    PX_MISMATCH                   : N                                              
    MV_STALEOBJ_MISMATCH          : N                                              
    FLASHBACK_TABLE_MISMATCH      : N                                              
    LITREP_COMP_MISMATCH          : N                                              
    PL/SQL procedure successfully completed.

  • DBMS_XPLAN.DISPLAY - predicate information

    As mentioned in Oracle® Database PL/SQL Packages and Types Reference oracle predicate information is only displayed when applicable.
    Do you konow when it is not applicable .
    First System Which shows predicate information
    SQL> create table ttt (a number);
    Table created.
    SQL> explain plan for select * from ttt where a=333;
    Explained.
    SQL> Select * from table(dbms_xplan.display());
    PLAN_TABLE_OUTPUT
    Plan hash value: 774701505
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 1 | 13 | 2 (0)| 00:00:01 |
    |* 1 | TABLE ACCESS FULL| TTT | 1 | 13 | 2 (0)| 00:00:01 |
    Predicate Information (identified by operation id):
    PLAN_TABLE_OUTPUT
    *1 - filter("A"=333)*
    Second System Which doesn't show predicate information
    SQL> create table ttt (a number);
    Table created.
    SQL> explain plan for select * from ttt where a=333;
    Explained.
    SQL> Select * from table(dbms_xplan.display());
    Plan hash value: 774701505
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 1 | 13 | 2 (0)| 00:00:01 |
    | 1 | TABLE ACCESS FULL| TTT | 1 | 13 | 2 (0)| 00:00:01 |
    Note
    - dynamic sampling used for this statement
    12 rows selected.
    SQL>
    Edited by: user8308823 on 11.Åžub.2011 05:42

    Check your value of cursorplan_unparse_enabled
    There have been bugs around access to the predicates column in v$sql_plan in certain
    versions (Metalink ids 2791172,763607.1,3267299)
    One of the recommendations was to alter the
    setting of " _cursor_plan_unparse_enabled"
    E.g.
    ALTER SESSION set "_cursor_plan_unparse_enabled"=FALSE
    which had this effect.
    See also
    Execution plan: Suddenly no predicate information displayed anymore
    Edited by: Dom Brooks on Feb 11, 2011 2:15 PM

  • Why query against table(dbms_xplan.display) take too long?

    the env is PROD, version is Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi.
    Most of the time, when I do explain plan and query the table(dbms_xplan.display), it takes like 3-8 minutes to display the result.
    So, I wonder what might go wrong here?
    How a simple query would take this long?
    Any thought or guess are welcome.
    Thanks

    That is not an option here. I only have query privilege on PROD.
    All I can do is to figure out the reason for the slowness and advise the fix.
    Thanks.

  • Dbms_xplan, e-rows, a-rows

    oracle 10.2.0.5
    Where does dbms_xplan get the a-rows and e-rows? When I look in v$sql_plan I only see 1 cardinality field. How does it get two different values?
    we have statistics_level=typical, so v$sql_plan_statistics is not populated. So it can't be from that.

    >
    Where does dbms_xplan get the a-rows and e-rows?
    >
    e-rows are optimizer estimates and a-rows are actual statistics gathered during execution
    See this blog by Maria Colgan - a member of the Oracle Optimizer development team.
    https://blogs.oracle.com/optimizer/entry/how_do_i_know_if
    You might want to bookmark her blog.

  • Dbms_xplan.display_awr display more than one plan

    Hi,
    There are times when running dbms_xplan.display_awr , shows more than one execution plan.
    How can i know which of the plans is the most recent ?
    For example :
    SYS@qa> SELECT * FROM table(dbms_xplan.display_awr('0gtqfjcypx66z'));
    Show two diffrenets plan :
    Plan hash value: 3366355658
    Plan hash value: 2273523394
    Thanks

    It is more than likely both plan will be relevant. A single sql_id does not mean that there is a single plan active.
    Below is a very simple testcase that highlights the same sql_id with 2 different plans being used at the same time. Even though the same namespace is shared the underlying objects are different.
    There are a lot of other reasons for a child cursor to not be shared apart from the query be executed in different schema.
    -- 1. Create 2 users with identical tables but different data. 1 table has an index.
    sqlplus / as sysdba
    grant dba to test1 identified by test;
    grant dba to test2 identified by test;
    create table test1.x (x varchar2(1));
    create table test2.x (x varchar2(1));
    declare
    i number;
    begin
    for i in 1..125000 loop
    insert into test1.x values ('N');
    end loop;
    insert into test1.x values ('Y');
    commit;
    end;
    insert into test2.x values('T');
    create index test1.x_idx on test1.x(x);
    exec dbms_stats.gather_table_stats('TEST1','X', method_opt=>'for all columns size skewonly');
    exec dbms_stats.gather_table_stats('TEST2','X');
    alter system flush shared_pool;
    -- Connect as the first user and observe the results
    conn test1/test
    select * from x where x='Y';
    SELECT * FROM table(DBMS_XPLAN.DISPLAY_CURSOR);
    alter session set nls_date_format='DD-MON-YYYY:HH24:MI:SS';
    select sql_id, PLAN_HASH_VALUE,CHILD_NUMBER,LOADS,USERS_EXECUTING,FIRST_LOAD_TIME,LAST_ACTIVE_TIME, OPEN_VERSIONS from v$sql where sql_text like 'select * from x%';
    pause
    -- Connect as the second user. See the second child cursor being created with a different plan
    conn test2/test
    select * from x where x='Y';
    SELECT * FROM table(DBMS_XPLAN.DISPLAY_CURSOR);
    alter session set nls_date_format='DD-MON-YYYY:HH24:MI:SS';
    select sql_id, PLAN_HASH_VALUE,CHILD_NUMBER,LOADS,USERS_EXECUTING,FIRST_LOAD_TIME,LAST_ACTIVE_TIME, OPEN_VERSIONS from v$sql where sql_text like 'select * from x%';
    pause
    -- Now we go back to the first user and execute the query again. Notice that the last_active_time is updated again
    conn test1/test
    select * from x where x='Y';
    SELECT * FROM table(DBMS_XPLAN.DISPLAY_CURSOR);
    alter session set nls_date_format='DD-MON-YYYY:HH24:MI:SS';
    select sql_id, PLAN_HASH_VALUE,CHILD_NUMBER,LOADS,USERS_EXECUTING,FIRST_LOAD_TIME,LAST_ACTIVE_TIME, OPEN_VERSIONS from v$sql where sql_text like 'select * from x%';

  • Help with interpreting explain plan (dbms_xplan) output

    Hi all,
    I'm trying to get to grips with reading and interpreting the explain plan or dbms_xplan output, and so I hope someone can help with the output below.
    So, with the explain shown below, does it mean that...
    a) it starts with step 8 and sends all rows to the nested loop in step 5
    b) it only sends (or thinks it sends) 1 row to step 5 from step 8
    c) For each row supplied from step 5, there will be an index lookup at step 8 to access the table at step 6
    d) Step 8 only gets (or think it gets) 1 row
    If it does mean that only 1 row is expected by the optimizer, and yet the full table scan should return 150,000 records, and the table has up to date statistiucs, what else would cause the cardinality to be so far off?
    If it doesn't mean it will return 1 row then what does it mean ?
    | Id  | Operation                           | Name                           | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT                    |                                |       |       |   945 (100)|          |
    |   1 |  SORT GROUP BY                      |                                |     1 |   283 |   945   (3)| 00:00:05 |
    |*  2 |   FILTER                            |                                |       |       |            |          |
    |   3 |    NESTED LOOPS                     |                                |       |       |            |          |
    |   4 |     NESTED LOOPS                    |                                |     1 |   283 |   944   (3)| 00:00:05 |
    |   5 |      NESTED LOOPS                   |                                |     1 |   108 |   929   (3)| 00:00:05 |
    |*  6 |       MAT_VIEW ACCESS FULL          | DEMOGRAPHICS_MV                |     1 |    97 |   927   (3)| 00:00:05 |
    |*  7 |       MAT_VIEW ACCESS BY INDEX ROWID| NAMES_MV                       |     1 |    11 |     2   (0)| 00:00:01 |
    |*  8 |        INDEX RANGE SCAN             | ORG_MV_IDX1                    |     1 |       |     1   (0)| 00:00:01 |
    |*  9 |      INDEX RANGE SCAN               | PAY_IDX8                       |   252 |       |     4   (0)| 00:00:01 |
    |* 10 |     TABLE ACCESS BY INDEX ROWID     | PAY_ALL                        |     1 |   175 |    15   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
          8 - access("ORG_MV"."ORG_ID"="DEMO_MV"."ORG_ID")Many thanks for your help.

    Thank you Hemant and rp0428,
    I read through that white paper which was really useful.
    I ran query using GATHER_PLAN_STATISTICS and go tthe Estimate and Actual rows - wow - it is a long way out!!
    | Id  | Operation                           | Name                           | Starts | E-Rows |E-Bytes| Cost (%CPU)| E-Time   | A-Rows |   A-Time   | Buffers | Reads  |  OMem |  1Mem | Used-Mem |
    |   0 | SELECT STATEMENT                    |                                |      1 |        |       |   945 (100)|          |      0 |00:18:11.39 |    2552K|    361K|       |       |          |
    |   1 |  SORT GROUP BY                      |                                |      1 |      1 |   283 |   945   (3)| 00:00:05 |      0 |00:18:11.39 |    2552K|    361K|  1024 |  1024 |          |
    |*  2 |   FILTER                            |                                |      1 |        |       |            |          |      0 |00:18:11.39 |    2552K|    361K|       |       |          |
    |   3 |    NESTED LOOPS                     |                                |      1 |        |       |            |          |      0 |00:18:11.39 |    2552K|    361K|       |       |          |
    |   4 |     NESTED LOOPS                    |                                |      1 |      1 |   283 |   944   (3)| 00:00:05 |     44M|00:04:59.03 |     598K|  63442 |       |       |          |
    |   5 |      NESTED LOOPS                   |                                |      1 |      1 |   108 |   929   (3)| 00:00:05 |    109K|00:00:01.73 |    7807 |      7 |       |       |          |
    |*  6 |       MAT_VIEW ACCESS FULL          | DEMOGRAPHICS_MV                |      1 |      1 |    97 |   927   (3)| 00:00:05 |    126K|00:00:00.26 |    5417 |      1 |       |       |          |
    |*  7 |       MAT_VIEW ACCESS BY INDEX ROWID| NAMES_MV                       |    126K|      1 |    11 |     2   (0)| 00:00:01 |    109K|00:00:01.27 |    2390 |      6 |       |       |          |
    |*  8 |        INDEX RANGE SCAN             | ORG_MV_IDX1                    |    126K|      1 |       |     1   (0)| 00:00:01 |    126K|00:00:00.69 |    2023 |      6 |       |       |          |
    |*  9 |      INDEX RANGE SCAN               | PAY_IDX8                       |    109K|    252 |       |     4   (0)| 00:00:01 |     44M|00:04:03.07 |     590K|  63435 |       |       |          |
    |* 10 |     TABLE ACCESS BY INDEX ROWID     | PAY_ALL                        |     44M|      1 |   175 |    15   (0)| 00:00:01 |      0 |00:13:09.85 |    1954K|    297K|       |       |          |
    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------When I unravel the WHERE clause and remove the decode(nvl statements (which only evaluate the passed in parameters and provide default values where they are NULL) I get a much better plan and values
    | Id  | Operation                        | Name                           | Starts | E-Rows |E-Bytes| Cost (%CPU)| E-Time   | A-Rows |   A-Time   | Buffers | Reads  |  OMem |  1Mem | Used-Mem |
    |   0 | SELECT STATEMENT                 |                                |      1 |        |       |   157K(100)|          |      0 |00:00:43.10 |     343K|  45190 |       |       |          |
    |   1 |  SORT GROUP BY                   |                                |      1 |      1 |   283 |   157K  (1)| 00:13:47 |      0 |00:00:43.10 |     343K|  45190 |  1024 |  1024 |          |
    |   2 |   NESTED LOOPS                   |                                |      1 |        |       |            |          |      0 |00:00:43.10 |     343K|  45190 |       |       |          |
    |   3 |    NESTED LOOPS                  |                                |      1 |      1 |   283 |   157K  (1)| 00:13:47 |      0 |00:00:43.10 |     343K|  45190 |       |       |          |
    |*  4 |     HASH JOIN                    |                                |      1 |      1 |   272 |   157K  (1)| 00:13:47 |      0 |00:00:43.10 |     343K|  45190 |   720K|   720K|  171K (0)|
    |*  5 |      TABLE ACCESS BY INDEX ROWID | PAY_ALL                        |      1 |      2 |   350 |   156K  (1)| 00:13:43 |      0 |00:00:43.10 |     343K|  45190 |       |       |          |
    |*  6 |       INDEX RANGE SCAN           | PAY_IDX7                       |      1 |   3596K|       | 15565   (1)| 00:01:22 |   7251K|00:00:50.88 |   45190 |  45190 |       |       |          |
    |*  7 |      MAT_VIEW ACCESS FULL        | DEMOGRAPHICS_MV                |      0 |    126K|    11M|   919   (2)| 00:00:05 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
    |*  8 |     INDEX RANGE SCAN             | ORG_MV_IDX1                    |      0 |      1 |       |     1   (0)| 00:00:01 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
    |*  9 |    MAT_VIEW ACCESS BY INDEX ROWID| NAMES_MV                       |      0 |      1 |    11 |     2   (0)| 00:00:01 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Even though the result set is zero, the time to establish this came down from 35 minutes to 30 seconds and the plan has changed and is using a different index now!
    Thanks for your help!

  • Problem with dbms_xplan.display_cursor

    Hi All,
    I am on Oracle 11.2 on Linux.
    My understanding is, if I need to see the plan for the last (i.e. latest) query executed in current session, I can run,
    select * from table( dbms_xplan.display_cursor ) ;
    I am running my query (in sql*plus) and immediatly after that running (above) dbms_xplan.display_cursor and got error,
    SQL> select * from table( dbms_xplan.display_cursor ) ;
    PLAN_TABLE_OUTPUT
    SQL_ID  9babjv8yq8ru3, child number 2
    BEGIN DBMS_OUTPUT.GET_LINES(:LINES, :NUMLINES); END;
    NOTE: cannot fetch plan for SQL_ID: 9babjv8yq8ru3, CHILD_NUMBER: 2
          Please verify value of SQL_ID and CHILD_NUMBER;
          It could also be that the plan is no longer in cursor cache (check v$sql_plan)
    8 rows selected.This is a test database, where nothing much is running at the time when I am running my query.
    Any ideas ??
    Thanks in advance

    set serveroutput off:
    SQL> set serveroutput on
    SQL> select sysdate from dual;
    SYSDATE
    10-MAR-11
    SQL> select * from table(dbms_xplan.display_cursor(null,null,'ALLSTATS LAST'));
    PLAN_TABLE_OUTPUT
    SQL_ID  9babjv8yq8ru3, child number 0
    BEGIN DBMS_OUTPUT.GET_LINES(:LINES, :NUMLINES); END;
    NOTE: cannot fetch plan for SQL_ID: 9babjv8yq8ru3, CHILD_NUMBER: 0
          Please verify value of SQL_ID and CHILD_NUMBER;
          It could also be that the plan is no longer in cursor cache (check v$sql_plan)
    8 rows selected.
    SQL> set serveroutput off
    SQL>  select sysdate from dual;
    SYSDATE
    10-MAR-11
    SQL>  select * from table(dbms_xplan.display_cursor(null,null,'ALLSTATS LAST'));
    PLAN_TABLE_OUTPUT
    SQL_ID  a578ruam38apm, child number 0
    select sysdate from dual
    Plan hash value: 1388734953
    | Id  | Operation        | Name | E-Rows |
    |   0 | SELECT STATEMENT |      |        |
    |   1 |  FAST DUAL       |      |      1 |
    Note
       - Warning: basic plan statistics not available. These are only collected when:
           * hint 'gather_plan_statistics' is used for the statement or
           * parameter 'statistics_level' is set to 'ALL', at session or system level
    19 rows selected.
    SQL>

  • 'dbms_xplan.display_awr' is showing two plan for single query

    Hi,
    I am trying to fetch sql plan from awr, but it's showing two different plans for a single query:
    PLAN_TABLE_OUTPUT
    SQL_ID 2pxv33cr271sb
    SELECT P_DEP_BNK_CODE,P_DEP_BRN_CODE,P_DEP_DATE,
                                   P_DEP_DAY_SL,P_DEP_INST_SL,P_INST_AMT                                       
                             FROM P WHERE
                                        P_DEP_BNK_CODE = :1 AND
                                    P_DEP_BRN_CODE = :2 AND
                                P_DEP_DATE     = :3 AND
                            P_DEP_LCC_UCC  = :4 AND
                        P_DEP_DAY_SL   = :5 AND
                    (P_REALISED_ON IS NULL AND
                    P_RTN_DATE IS NULL)
    Plan hash value: 3064382432
    | Id  | Operation                          | Name      | Rows  | Bytes | Cost (%CPU)| Time     | Pstart| Pstop |
    |   0 | SELECT STATEMENT                   |           |       |       |     5 (100)|          |       |       |
    |   1 |  TABLE ACCESS BY GLOBAL INDEX ROWID| P         |     1 |    40 |     5   (0)| 00:00:01 | ROWID | ROWID |
    |   2 |   INDEX RANGE SCAN                 | P_PK      |     1 |       |     4   (0)| 00:00:01 |       |       |
    Note
       - dynamic sampling used for this statement (level=5)
    SQL_ID 2pxv33cr271sb
    SELECT P_DEP_BNK_CODE,P_DEP_BRN_CODE,P_DEP_DATE,
                                   P_DEP_DAY_SL,P_DEP_INST_SL,P_INST_AMT                                       
                             FROM P WHERE
                                        P_DEP_BNK_CODE = :1 AND
                                    P_DEP_BRN_CODE = :2 AND
                                P_DEP_DATE     = :3 AND
                            P_DEP_LCC_UCC  = :4 AND
                        P_DEP_DAY_SL   = :5 AND
                    (P_REALISED_ON IS NULL AND
                    P_RTN_DATE IS NULL)
    Plan hash value: 3447007225
    | Id  | Operation            | Name     | Rows  | Bytes | Cost (%CPU)| Time     | Pstart| Pstop |    TQ  |IN-OUT| PQ Distrib |
    |   0 | SELECT STATEMENT     |          |       |       |     7 (100)|          |       |       |        |      |            |
    |   1 |  PX COORDINATOR      |          |       |       |            |          |       |       |        |      |            |
    |   2 |   PX SEND QC (RANDOM)| :TQ10000 |     1 |    38 |     7  (43)| 00:00:01 |       |       |  Q1,00 | P->S | QC (RAND)  |
    |   3 |    PX BLOCK ITERATOR |          |     1 |    38 |     7  (43)| 00:00:01 |   KEY |   KEY |  Q1,00 | PCWC |            |
    |   4 |     TABLE ACCESS FULL| P        |     1 |    38 |     7  (43)| 00:00:01 |   KEY |   KEY |  Q1,00 | PCWP |            |
    ------------------------------------------------------------------------------------------------------------------------------The database version is 11.2.0.1 and the underlying table is partitioned. Why this is showing two plans? Although the plan doesn't look expensive but this is causing maximum gets and enq: row lock contention
    Regards,
    Regards

    SQL> set autot on
    SQL> SELECT
      2  SUM(NVL(P_INST_AMT, 0))
      3  FROM
      4  AXISCMS.P
      5  WHERE
      6  P_DEP_BNK_CODE = '211'
      7  AND
      8  P_DEP_BRN_CODE = '005'
      9  AND
    10  P_DEP_DATE = to_date('11-NOV-2010')
    11  AND
    12  P_DEP_LCC_UCC = 'L'
    13  AND
    P_DEP_DAY_SL = 15001
    14   15  AND
    16  (P_REALISED_ON IS NOT NULL OR P_RTN_DATE IS NOT NULL );
    SUM(NVL(P_INST_AMT,0))
    Execution Plan
    | Id  | Operation                           | Name      | Rows  | Bytes | Cost  | Pstart| Pstop |
    |   0 | SELECT STATEMENT                    |           |     1 |    38 |     8 |       |       |
    |   1 |  SORT AGGREGATE                     |           |     1 |    38 |       |       |       |
    |   2 |   TABLE ACCESS BY GLOBAL INDEX ROWID| P          |     1 |    38 |     8 |    72 |    72 |
    |   3 |    INDEX RANGE SCAN                 | P_PK      |     1 |       |     4 |       |       |
    Note
       - 'PLAN_TABLE' is old version
    Statistics
              5  recursive calls
              0  db block gets
            370  consistent gets
             31  physical reads
              0  redo size
            543  bytes sent via SQL*Net to client
            524  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
              1  rows processedThe above query seems to be having cheapest cost but causing a lot of slowness in the database.
    Column Description:
    COLUMN_NAME                    DATA_TYPE                      NUM_DISTINCT  NUM_NULLS    DENSITY HISTOGRAM
    P_AC_NAME                 VARCHAR2                             244672   49251591 4.0871E-06 NONE
    P_AC_NO                   VARCHAR2                             413792   48713721 2.4167E-06 NONE
    P_ARNGMNT_CREDIT_DATE     DATE                                   1708   39366743 .001724138 HEIGHT BALANCED
    P_AUTOLIQ_ACT_DATE        DATE                                    358   50356077 .003003003 HEIGHT BALANCED
    P_AUTOLIQ_DUE_DATE        DATE                                    337   50427426 .002967359 NONE
    P_AUTOLIQ_FLAG            CHAR                                      1   44746714          1 NONE
    P_CLG_DNLD_FLAG           NUMBER                                    1   50481119 .035714286 FREQUENCY
    P_CORR_BANK_REAL_DATE     DATE                                      0   50481133          0 NONE
    P_DEP_BNK_CODE            VARCHAR2                                 16          0 9.9454E-09 FREQUENCY
    P_DEP_BRN_CODE            VARCHAR2                                671          0 .002531646 HEIGHT BALANCEDIndex Details
    INDEX_NAME                     COLUMN_NAME                    COLUMN_POSITION
        P_IDX_FULL                P_INST_NO                               1
        P_IDX_FULL                P_DRAWN_ON_BANK                         2
        P_IDX_FULL                P_DRAWN_ON_BRN                          3
        P_IDX_FULL                P_INST_TYPE                             4
        P_IDX_FULL                P_DRAWN_ON_LOC                          5
        P_IDX_FULL                P_RTN_DATE                              6
        P_INDX1                   P_INST_NO                               1
        P_INDX2                   P_RTN_DATE                              1
        P_INDX2                   P_RTN_DAY_SL                            2
        P_INDX2                   P_RTN_INS_SL                            3
        P_INDX3                   P_REALISED_ON                           1
        P_INDX3                   P_REALISED_DAY_SL                       2
        P_INDX3                   P_REALISED_INS_SL                       3
        P_INDX4                   P_REV_TO_COL_DUE_DATE                   1
        P_INDX4                   P_REV_TO_COL_DONE_ON                    2
        P_INDX5                   P_ARNGMNT_CREDIT_DATE                   1
        P_INDX6                   P_POOL_POST_DATE                        1
        P_INDX6                   P_POOL_POST_DAYSL                       2
        P_PK                      P_DEP_BNK_CODE                          1
        P_PK                      P_DEP_BRN_CODE                          2
        P_PK                      P_DEP_DATE                              3
        P_PK                      P_DEP_LCC_UCC                           4
        P_PK                      P_DEP_DAY_SL                            5
        P_PK                      P_DEP_INST_SL                           6
    Top 5 Timed Foreground Events
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                               Avg
                                                              wait   % DB
    Event                                 Waits     Time(s)   (ms)   time Wait Class
    DB CPU                                           58,454          13.1
    enq: TX - row lock contention         1,095      17,691  16156    4.0 Applicatio
    read by other session             1,719,661      11,392      7    2.6 User I/O
    latch: cache buffers chains         264,753      10,758     41    2.4 Concurrenc
    latch free                           78,456       8,215    105    1.8 Other
    The query comes on top in every section in AWR.Regards,

  • How to wrap a view in oracle

    Does any one know how to wrap a view in Oracle, I know it is not possible, yet. Are there any third party software to wrap the logic in the view.
    Thanks,
    Sanjay

    Your best bet is to write a view that queries the source tables and contains any necessary business logic
    CREATE VIEW VBASE AS SELECT A.COLUMN_A FROM TABLE_1 A, TABLE_2 B, TABLE_3 C WHERE A.ID = B.ID AND B.ID = C.ID;
    create a view for exposure to the user that queries the base view.
    CREATE VIEW VSECURE AS SELECT COLUMN_B FROM VBASE;
    and grant privileges to VSECURE.
    GRANT SELECT ON VSECURE TO SECURE_USER;
    This will allow the user to see, query, and describe VSECURE without seeing the definition for VBASE.
    The advantage of the this approach is that the query engine can still push predicates down into the base view to optimize the performance or the query where as this is limited with the pipeline function and can become a tuning headache.
    eg.
    SQL> -----------------------------------------
    SQL> -- create some tables
    SQL> -----------------------------------------
    SQL> CREATE TABLE table_1(ID NUMBER, MESSAGE VARCHAR2(100))
    Table created.
    SQL> CREATE TABLE table_2(ID NUMBER, message2 VARCHAR2(100))
    Table created.
    SQL> CREATE TABLE table_3(ID NUMBER, message3 VARCHAR2(100))
    Table created.
    SQL> -----------------------------------------
    SQL> -- populate tables with some data
    SQL> -----------------------------------------
    SQL> INSERT INTO table_1
    SELECT ROWNUM,
    CASE
    WHEN MOD ( ROWNUM, 50 ) = 0 THEN 'HELLO there joe'
    ELSE 'goodbye joe'
    END
    FROM DUAL
    CONNECT BY LEVEL < 1000000
    999999 rows created.
    SQL> INSERT INTO table_2
    SELECT ROWNUM,
    CASE
    WHEN MOD ( ROWNUM, 50 ) = 0 THEN 'how are you joe'
    ELSE 'good to see you joe'
    END
    FROM DUAL
    CONNECT BY LEVEL < 1000000
    999999 rows created.
    SQL> INSERT INTO table_3
    SELECT ROWNUM,
    CASE
    WHEN MOD ( ROWNUM, 50 ) = 0 THEN 'just some data'
    ELSE 'other stuff'
    END
    FROM DUAL
    CONNECT BY LEVEL < 1000000
    999999 rows created.
    SQL> -----------------------------------------
    SQL> --create base view
    SQL> -----------------------------------------
    SQL> CREATE OR REPLACE VIEW vbase AS
    SELECT a.MESSAGE,
    c.message3
    FROM table_1 a,
    table_2 b,
    table_3 c
    WHERE a.ID = b.ID
    AND b.ID = c.ID
    View created.
    SQL> -----------------------------------------
    SQL> --create secure view using base view
    SQL> -----------------------------------------
    SQL> CREATE OR REPLACE VIEW vsecure AS
    SELECT MESSAGE,
    message3
    FROM vbase
    View created.
    SQL> -----------------------------------------
    SQL> -- create row type for pipeline function
    SQL> -----------------------------------------
    SQL> CREATE OR REPLACE TYPE vbase_row
    AS OBJECT
    message varchar2(100),
    message3 varchar2(100)
    Type created.
    SQL> -----------------------------------------
    SQL> -- create table type for pipeline function
    SQL> -----------------------------------------
    SQL> CREATE OR REPLACE TYPE vbase_table
    AS TABLE OF vbase_row;
    Type created.
    SQL> -----------------------------------------
    SQL> -- create package
    SQL> -----------------------------------------
    SQL> CREATE OR REPLACE PACKAGE pkg_getdata AS
    FUNCTION f_get_vbase
    RETURN vbase_table PIPELINED;
    END;
    Package created.
    SQL> -----------------------------------------
    SQL> -- create package body with pipeline function using same query as vbase
    SQL> -----------------------------------------
    SQL> CREATE OR REPLACE PACKAGE BODY pkg_getdata AS
    FUNCTION f_get_vbase
    RETURN vbase_table PIPELINED IS
    CURSOR cur IS
    SELECT a.MESSAGE,
    c.message3
    FROM table_1 a,
    table_2 b,
    table_3 c
    WHERE a.ID = b.ID
    AND b.ID = c.ID;
    BEGIN
    FOR rec IN cur
    LOOP
    PIPE ROW ( vbase_row ( rec.MESSAGE, rec.message3 ) );
    END LOOP;
    END;
    END pkg_getdata;
    Package body created.
    SQL> -----------------------------------------
    SQL> -- create secure view using pipeline function
    SQL> -----------------------------------------
    SQL> CREATE or replace VIEW vsecure_with_pipe AS
    SELECT *
    FROM TABLE ( pkg_getdata.f_get_vbase ( ) )
    View created.
    SQL> -----------------------------------------
    SQL> -- this would grant select on the 2 views, one with nested view, one with nested pipeline function
    SQL> -----------------------------------------
    SQL> GRANT SELECT ON vsecure TO test_user
    Grant complete.
    SQL> GRANT SELECT ON vsecure_with_pipe TO test_user
    Grant complete.
    SQL> explain plan for
    SELECT *
    FROM vsecure
    WHERE MESSAGE LIKE 'HELLO%'
    Explain complete.
    SQL> SELECT *
    FROM TABLE ( DBMS_XPLAN.display ( ) )
    PLAN_TABLE_OUTPUT
    Plan hash value: 3905984671
    | Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 16939 | 2365K| | 3098 (3)| 00:00:54 |
    |* 1 | HASH JOIN | | 16939 | 2365K| 2120K| 3098 (3)| 00:00:54 |
    |* 2 | HASH JOIN | | 24103 | 1835K| | 993 (5)| 00:00:18 |
    |* 3 | TABLE ACCESS FULL| TABLE_1 | 24102 | 1529K| | 426 (5)| 00:00:08 |
    | 4 | TABLE ACCESS FULL| TABLE_2 | 1175K| 14M| | 559 (3)| 00:00:10 |
    | 5 | TABLE ACCESS FULL | TABLE_3 | 826K| 51M| | 415 (3)| 00:00:08 |
    Predicate Information (identified by operation id):
    1 - access("B"."ID"="C"."ID")
    2 - access("A"."ID"="B"."ID")
    3 - filter("A"."MESSAGE" LIKE 'HELLO%')
    Note
    PLAN_TABLE_OUTPUT
    - dynamic sampling used for this statement
    23 rows selected.
    SQL> -----------------------------------------
    SQL> -- note that the explain plan shows the predicate pushed down into the base view.
    SQL> -----------------------------------------
    SQL> explain plan for
    SELECT count(*)
    FROM vsecure_with_pipe
    WHERE MESSAGE LIKE 'HELLO%'
    Explain complete.
    SQL> SELECT *
    FROM TABLE ( DBMS_XPLAN.display ( ) )
    PLAN_TABLE_OUTPUT
    Plan hash value: 19045890
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 1 | 2 | 15 (0)| 00:00:01 |
    | 1 | SORT AGGREGATE | | 1 | 2 | | |
    |* 2 | COLLECTION ITERATOR PICKLER FETCH| F_GET_VBASE | | | | |
    Predicate Information (identified by operation id):
    2 - filter(VALUE(KOKBF$) LIKE 'HELLO%')
    14 rows selected.
    SQL> -----------------------------------------
    SQL> -- note that the filter is applied on the results of the pipeline function
    SQL> -----------------------------------------
    SQL> set timing on
    SQL> SELECT count(*)
    FROM vsecure
    WHERE MESSAGE LIKE 'HELLO%'
    COUNT(*)
    19999
    1 row selected.
    Elapsed: 00:00:01.42
    SQL> SELECT count(*)
    FROM vsecure_with_pipe
    WHERE MESSAGE LIKE 'HELLO%'
    COUNT(*)
    19999
    1 row selected.
    Elapsed: 00:00:04.11
    SQL> -----------------------------------------
    SQL> -- note the difference in the execution times.
    SQL> -----------------------------------------

  • Need suggestion in sql

    I have 8 tables of which i need to do union of all tables and do group by ..all 8 tables consists of similar columns with small changes..
    My question is which is best idea
    1. do union first of all 8 tables and do group by
    or
    2. group by each individual table and then do union of all 8 tables
    which way sql query will be fast?

    Your question is impossible to answer.
    No version number.
    No DDL.
    No Data.
    No metrics.
    No SQL.
    No explain plan report generated with DBMS_XPLAN.
    Do your work ... multiple ways ... and post the plans if you have any further questions.

  • Help needed to tune the Query:Statistics added

    Can someone DBA please help me to tune this query:
    SELECT DISTINCT K.ATTRIBUTE_VALUE AGENCY_ID,B.PROFILE_NM ,NVL(G.OFFICE_DESC,'--') OFFICE_DESC,f.OFFICE_ID,B.PROFILE_ID,'%' ROLE,'%' LAYOUT,
    CASE
    WHEN 'flagB' = '%' THEN
    NVL(J.ISS_GRP_DESC,'BILLING')
    WHEN 'flagO' = '%' THEN
    NVL(J.ISS_GRP_DESC,'ORDERING')
    WHEN 'flag' = '%' THEN
    NVL(J.ISS_GRP_DESC,'BILLING/ORDERING')
    ELSE
    NVL(J.ISS_GRP_DESC,' ')
    END ISS_GRP_DESC,
    DECODE(NVL(H.USERID,' ') ,' ','--','<a sbcuid_in=' || H.USERID || ' target=NEW >'||H.FIRSTNAME || ' ' || H.LASTNAME || '( ' || H.USERID || ' )</a>' ) USER_NAME
    FROM
    PROFILE_PORTAL B ,
    TBL_BDA_AGENCY_RESP_REP C ,
    TBL_BDA_AGENCY_OFFICE F,
    TBL_BDA_OFFICE G,
    USERS_PORTAL H,
    TBL_BDA_USR_ISS_GRP I ,
    TBL_BDA_ISS_GROUP J,
    ATTRIBUTE_VALUES_PORTAL K,
    PROFILE_TYPE_PORTAL L
    WHERE
    B.PROFILE_ID = F.AGENCY_ID (+)
    AND B.PROFILE_ID = C.AGENCY_ID (+)
    AND G.OFFICE_ID (+)= F.OFFICE_ID
    AND H.USERID (+)= C.RESP_USR_ID
    AND C.ISS_GRP_ID = I.ISS_GRP_ID (+)
    AND I.ISS_GRP_ID = J.ISS_GRP_ID(+)
    AND 'PROFILE.'||B.PROFILE_ID = K.ENTITY_ID(+)
    AND K.ATTRIBUTE_VALUE IS NOT NULL
    AND L.PROFILE_TYPE_ID = B.PROFILE_TYPE_ID
    AND L.APPLICATION_CD='BDA'
    AND NOT EXISTS (SELECT agency_id
    FROM TBL_BDA_AGENCY_RESP_REP t
    WHERE t.ISS_GRP_ID IN ('%')
    AND t.AGENCY_ID = C.AGENCY_ID)
    AND K.ATTRIBUTE_VALUE LIKE '%'
    AND UPPER(B.PROFILE_NM) LIKE UPPER('%')
    AND (to_char(NVL(B.PROFILE_ID,0)) LIKE '%' OR NVL(B.PROFILE_ID,0) IN ('a'))
    AND NVL(G.OFFICE_ID,0) IN ('%')
    AND (to_char(NVL(C.RESP_USR_ID,'0')) LIKE '%' OR NVL(C.RESP_USR_ID,'0') IN ('k'))
    ORDER BY PROFILE_NM
    The number of rows in these tables are as follows:
    PROFILE_PORTAL -- 2392
    TBL_BDA_AGENCY_RESP_REP 3508
    TBL_BDA_AGENCY_OFFICE 2151
    TBL_BDA_OFFICE 3
    USERS_PORTAL 270500
    TBL_BDA_USR_ISS_GRP 234
    TBL_BDA_ISS_GROUP 2
    ATTRIBUTE_VALUES_PORTAL 2790
    PROFILE_TYPE_PORTAL 3
    The Explain pal nhas given this o/p to me:
    SQL> select * from table(dbms_xplan.display) dual;
    PLAN_TABLE_OUTPUT
    | Id | Operation | Name | Rows | Bytes |TempSpc| Cost |
    | 0 | SELECT STATEMENT | | 807 | 102K| | 2533 |
    | 1 | SORT UNIQUE | | 807 | 102K| 232K| 82 |
    |* 2 | FILTER | | | | | |
    |* 3 | HASH JOIN OUTER | | 807 | 102K| | 52 |
    |* 4 | HASH JOIN OUTER | | 807 | 95226 | | 40 |
    |* 5 | TABLE ACCESS BY INDEX ROWID | ATTRIBUTE_VALUES | 1 | 23 | | 2 |
    | 6 | NESTED LOOPS | | 7 | 805 | | 37 |
    | 7 | NESTED LOOPS OUTER | | 6 | 552 | | 25 |
    |* 8 | FILTER | | | | | |
    | 9 | NESTED LOOPS OUTER | | | | | |
    |* 10 | FILTER | | | | | |
    | 11 | NESTED LOOPS OUTER | | | | | |
    | 12 | NESTED LOOPS OUTER | | 3 | 141 | | 10 |
    |* 13 | HASH JOIN | | 3 | 120 | | 7 |
    |* 14 | TABLE ACCESS FULL | PROFILE | 6 | 198 | | 4 |
    |* 15 | TABLE ACCESS FULL | PROFILE_TYPE | 1 | 7 | | 2 |
    |* 16 | INDEX RANGE SCAN | SYS_C0019777 | 1 | 7 | | 1 |
    | 17 | TABLE ACCESS BY INDEX ROWID| TBL_BDA_OFFICE | 1 | 10 | | 1 |
    |* 18 | INDEX UNIQUE SCAN | SYS_C0019800 | 1 | | | |
    | 19 | TABLE ACCESS BY INDEX ROWID | TBL_BDA_AGENCY_RESP_REP | 2 | 26 | | 2 |
    |* 20 | INDEX RANGE SCAN | IDX_AGECYRESP_AGNCYID | 2 | | | 1 |
    | 21 | TABLE ACCESS BY INDEX ROWID | USER_ | 1 | 22 | | 1 |
    |* 22 | INDEX UNIQUE SCAN | USER_PK | 1 | | | |
    |* 23 | INDEX RANGE SCAN | IDX_ATTVAL_ENTATTID | 1 | | | 1 |
    | 24 | TABLE ACCESS FULL | TBL_BDA_USR_ISS_GRP | 234 | 702 | | 2 |
    | 25 | TABLE ACCESS FULL | TBL_BDA_ISS_GROUP | 2 | 24 | | 2 |
    |* 26 | TABLE ACCESS BY INDEX ROWID | TBL_BDA_AGENCY_RESP_REP | 1 | 7 | | 3 |
    |* 27 | INDEX RANGE SCAN | IDX_AGECYRESP_AGNCYID | 2 | | | 1 |
    Predicate Information (identified by operation id):
    2 - filter( NOT EXISTS (SELECT /*+ */ 0 FROM "TBL_BDA_AGENCY_RESP_REP" "T" WHERE "T"."AGENCY_ID"=:B1
    AND "T"."ISS_GRP_ID"=TO_NUMBER('%')))
    3 - access("I"."ISS_GRP_ID"="J"."ISS_GRP_ID"(+))
    4 - access("SYS_ALIAS_1"."ISS_GRP_ID"="I"."ISS_GRP_ID"(+))
    5 - filter("K"."ATTRIBUTE_VALUE" IS NOT NULL AND "K"."ATTRIBUTE_VALUE" LIKE '%')
    8 - filter(NVL("SYS_ALIAS_1"."RESP_USR_ID",'0') LIKE '%' OR NVL("SYS_ALIAS_1"."RESP_USR_ID",'0')='k')
    10 - filter(NVL("G"."OFFICE_ID",0)=TO_NUMBER('%'))
    13 - access("L"."PROFILE_TYPE_ID"="B"."PROFILE_TYPE_ID")
    14 - filter(UPPER("B"."PROFILE_NM") LIKE '%' AND (TO_CHAR(NVL("B"."PROFILE_ID",0)) LIKE '%' OR
    NVL("B"."PROFILE_ID",0)=TO_NUMBER('a')))
    15 - filter("L"."APPLICATION_CD"='BDA')
    16 - access("B"."PROFILE_ID"="F"."AGENCY_ID"(+))
    18 - access("G"."OFFICE_ID"(+)="F"."OFFICE_ID")
    20 - access("B"."PROFILE_ID"="SYS_ALIAS_1"."AGENCY_ID"(+))
    22 - access("H"."USERID"(+)="SYS_ALIAS_1"."RESP_USR_ID")
    23 - access("K"."ENTITY_ID"='PROFILE.'||TO_CHAR("B"."PROFILE_ID"))
    26 - filter("T"."ISS_GRP_ID"=TO_NUMBER('%'))
    27 - access("T"."AGENCY_ID"=:B1)
    Note: cpu costing is off
    57 rows selected.
    Elapsed: 00:00:01.08
    Please help me.
    Aashish S.

    Hello Eric,
    Here is the code:
    SELECT DISTINCT
    K.ATTRIBUTE_VALUE AGENCY_ID,
    B.PROFILE_NM ,
    NVL(G.OFFICE_DESC,'--') OFFICE_DESC,
    f.OFFICE_ID,
    B.PROFILE_ID,
    '%' ROLE,
    '%' LAYOUT,
    case
    WHEN 'flagB' = '%' THEN
    NVL(J.ISS_GRP_DESC,'BILLING')
    WHEN 'flagO' = '%' THEN
    NVL(J.ISS_GRP_DESC,'ORDERING')
    WHEN 'flag' = '%' THEN
    NVL(J.ISS_GRP_DESC,'BILLING/ORDERING')
    else
    NVL(J.ISS_GRP_DESC,' ')
    END ISS_GRP_DESC,
    DECODE(NVL(H.USERID,' ') ,' ','--','&lt;a sbcuid_in=' || H.USERID || ' target=NEW &gt;'||H.FIRSTNAME || ' ' || H.LASTNAME ||
    '( ' || H.USERID || ' )&lt;/a&gt;' ) USER_NAME
    from
    PROFILE_PORTAL B ,
    TBL_BDA_AGENCY_RESP_REP C ,
    TBL_BDA_AGENCY_OFFICE F,
    TBL_BDA_OFFICE G,
    USERS_PORTAL H,
    TBL_BDA_USR_ISS_GRP I ,
    TBL_BDA_ISS_GROUP J,
    ATTRIBUTE_VALUES_PORTAL K,
    PROFILE_TYPE_PORTAL L
    WHERE
    B.PROFILE_ID = F.AGENCY_ID (+)
    AND B.PROFILE_ID = C.AGENCY_ID (+)
    AND G.OFFICE_ID (+)= F.OFFICE_ID
    AND H.USERID (+)= C.RESP_USR_ID
    AND C.ISS_GRP_ID = I.ISS_GRP_ID (+)
    AND I.ISS_GRP_ID = J.ISS_GRP_ID(+)
    AND 'PROFILE.'||B.PROFILE_ID = K.ENTITY_ID(+)
    AND K.ATTRIBUTE_VALUE IS NOT NULL
    AND L.PROFILE_TYPE_ID = B.PROFILE_TYPE_ID
    AND L.APPLICATION_CD='BDA'
    AND NOT EXISTS
    (SELECT agency_id
    FROM TBL_BDA_AGENCY_RESP_REP t
    WHERE t.ISS_GRP_ID IN (1)
    AND t.AGENCY_ID = C.AGENCY_ID)
    AND K.ATTRIBUTE_VALUE LIKE '%'
    AND UPPER(B.PROFILE_NM) LIKE UPPER('%')
    AND (to_char(NVL(B.PROFILE_ID,0))
    LIKE '%'
    OR NVL(B.PROFILE_ID,0) IN (1))
    AND NVL(G.OFFICE_ID,0) IN (1)
    AND (to_char(NVL(C.RESP_USR_ID,'0'))
    LIKE '%'
    OR NVL(C.RESP_USR_ID,'0') IN ('%'))
    ORDER BY PROFILE_NM
    This is the Query and the query takes some mins. to run in prod environment.
    From the Query plan ,I am not able to get any idea for optimization.
    Now,Can you tell me which steps I need to follow to run it faster and which all modifications should be made?
    Thanks.
    Aashish S.

  • What can I do to make this query run faster

    Hi All,
    The below query is taking a long time. Is there any thing that I can do to shorten its time.
    SELECT C.FOLIO_NO, C.CO_TRANS_NO TRANS_NO, to_char(C.CREATED_DATE, 'dd/mm/yyyy') DOC_DATE, DECODE(PP.NAME, NULL, D.EMP_NAME, PP.NAME) LODGED_BY, decode(sf_fetch_datechange(c.co_trans_no, C.CO_TRANS_ID), Null, '-', sf_fetch_datechange(c.co_trans_no, C.CO_TRANS_ID)) DATE_CHANGE, P.RECEIPT_NO, decode(c.co_trans_id,'A020',(select nvl(base_trans_id,co_trans_id) from co_form5a_trans f where f.co_trans_no=c.co_trans_no),c.co_trans_id) TRANS_ID,(case when decode(c.co_trans_id,'A020',(select nvl(base_trans_id,co_trans_id) from co_form5a_trans f where f.co_trans_no=c.co_trans_no),c.co_trans_id)='AR20' then 1 when decode(c.co_trans_id,'A020',(select nvl(base_trans_id,co_trans_id) from co_form5a_trans f where f.co_trans_no=c.co_trans_no),c.co_trans_id)='AR03' then 2 end) TRANS_TYPE FROM CO_TRANS_MASTER C, PAYMENT_DETAIL P, PEOPLE_PROFILE PP, SC_AGENT_EMP D, M_CAA_TRANS E     where '1' <> TRIM(UPPER('S0750070Z')) and (C.CO_TRANS_ID in TRIM(UPPER('AR20')) OR C.CO_TRANS_ID in TRIM(UPPER('AR03'))OR c.co_trans_id IN TRIM (UPPER ('A020')))and C.CO_TRANS_NO = P.TRANS_NO and (C.VOID_IND = 'N' or C.VOID_IND is Null) and C.CREATED_BY = PP.PP_ID(+) and C.PROF_NO = D.PROF_NO(+) and C.CREATED_BY = D.EMP_ID (+) and TRIM(UPPER(C.CO_NO)) = TRIM(UPPER('200101586W')) and c.co_trans_id = e.trans_id (+) order by FOLIO_NO;
    SQL>
    SQL> show parameter user_dump_dest
    NAME                                 TYPE        VALUE
    user_dump_dest                       string      /u01/app/oracle/diag/rdbms/ebi
    zfile/EBIZFILE1/trace
    SQL> show parameter optimizer
    NAME                                 TYPE        VALUE
    optimizer_capture_sql_plan_baselines boolean     FALSE
    optimizer_dynamic_sampling           integer     2
    optimizer_features_enable            string      11.2.0.2
    optimizer_index_caching              integer     0
    optimizer_index_cost_adj             integer     100
    optimizer_mode                       string      ALL_ROWS
    optimizer_secure_view_merging        boolean     TRUE
    optimizer_use_invisible_indexes      boolean     FALSE
    optimizer_use_pending_statistics     boolean     FALSE
    optimizer_use_sql_plan_baselines     boolean     TRUE
    SQL> show parameter db_file_multi
    NAME                                 TYPE        VALUE
    db_file_multiblock_read_count        integer     128
    SQL> show parameter db_block_size
    NAME                                 TYPE        VALUE
    db_block_size                        integer     8192
    SQL> show parameter cursor_sharing
    NAME                                 TYPE        VALUE
    cursor_sharing                       string      EXACT
    SQL>
    SQL> column sname format a20
    SQL> column pname format a20
    SQL> column pval2 format a20
    SQL>
    SQL> select
      2  sname, pname, pval1, pval2
      3  from
      4  sys.aux_stats$;
    SNAME                PNAME                     PVAL1 PVAL2
    SYSSTATS_INFO        STATUS                          COMPLETED
    SYSSTATS_INFO        DSTART                          09-11-2010 14:25
    SYSSTATS_INFO        DSTOP                           09-11-2010 14:25
    SYSSTATS_INFO        FLAGS                         1
    SYSSTATS_MAIN        CPUSPEEDNW           739.734748
    SYSSTATS_MAIN        IOSEEKTIM                    10
    SYSSTATS_MAIN        IOTFRSPEED                 4096
    SYSSTATS_MAIN        SREADTIM
    SYSSTATS_MAIN        MREADTIM
    SYSSTATS_MAIN        CPUSPEED
    SYSSTATS_MAIN        MBRC
    SYSSTATS_MAIN        MAXTHR
    SYSSTATS_MAIN        SLAVETHR
    13 rows selected.
    Elapsed: 00:00:00.06
    SQL>
    SQL> explain plan for
      2  SELECT C.FOLIO_NO, C.CO_TRANS_NO TRANS_NO, to_char(C.CREATED_DATE, 'dd/mm/yyyy') DOC_DATE, DECODE(PP.NAME, NULL, D.EMP_NAME, PP.NAME) LODGED_BY, decode(sf_fetch_datechange(c.co_trans_no, C.CO_TRANS_ID), Null, '-', sf_fetch_datechange(c.co_trans_no, C.CO_TRANS_ID)) DATE_CHANGE, P.RECEIPT_NO, decode(c.co_trans_id,'A020',(select nvl(base_trans_id,co_trans_id) from co_form5a_trans f where f.co_trans_no=c.co_trans_no),c.co_trans_id) TRANS_ID,(case when  decode(c.co_trans_id,'A020',(select nvl(base_trans_id,co_trans_id) from co_form5a_trans f where f.co_trans_no=c.co_trans_no),c.co_trans_id)='AR20' then 1 when  decode(c.co_trans_id,'A020',(select nvl(base_trans_id,co_trans_id) from co_form5a_trans f where f.co_trans_no=c.co_trans_no),c.co_trans_id)='AR03' then 2 end) TRANS_TYPE FROM CO_TRANS_MASTER C, PAYMENT_DETAIL P, PEOPLE_PROFILE PP, SC_AGENT_EMP D, M_CAA_TRANS E     where '1' <> TRIM(UPPER('S0750070Z')) and (C.CO_TRANS_ID in TRIM(UPPER('AR20')) OR C.CO_TRANS_ID in TRIM(UPPER('AR03'))OR c.co_trans_id IN TRIM (UPPER ('A020')))and C.CO_TRANS_NO = P.TRANS_NO and (C.VOID_IND = 'N' or C.VOID_IND is Null) and C.CREATED_BY = PP.PP_ID(+) and C.PROF_NO = D.PROF_NO(+) and C.CREATED_BY = D.EMP_ID (+) and TRIM(UPPER(C.CO_NO)) =  TRIM(UPPER('200101586W')) and c.co_trans_id = e.trans_id (+) order by FOLIO_NO;
    Explained.
    Elapsed: 00:00:00.09
    SQL>
    SQL> set pagesize 1000;
    SQL> set linesize 170;
    SQL> @/u01/app/oracle/product/11.2.0/rdbms/admin/utlxpls.sql
    SQL> Rem
    SQL> Rem $Header: utlxpls.sql 26-feb-2002.19:49:37 bdagevil Exp $
    SQL> Rem
    SQL> Rem utlxpls.sql
    SQL> Rem
    SQL> Rem Copyright (c) 1998, 2002, Oracle Corporation.     All rights reserved.
    SQL> Rem
    SQL> Rem    NAME
    SQL> Rem      utlxpls.sql - UTiLity eXPLain Serial plans
    SQL> Rem
    SQL> Rem    DESCRIPTION
    SQL> Rem      script utility to display the explain plan of the last explain plan
    SQL> Rem      command. Do not display information related to Parallel Query
    SQL> Rem
    SQL> Rem    NOTES
    SQL> Rem      Assume that the PLAN_TABLE table has been created. The script
    SQL> Rem      utlxplan.sql should be used to create that table
    SQL> Rem
    SQL> Rem      With SQL*plus, it is recomended to set linesize and pagesize before
    SQL> Rem      running this script. For example:
    SQL> Rem      set linesize 100
    SQL> Rem      set pagesize 0
    SQL> Rem
    SQL> Rem    MODIFIED   (MM/DD/YY)
    SQL> Rem    bdagevil     02/26/02 - cast arguments
    SQL> Rem    bdagevil     01/23/02 - rewrite with new dbms_xplan package
    SQL> Rem    bdagevil     04/05/01 - include CPU cost
    SQL> Rem    bdagevil     02/27/01 - increase Name column
    SQL> Rem    jihuang     06/14/00 - change order by to order siblings by.
    SQL> Rem    jihuang     05/10/00 - include plan info for recursive SQL in LE row source
    SQL> Rem    bdagevil     01/05/00 - add order-by to make it deterministic
    SQL> Rem    kquinn     06/28/99 - 901272: Add missing semicolon
    SQL> Rem    bdagevil     05/07/98 - Explain plan script for serial plans
    SQL> Rem    bdagevil     05/07/98 - Created
    SQL> Rem
    SQL>
    SQL> set markup html preformat on
    SQL>
    SQL> Rem
    SQL> Rem Use the display table function from the dbms_xplan package to display the last
    SQL> Rem explain plan. Force serial option for backward compatibility
    SQL> Rem
    SQL> select plan_table_output from table(dbms_xplan.display('plan_table',null,'serial'));
    PLAN_TABLE_OUTPUT
    Plan hash value: 2520189693
    | Id  | Operation                         | Name                    | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT                  |                         |   592 | 85248 | 16573   (1)| 00:03:19 |
    |   1 |  TABLE ACCESS BY INDEX ROWID      | CO_FORM5A_TRANS         |     1 |    20 |     2   (0)| 00:00:01 |
    |*  2 |   INDEX UNIQUE SCAN               | SYS_C0059692            |     1 |       |     1   (0)| 00:00:01 |
    |   3 |  TABLE ACCESS BY INDEX ROWID      | CO_FORM5A_TRANS         |     1 |    20 |     2   (0)| 00:00:01 |
    |*  4 |   INDEX UNIQUE SCAN               | SYS_C0059692            |     1 |       |     1   (0)| 00:00:01 |
    |   5 |   TABLE ACCESS BY INDEX ROWID     | CO_FORM5A_TRANS         |     1 |    20 |     2   (0)| 00:00:01 |
    |*  6 |    INDEX UNIQUE SCAN              | SYS_C0059692            |     1 |       |     1   (0)| 00:00:01 |
    |   7 |  SORT ORDER BY                    |                         |   592 | 85248 | 16573   (1)| 00:03:19 |
    |   8 |   NESTED LOOPS                    |                         |       |       |            |          |
    |   9 |    NESTED LOOPS                   |                         |   592 | 85248 | 16572   (1)| 00:03:19 |
    |  10 |     NESTED LOOPS OUTER            |                         |   477 | 54855 | 15329   (1)| 00:03:04 |
    |  11 |      NESTED LOOPS OUTER           |                         |   477 | 41499 | 14374   (1)| 00:02:53 |
    |  12 |       INLIST ITERATOR             |                         |       |       |            |          |
    |* 13 |        TABLE ACCESS BY INDEX ROWID| CO_TRANS_MASTER         |   477 | 22896 | 14367   (1)| 00:02:53 |
    |* 14 |         INDEX RANGE SCAN          | IDX_CO_TRANS_ID         | 67751 |       |   150   (1)| 00:00:02 |
    |  15 |       TABLE ACCESS BY INDEX ROWID | SC_AGENT_EMP            |     1 |    39 |     1   (0)| 00:00:01 |
    |* 16 |        INDEX UNIQUE SCAN          | PK_SC_AGENT_EMP         |     1 |       |     0   (0)| 00:00:01 |
    |  17 |      TABLE ACCESS BY INDEX ROWID  | PEOPLE_PROFILE          |     1 |    28 |     2   (0)| 00:00:01 |
    |* 18 |       INDEX UNIQUE SCAN           | SYS_C0063100            |     1 |       |     1   (0)| 00:00:01 |
    |* 19 |     INDEX RANGE SCAN              | IDX_PAY_DETAIL_TRANS_NO |     1 |       |     2   (0)| 00:00:01 |
    |  20 |    TABLE ACCESS BY INDEX ROWID    | PAYMENT_DETAIL          |     1 |    29 |     3   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - access("F"."CO_TRANS_NO"=:B1)
       4 - access("F"."CO_TRANS_NO"=:B1)
       6 - access("F"."CO_TRANS_NO"=:B1)
      13 - filter(TRIM(UPPER("SYS_ALIAS_3"."CO_NO"))='200101586W' AND ("SYS_ALIAS_3"."VOID_IND" IS NULL
                  OR "SYS_ALIAS_3"."VOID_IND"='N'))
      14 - access("SYS_ALIAS_3"."CO_TRANS_ID"='A020' OR "SYS_ALIAS_3"."CO_TRANS_ID"='AR03' OR
                  "SYS_ALIAS_3"."CO_TRANS_ID"='AR20')
      16 - access("SYS_ALIAS_3"."PROF_NO"="D"."PROF_NO"(+) AND
                  "SYS_ALIAS_3"."CREATED_BY"="D"."EMP_ID"(+))
      18 - access("SYS_ALIAS_3"."CREATED_BY"="PP"."PP_ID"(+))
      19 - access("SYS_ALIAS_3"."CO_TRANS_NO"="P"."TRANS_NO")
    42 rows selected.
    Elapsed: 00:00:00.53
    SQL>
    SQL>
    SQL>
    SQL> rollback;
    Rollback complete.
    Elapsed: 00:00:00.01
    SQL>
    SQL> rem Set the ARRAYSIZE according to your application
    SQL> set autotrace traceonly arraysize 100
    SQL>
    SQL> alter session set tracefile_identifier = 'mytrace1';
    Session altered.
    Elapsed: 00:00:00.00
    SQL>
    SQL> rem if you're using bind variables
    SQL> rem define them here
    SQL>
    SQL> rem variable b_var1 number
    SQL> rem variable b_var2 varchar2(20)
    SQL>
    SQL> rem and initialize them
    SQL>
    SQL> rem exec :b_var1 := 1
    SQL> rem exec :b_var2 := 'DIAG'
    SQL> set pagesize 1000;
    SQL> set linesize 170;
    SQL> alter session set events '10046 trace name context forever, level 8';
    Session altered.
    Elapsed: 00:00:00.01
    SQL> SELECT C.FOLIO_NO, C.CO_TRANS_NO TRANS_NO, to_char(C.CREATED_DATE, 'dd/mm/yyyy') DOC_DATE, DECODE(PP.NAME, NULL, D.EMP_NAME, PP.NAME) LODGED_BY, decode(sf_fetch_datechange(c.co_trans_no, C.CO_TRANS_ID), Null, '-', sf_fetch_datechange(c.co_trans_no, C.CO_TRANS_ID)) DATE_CHANGE, P.RECEIPT_NO, decode(c.co_trans_id,'A020',(select nvl(base_trans_id,co_trans_id) from co_form5a_trans f where f.co_trans_no=c.co_trans_no),c.co_trans_id) TRANS_ID,(case when  decode(c.co_trans_id,'A020',(select nvl(base_trans_id,co_trans_id) from co_form5a_trans f where f.co_trans_no=c.co_trans_no),c.co_trans_id)='AR20' then 1 when  decode(c.co_trans_id,'A020',(select nvl(base_trans_id,co_trans_id) from co_form5a_trans f where f.co_trans_no=c.co_trans_no),c.co_trans_id)='AR03' then 2 end) TRANS_TYPE FROM CO_TRANS_MASTER C, PAYMENT_DETAIL P, PEOPLE_PROFILE PP, SC_AGENT_EMP D, M_CAA_TRANS E     where '1' <> TRIM(UPPER('S0750070Z')) and (C.CO_TRANS_ID in TRIM(UPPER('AR20')) OR C.CO_TRANS_ID in TRIM(UPPER('AR03'))OR c.co_trans_id IN TRIM (UPPER ('A020')))and C.CO_TRANS_NO = P.TRANS_NO and (C.VOID_IND = 'N' or C.VOID_IND is Null) and C.CREATED_BY = PP.PP_ID(+) and C.PROF_NO = D.PROF_NO(+) and C.CREATED_BY = D.EMP_ID (+) and TRIM(UPPER(C.CO_NO)) =  TRIM(UPPER('200101586W')) and c.co_trans_id = e.trans_id (+) order by FOLIO_NO;
    10 rows selected.
    Elapsed: 00:03:42.27
    Execution Plan
    Plan hash value: 2520189693
    | Id  | Operation                         | Name                    | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT                  |                         |   592 | 85248 | 16573   (1)| 00:03:19 |
    |   1 |  TABLE ACCESS BY INDEX ROWID      | CO_FORM5A_TRANS         |     1 |    20 |     2   (0)| 00:00:01 |
    |*  2 |   INDEX UNIQUE SCAN               | SYS_C0059692            |     1 |       |     1   (0)| 00:00:01 |
    |   3 |  TABLE ACCESS BY INDEX ROWID      | CO_FORM5A_TRANS         |     1 |    20 |     2   (0)| 00:00:01 |
    |*  4 |   INDEX UNIQUE SCAN               | SYS_C0059692            |     1 |       |     1   (0)| 00:00:01 |
    |   5 |   TABLE ACCESS BY INDEX ROWID     | CO_FORM5A_TRANS         |     1 |    20 |     2   (0)| 00:00:01 |
    |*  6 |    INDEX UNIQUE SCAN              | SYS_C0059692            |     1 |       |     1   (0)| 00:00:01 |
    |   7 |  SORT ORDER BY                    |                         |   592 | 85248 | 16573   (1)| 00:03:19 |
    |   8 |   NESTED LOOPS                    |                         |       |       |            |          |
    |   9 |    NESTED LOOPS                   |                         |   592 | 85248 | 16572   (1)| 00:03:19 |
    |  10 |     NESTED LOOPS OUTER            |                         |   477 | 54855 | 15329   (1)| 00:03:04 |
    |  11 |      NESTED LOOPS OUTER           |                         |   477 | 41499 | 14374   (1)| 00:02:53 |
    |  12 |       INLIST ITERATOR             |                         |       |       |            |          |
    |* 13 |        TABLE ACCESS BY INDEX ROWID| CO_TRANS_MASTER         |   477 | 22896 | 14367   (1)| 00:02:53 |
    |* 14 |         INDEX RANGE SCAN          | IDX_CO_TRANS_ID         | 67751 |       |   150   (1)| 00:00:02 |
    |  15 |       TABLE ACCESS BY INDEX ROWID | SC_AGENT_EMP            |     1 |    39 |     1   (0)| 00:00:01 |
    |* 16 |        INDEX UNIQUE SCAN          | PK_SC_AGENT_EMP         |     1 |       |     0   (0)| 00:00:01 |
    |  17 |      TABLE ACCESS BY INDEX ROWID  | PEOPLE_PROFILE          |     1 |    28 |     2   (0)| 00:00:01 |
    |* 18 |       INDEX UNIQUE SCAN           | SYS_C0063100            |     1 |       |     1   (0)| 00:00:01 |
    |* 19 |     INDEX RANGE SCAN              | IDX_PAY_DETAIL_TRANS_NO |     1 |       |     2   (0)| 00:00:01 |
    |  20 |    TABLE ACCESS BY INDEX ROWID    | PAYMENT_DETAIL          |     1 |    29 |     3   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - access("F"."CO_TRANS_NO"=:B1)
       4 - access("F"."CO_TRANS_NO"=:B1)
       6 - access("F"."CO_TRANS_NO"=:B1)
      13 - filter(TRIM(UPPER("SYS_ALIAS_3"."CO_NO"))='200101586W' AND ("SYS_ALIAS_3"."VOID_IND" IS NULL
                  OR "SYS_ALIAS_3"."VOID_IND"='N'))
      14 - access("SYS_ALIAS_3"."CO_TRANS_ID"='A020' OR "SYS_ALIAS_3"."CO_TRANS_ID"='AR03' OR
                  "SYS_ALIAS_3"."CO_TRANS_ID"='AR20')
      16 - access("SYS_ALIAS_3"."PROF_NO"="D"."PROF_NO"(+) AND
                  "SYS_ALIAS_3"."CREATED_BY"="D"."EMP_ID"(+))
      18 - access("SYS_ALIAS_3"."CREATED_BY"="PP"."PP_ID"(+))
      19 - access("SYS_ALIAS_3"."CO_TRANS_NO"="P"."TRANS_NO")
    Statistics
             51  recursive calls
              0  db block gets
         651812  consistent gets
          92202  physical reads
              0  redo size
           1594  bytes sent via SQL*Net to client
            524  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              1  sorts (memory)
              0  sorts (disk)
             10  rows processed
    SQL>
    SQL> disconnect
    Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
    With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
    Data Mining and Real Application Testing options
    SQL> Thanks in advance!

    Hi Raj,
    I have given the output below as you requested....
    QL>  select * from table(dbms_xplan.display_cursor(null, null, 'ALLSTATS LAST'));
    PLAN_TABLE_OUTPUT
    SQL_ID  0taz7ckjm41yv, child number 1
    SELECT C.FOLIO_NO, C.CO_TRANS_NO TRANS_NO, to_char(C.CREATED_DATE,
    'dd/mm/yyyy') DOC_DATE, DECODE(PP.NAME, NULL, D.EMP_NAME, PP.NAME)
    LODGED_BY, decode(sf_fetch_datechange(c.co_trans_no, C.CO_TRANS_ID),
    Null, '-', sf_fetch_datechange(c.co_trans_no, C.CO_TRANS_ID))
    DATE_CHANGE, P.RECEIPT_NO, decode(c.co_trans_id,'A020',(select
    nvl(base_trans_id,co_trans_id) from co_form5a_trans f where
    f.co_trans_no=c.co_trans_no),c.co_trans_id) TRANS_ID,(case when
    decode(c.co_trans_id,'A020',(select nvl(base_trans_id,co_trans_id) from
    co_form5a_trans f where f.co_trans_no=c.co_trans_no),c.co_trans_id)='AR2
    0' then 1 when  decode(c.co_trans_id,'A020',(select
    nvl(base_trans_id,co_trans_id) from co_form5a_trans f where
    f.co_trans_no=c.co_trans_no),c.co_trans_id)='AR03' then 2 end)
    TRANS_TYPE FROM CO_TRANS_MASTER C, PAYMENT_DETAIL P, PEOPLE_PROFILE PP,
    SC_AGENT_EMP D, M_CAA_TRANS E where '1' <> TRIM(UPPER('S0750070Z')) and
    (C.CO_TRANS_ID in TRIM(UPPER('AR20')) OR C.CO_TRANS_ID in
    TRIM(UPPER('AR03'))OR c.co
    Plan hash value: 4175354585
    | Id  | Operation                        | Name                    | E-Rows |  OMem |  1Mem | Used-Mem |
    |   0 | SELECT STATEMENT                 |                         |        |       |       |          |
    |   1 |  TABLE ACCESS BY INDEX ROWID     | CO_FORM5A_TRANS         |      1 |       |       |          |
    |*  2 |   INDEX UNIQUE SCAN              | SYS_C0059692            |      1 |       |       |          |
    |   3 |  TABLE ACCESS BY INDEX ROWID     | CO_FORM5A_TRANS         |      1 |       |       |          |
    |*  4 |   INDEX UNIQUE SCAN              | SYS_C0059692            |      1 |       |       |          |
    |   5 |   TABLE ACCESS BY INDEX ROWID    | CO_FORM5A_TRANS         |      1 |       |       |          |
    |*  6 |    INDEX UNIQUE SCAN             | SYS_C0059692            |      1 |       |       |          |
    |   7 |  SORT ORDER BY                   |                         |     12 |  2048 |  2048 | 2048  (0)|
    |   8 |   NESTED LOOPS                   |                         |        |       |       |          |
    |   9 |    NESTED LOOPS                  |                         |     12 |       |       |          |
    |  10 |     NESTED LOOPS OUTER           |                         |     10 |       |       |          |
    |  11 |      NESTED LOOPS OUTER          |                         |     10 |       |       |          |
    |* 12 |       TABLE ACCESS FULL          | CO_TRANS_MASTER         |     10 |       |       |          |
    |  13 |       TABLE ACCESS BY INDEX ROWID| SC_AGENT_EMP            |      1 |       |       |          |
    |* 14 |        INDEX UNIQUE SCAN         | PK_SC_AGENT_EMP         |      1 |       |       |          |
    |  15 |      TABLE ACCESS BY INDEX ROWID | PEOPLE_PROFILE          |      1 |       |       |          |
    |* 16 |       INDEX UNIQUE SCAN          | SYS_C0063100            |      1 |       |       |          |
    |* 17 |     INDEX RANGE SCAN             | IDX_PAY_DETAIL_TRANS_NO |      1 |       |       |          |
    |  18 |    TABLE ACCESS BY INDEX ROWID   | PAYMENT_DETAIL          |      1 |       |       |          |
    Predicate Information (identified by operation id):
       2 - access("F"."CO_TRANS_NO"=:B1)
       4 - access("F"."CO_TRANS_NO"=:B1)
       6 - access("F"."CO_TRANS_NO"=:B1)
      12 - filter((INTERNAL_FUNCTION("SYS_ALIAS_3"."CO_TRANS_ID") AND
                  TRIM(UPPER("SYS_ALIAS_3"."CO_NO"))='200101586W' AND ("SYS_ALIAS_3"."VOID_IND" IS NULL OR
                  "SYS_ALIAS_3"."VOID_IND"='N')))
      14 - access("SYS_ALIAS_3"."PROF_NO"="D"."PROF_NO" AND "SYS_ALIAS_3"."CREATED_BY"="D"."EMP_ID")
      16 - access("SYS_ALIAS_3"."CREATED_BY"="PP"."PP_ID")
      17 - access("SYS_ALIAS_3"."CO_TRANS_NO"="P"."TRANS_NO")
    Note
       - cardinality feedback used for this statement
       - Warning: basic plan statistics not available. These are only collected when:
           * hint 'gather_plan_statistics' is used for the statement or
           * parameter 'statistics_level' is set to 'ALL', at session or system level
    65 rows selected.

Maybe you are looking for

  • LDAP Users & Home Directories

    Hello, any help would be much appreciated on this one! I have a Dual 2.3Ghz Xserve G5 running OSX Server 10.4.9 with a 700Gb Xserve RAID. All users home directories are stored on the RAID. I had 1361 users on the LDAP Open Directory system and all wa

  • Scale transformation of a symbol within a motion tween

    Hi all, I'm making a very simple animated flight plan with 3 airfields and six airplanes as seen from the top. To imitate the effect of take off and landing I want to be able to change the size of the plane when it flies. Only trouble is I can do tha

  • How to automate refresh of the existing Xcelsius 4.5 dashboard

    Hi, I have bunch of dashboards developed in 4.5. These dashboards are manually refreshed via updating the spreadsheets and importing and exporting to swf file. Now my company wants all this process to be automated. I would like to know more about aut

  • LR windows interface vs mac

    I did see claims that virtually there was no diff between these two. However, my entire windows TITLE BAR has changed, there is no minimize or close (x) button and it only shows if I point in that direciton. Does anybody know how to revert to the way

  • Calendar on iPad not updating after iOS8

    After updating to ios8 i noticed that the calendar on My ipad wouldnt update events added on my i Phone. Events added on the ipad do sync over to the iphone. I tried turning calendar sync on and off on the ipad, but that just added two entries for so