rownum hurt Oracle explain plan

SCOTT@oracle10g>create table t as select * from dba_objects;

Table created.

SCOTT@oracle10g>alter table t modify CREATED date not null;

Table altered.

SCOTT@oracle10g>insert into t select * from t;

50416 rows created.

SCOTT@oracle10g>insert into t select * from t;

100832 rows created.

SCOTT@oracle10g>insert into t select * from t;

201664 rows created.

SCOTT@oracle10g>commit;

Commit complete.

SCOTT@oracle10g>create index t_created on t(created) nologging;

Index created.

SCOTT@oracle10g>select * from v$version;

BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
PL/SQL Release 10.2.0.3.0 - Production
CORE    10.2.0.3.0      Production
TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
NLSRTL Version 10.2.0.3.0 - Production


SCOTT@oracle10g>set autot trace 
SCOTT@oracle10g>select t.owner,t.object_name   from 
  2  (select rid from (
  3  select rownum rn,rid from 
  4  (select rowid rid from t order by created)
  5  where rownum<100035)
  6  where rn>100000) h, t
  7  where t.rowid=h.rid;

34 rows selected.


Execution Plan
----------------------------------------------------------
Plan hash value: 3449471415

--------------------------------------------------------------------------------
---------

| Id  | Operation           | Name      | Rows  | Bytes |TempSpc| Cost (%CPU)| T
ime     |

--------------------------------------------------------------------------------
---------

|   0 | SELECT STATEMENT    |           |   100K|    11M|       |  4776   (2)| 0
0:00:58 |

|*  1 |  HASH JOIN          |           |   100K|    11M|  3616K|  4776   (2)| 0
0:00:58 |

|*  2 |   VIEW              |           |   100K|  2442K|       |  1116   (2)| 0
0:00:14 |

|*  3 |    COUNT STOPKEY    |           |       |       |       |            |
        |

|   4 |     VIEW            |           |   440K|  5157K|       |  1116   (2)| 0
0:00:14 |

|   5 |      INDEX FULL SCAN| T_CREATED |   440K|  9024K|       |  1116   (2)| 0
0:00:14 |

|   6 |   TABLE ACCESS FULL | T         |   440K|    39M|       |  1237   (2)| 0
0:00:15 |

--------------------------------------------------------------------------------
---------


Predicate Information (identified by operation id):
---------------------------------------------------

   1 - access("T".ROWID="RID")
   2 - filter("RN">100000)
   3 - filter(ROWNUM<100035)

Note
-----
   - dynamic sampling used for this statement


Statistics
----------------------------------------------------------
          0  recursive calls
          0  db block gets
       5814  consistent gets
          0  physical reads
          0  redo size
       1588  bytes sent via SQL*Net to client
        422  bytes received via SQL*Net from client
          4  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
         34  rows processed    

here ,oracle don't choose the best explain plan ,I think becase  oracle compute cadinality 100k ,so it don't choose nest loop,why oracle can't compute cardinality 35 here ??

|*  2 |   VIEW              |           |   100K|  2442K|       |  1116   (2)| 0



SCOTT@oracle10g>select  t.owner,t.object_name   from t where rowid in 
  2      (select rid from (
  3      select rownum rn,rid from 
  4      (select rowid rid from t order by created)
  5      where rownum<100035)
  6      where rn>100000) 
  7  
SCOTT@oracle10g>/

34 rows selected.


Execution Plan
----------------------------------------------------------
Plan hash value: 1566335206

--------------------------------------------------------------------------------
---------

| Id  | Operation                   | Name      | Rows  | Bytes | Cost (%CPU)| T
ime     |

--------------------------------------------------------------------------------
---------

|   0 | SELECT STATEMENT            |           |     1 |   107 |  1586   (2)| 0
0:00:20 |

|   1 |  NESTED LOOPS               |           |     1 |   107 |  1586   (2)| 0
0:00:20 |

|   2 |   VIEW                      | VW_NSO_1  |   100K|  1172K|  1116   (2)| 0
0:00:14 |

|   3 |    HASH UNIQUE              |           |     1 |  2442K|            |
        |

|*  4 |     VIEW                    |           |   100K|  2442K|  1116   (2)| 0
0:00:14 |

|*  5 |      COUNT STOPKEY          |           |       |       |            |
        |

|   6 |       VIEW                  |           |   440K|  5157K|  1116   (2)| 0
0:00:14 |

|   7 |        INDEX FULL SCAN      | T_CREATED |   440K|  9024K|  1116   (2)| 0
0:00:14 |

|   8 |   TABLE ACCESS BY USER ROWID| T         |     1 |    95 |     1   (0)| 0
0:00:01 |

--------------------------------------------------------------------------------
---------


Predicate Information (identified by operation id):
---------------------------------------------------

   4 - filter("RN">100000)
   5 - filter(ROWNUM<100035)

Note
-----
   - dynamic sampling used for this statement


Statistics
----------------------------------------------------------
          0  recursive calls
          0  db block gets
        301  consistent gets
          0  physical reads
          0  redo size
       1896  bytes sent via SQL*Net to client
        422  bytes received via SQL*Net from client
          4  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
         34  rows processed

SCOTT@oracle10g>select /*+ordered use_nl(t)*/ t.owner,t.object_name   from 
  2  (select rid from (
  3  select rownum rn,rid from 
  4  (select rowid rid from t order by created)
  5  where rownum<100035)
  6  where rn>100000) h, t
  7  where t.rowid=h.rid;

34 rows selected.


Execution Plan
----------------------------------------------------------
Plan hash value: 3976541160

--------------------------------------------------------------------------------
---------

| Id  | Operation                   | Name      | Rows  | Bytes | Cost (%CPU)| T
ime     |

--------------------------------------------------------------------------------
---------

|   0 | SELECT STATEMENT            |           |   100K|    11M|   101K  (1)| 0
0:20:16 |

|   1 |  NESTED LOOPS               |           |   100K|    11M|   101K  (1)| 0
0:20:16 |

|*  2 |   VIEW                      |           |   100K|  2442K|  1116   (2)| 0
0:00:14 |

|*  3 |    COUNT STOPKEY            |           |       |       |            |
        |

|   4 |     VIEW                    |           |   440K|  5157K|  1116   (2)| 0
0:00:14 |

|   5 |      INDEX FULL SCAN        | T_CREATED |   440K|  9024K|  1116   (2)| 0
0:00:14 |

|   6 |   TABLE ACCESS BY USER ROWID| T         |     1 |    95 |     1   (0)| 0
0:00:01 |

--------------------------------------------------------------------------------
---------


Predicate Information (identified by operation id):
---------------------------------------------------

   2 - filter("RN">100000)
   3 - filter(ROWNUM<100035)

Note
-----
   - dynamic sampling used for this statement


Statistics
----------------------------------------------------------
          0  recursive calls
          0  db block gets
        304  consistent gets
          0  physical reads
          0  redo size
       1588  bytes sent via SQL*Net to client
        422  bytes received via SQL*Net from client
          4  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
         34  rows processed   

Tags: Database

Similar Questions

  • Explain the explain plan

    decide to move to optimization soon. Book says join faster that the subquery in this example because the analyses involved. The "cost" to the subquery appears lower than the cost for the join. So it is confusing to me - aka How should I be interpreting this.

    Plan of subquery:

    image2.png.jpg

    join plan

    image2.png.jpg

    as you can see that the plan for the subquery has less than a cost. Could someone explain these outputs as to which application is more effective. I need to start somewhere.

    Thank you!

    The BEST way to get help when you ask questions is:

    1 ask questions on SPECIFIC things

    2. tell us EXACTLY what term, value, etc. ask abaout

    Book says join faster that the subquery in this example because the analyses involved. The "cost" to the subquery appears lower than the cost for the join. So it is confusing to me - aka How should I be interpreting this.

    OK - what BOOK are you talking about? There is not much interest to mention a book if you're not going to tell us which book it and provide a link to it and even a page number. This gives us the SCOPE of your question.

    This "cost for the subquery" are you talking about? Be specifc. It is in one of the plans that you posted? What plan? Whose cost is it? For example, you could say:

    I have a question for the foreground below. Why is the cost to the xx line lower than the cost of the second plan on line AA?

    This question refers CLEARLY to the info we're talking. The way in which you stating the question, we try to guess what plan and the lines you want to say.

    subquery plan:
    
    
    join plan
    
    
    as you can see the subquery plan has less of a cost. Could someone explain from these outputs as to which query is more efficient. I need to start from somewhere.
    

    Are you talking about line #1 in each of these plans?

    Please edit your post and tell us EXACTLY what you ask in the topic and refer to values and SPECIFIC lines. Also post a link to the book and a reference to a page number you got the information from.

    The optimizer generally chooses the REAL implementation with the lowest cost plan. It is not clear whether the plans that you have posted are ACTUAL spending plans that Oracle really determined and used or just explain plans.for what Oracle thought it might use.

    If the statistics are not up-to-date these plans do not yet reflect the reality of the data.

    And if the amount of data is a small number of blocks or other of these plans can run better than the other in reality.

    You can find this Oracle white paper "Explain the Plan explaining" useful

    http://www.Oracle.com/technetwork/database/bi-Datawarehousing/TWP-explain-the-explain-plan-052011-393674.PDF

  • Need help with understanding explain plan

    Hi all

    I'm trying to understand the subject of the explain Plan, and while I was reading a document and from there I found one of the query that is below:

    Query

    SELECT A.customer_name,

    Count (distinct b.invoice_id) 'open invoices. "

    Count (c.invoice_id) "open invoice".

    Clients has,

    b invoices,

    c invoices_items

    WHERE b.invoice_status = 'OPEN'

    AND A.customer_id = b.customer_id

    AND c.invoice_id (+) = b.invoice_id

    A.customer_name GROUP

    Explain Plan

    See attached file...

    explain_plan.JPG

    I appreciate if someone explain this attached plan really explain in detail for my purpose of learning. Thanks in advance

    Concerning

    Muzz

    I'm trying to understand the subject of the explain Plan

    Excellent!

    I suggest you just started reading the book of Maria Colgan white "Explain the explain Plan".

    http://www.Oracle.com/technetwork/database/bi-Datawarehousing/TWP-explain-the-explain-plan-052011-393674.PDF

    This white paper examines the different lines, you will see in a plan and what they mean.

  • Explain plan for select distinct

    I got 1 of the online test and there the question has been asked. I have already answered but curious to cross-check my response with your advice...

    Question

    Explain what information plan if the show room in SQL indicates that a separate select statement is made in the SQL.


    The choices are:

    Sort by a join

    b sort by

    c single fate

    d sort aggregate

    group e - sort by

    My answer

    I gave aggregates of SORT but it seems that his unique kind, because when I run explain plan then I see (unique) hash. Please guide


    SEPARATE will identify unique rows. So in the given choice it would be KIND of UNIQUE. But oracle could go other plans as UNIQUE HASH or same INDEX FULL SCAN.

    Look at the oracle does not SORT.

    SQL> select distinct ename from emp;
    ENAME
    ------
    SMITH
    BLAKE
    CLARK
    KING
    ADAMS
    TURNER
    ALLEN
    SCOTT
    JONES
    MARTIN
    WARD
    11 rows selected.
    SQL> select * from table(dbms_xplan.display_cursor);
    PLAN_TABLE_OUTPUT
    ---------------------------------------------------------------------------------
    SQL_ID  6b32yqumjmp9b, child number 0
    -------------------------------------
    select distinct ename from emp
    Plan hash value: 984151148
    ---------------------------------------------------------------------------
    | Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    ---------------------------------------------------------------------------
    |   0 | SELECT STATEMENT   |      |       |       |     3 (100)|          |
    |   1 |  HASH UNIQUE       |      |    11 |    66 |     3  (34)| 00:00:01 |
    |   2 |   TABLE ACCESS FULL| EMP  |    11 |    66 |     2   (0)| 00:00:01 |
    ---------------------------------------------------------------------------
    
    14 rows selected.
    

    Let me make an explicit ORDER BY for her to performa SORT.

    SQL> select distinct ename from emp order by 1;
    ENAME
    ------
    ADAMS
    ALLEN
    BLAKE
    CLARK
    JONES
    KING
    MARTIN
    SCOTT
    SMITH
    TURNER
    WARD
    11 rows selected.
    SQL> select * from table(dbms_xplan.display_cursor);
    PLAN_TABLE_OUTPUT
    -------------------------------------------------------------------------------
    SQL_ID  f72vjx5rmm0z4, child number 0
    -------------------------------------
    select distinct ename from emp order by 1
    Plan hash value: 725351111
    ---------------------------------------------------------------------------
    | Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    ---------------------------------------------------------------------------
    |   0 | SELECT STATEMENT   |      |       |       |     4 (100)|          |
    |   1 |  SORT UNIQUE       |      |    11 |    66 |     3  (34)| 00:00:01 |
    |   2 |   TABLE ACCESS FULL| EMP  |    11 |    66 |     2   (0)| 00:00:01 |
    ---------------------------------------------------------------------------
    
    14 rows selected.
    SQL>
    

    Version - 10.2.0.5.0

  • explain plan

    Hi all

    I use under version

    Connected to Oracle Database 11g Express Edition Release 11.2.0.2.0

    SQL > SELECT DEPTNO

    DEPT 2

    3. WHERE DEPTNO! = ALL

    4 (DEPTNO SELECT FROM EMP WHERE DEPTNO IS NOT NULL);

    DEPTNO

    ----------

    40

    Execution plan

    ----------------------------------------------------------

    Hash value of plan: 474461924

    ---------------------------------------------------------------------------

    | ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time |

    ---------------------------------------------------------------------------

    |   0 | SELECT STATEMENT |      |     4.   104.     5 (20) | 00:00:01 |

    |*  1 |  HASH ANTI JOIN |      |     4.   104.     5 (20) | 00:00:01 |

    |   2.   TABLE ACCESS FULL | DEPT |     4.    52.     2 (0) | 00:00:01 |

    |*  3 |   TABLE ACCESS FULL | EMP |    14.   182.     2 (0) | 00:00:01 |

    ---------------------------------------------------------------------------

    Information of predicates (identified by the operation identity card):

    ---------------------------------------------------

    1 - access ("DEPTNO" ="DEPTNO")

    3 - filter ("DEPTNO" IS NOT NULL)

    Note

    -----

    -dynamic sample used for this survey (level = 2)

    ----------------------------------------------------------------------------------------------------

    SQL > SELECT DEPTNO FROM DEPT

    2. IF YOU USE NOT IN DEPTNO (DEPTNO SELECT FROM EMP WHERE DEPTNO IS NOT NULL);

    DEPTNO

    ----------

    40

    Execution plan

    ----------------------------------------------------------

    Hash value of plan: 474461924

    ---------------------------------------------------------------------------

    | ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time |

    ---------------------------------------------------------------------------

    |   0 | SELECT STATEMENT |      |     4.   104.     5 (20) | 00:00:01 |

    |*  1 |  HASH ANTI JOIN |      |     4.   104.     5 (20) | 00:00:01 |

    |   2.   TABLE ACCESS FULL | DEPT |     4.    52.     2 (0) | 00:00:01 |

    |*  3 |   TABLE ACCESS FULL | EMP |    14.   182.     2 (0) | 00:00:01 |

    ---------------------------------------------------------------------------

    Information of predicates (identified by the operation identity card):

    ---------------------------------------------------

    1 - access ("DEPTNO" ="DEPTNO")

    3 - filter ("DEPTNO" IS NOT NULL)

    Note

    -----

    -dynamic sample used for this survey (level = 2)

    --------------------------------------------------------------------------------------------------

    SQL > SELECT DEPTNO

    DEPT 2

    3. WHERE THERE IS NO

    4 (SELECT * FROM EMP WHERE EMP.) DEPTNO = DEPT. DEPTNO);

    DEPTNO

    ----------

    40

    Execution plan

    ----------------------------------------------------------

    Hash value of plan: 474461924

    ---------------------------------------------------------------------------

    | ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time |

    ---------------------------------------------------------------------------

    |   0 | SELECT STATEMENT |      |     4.   104.     5 (20) | 00:00:01 |

    |*  1 |  HASH ANTI JOIN |      |     4.   104.     5 (20) | 00:00:01 |

    |   2.   TABLE ACCESS FULL | DEPT |     4.    52.     2 (0) | 00:00:01 |

    |   3.   TABLE ACCESS FULL | EMP |    14.   182.     2 (0) | 00:00:01 |

    ---------------------------------------------------------------------------

    Information of predicates (identified by the operation identity card):

    ---------------------------------------------------

    1 - access("EMP".") DEPTNO "=" DEPT ". ("' DEPTNO ')

    Note

    -----

    -dynamic sample used for this survey (level = 2)

    My doubt is as all the query 3 generates even explain plan

    Can we consider that all queries to be the same as in the review of the performance.

    Thank you

    NOT IN and EXISTS are not the same. If there is only one NULL value in the sub query used with NOT IN then any condition fails.

    Here is a note of AskTom on this topic

    https://asktom.Oracle.com/pls/Apex/f?p=100:11:0:P11_QUESTION_ID:442029737684

  • Understanding explain plan

    Hi gurus

    I try to explain the plan and referring to the link that http://docs.oracle.com/database/121/TGSQL/tgsql_interp.htm#TGSQL277understand/learn, see below for more details:

    1st step

    EXPLAIN PLAN

    SET statement_id = "ex_plan1" FOR

    SELECT phone_number

    Employees

    WHERE phone_number AS 650% ';

    step 2

    SELECT PLAN_TABLE_OUTPUT

    TABLE (DBMS_XPLAN. DISPLAY (NULL, 'ex_plan1', 'BASIC'));

    Output

    PLAN_TABLE_OUTPUT

    Hash value of plan: 1445457117

    ---------------------------------------

    | ID | Operation | Name |

    ---------------------------------------

    |   0 | SELECT STATEMENT |           |

    |   1.  TABLE ACCESS FULL | EMPLOYEES |

    ---------------------------------------

    If you have watched the plan explained above then in operation, he leads shows TABLE ACCESS FULL.

    Let's see now another for we explain with other data, see below

    Step 3

    EXPLAIN PLAN

    SET statement_id = "ex_plan2" FOR

    SELECT last_name

    Employees

    WHERE name LIKE '% Pe;

    Step 4

    SELECT PLAN_TABLE_OUTPUT

    TABLE (DBMS_XPLAN. DISPLAY (NULL, 'ex_plan2', 'BASIC'));

    Output

    PLAN_TABLE_OUTPUT

    Hash value of plan: 3085132068

    ----------------------------------------

    | ID | Operation | Name |

    ----------------------------------------

    |   0 | SELECT STATEMENT |             |

    |   1.  INDEX RANGE SCAN | EMP_NAME_IX |

    ----------------------------------------

    First Question:
    When I run the sql below:

    SELECT phone_number

    Employees

    WHERE phone_number AS 650% ';

    so why does it display FULL TABLE ACCESS

    on the other hand, when I have executed under SQL:

    SELECT last_name

    Employees

    WHERE name LIKE '% Pe;

    so why it shows INDEX RANGE SCAN even the two queries by using like operator.

    2nd question

    In step 4 in the section operation, what is the meaning of the INDEX RANGE SCAN?

    3rd issue

    In step 4, under the name of topic, what is the meaning of EMP_NAME_IX?

    Thanks in advance

    Concerning

    Shu


    All this would be in the documentation.

    The second query uses a different plan because there was a clue on last_name.

    Index range scan is exactly what it sounds like - it scans the index to find the appropriate values

    emp_name_ix is the name of the index that it scans.

  • SQL not using indexes at runtime, but by using the index in "explain plan".

    Hi all

    I am facing a problem here that I don't get to think.

    I have a SQL that makes a FULL ACCESS of TABLE into two tables and its costs are very high, but it occurs only when I run it in my program (I saw it in the session trace). If I do a "explain plan" sqlplus (SQL Navigator or PLSQL Developer) it shows that he use indexes and have a low cost. I already checked the statistics from both tables, and they are up to date.

    Did someone never facing a similar problem or knows something I can do to find my problem?

    Thank you all very much.

    Hello

    As far as I KNOW, optimizer Oracle never guarantees that an Index scan in query explain plan will be necessarily used during query execution.

    ORACLE-BASE - DBMS_XPLAN: Oracle display execution Plans

    Could you please read the above, run the query, as described and check the execution using DBMS_XPLAN plan. The cursor cache DISPLAY_CURSOR and not PLAN_TABLEs.

  • 3 clues on 3 different columns, but explain plan shows full table scan for select queries

    I have a table - used and have index - functional ind1 (upper (f_name)), index - (emp_id) ind2 ind3 (upper (l_name) functional on 3 columns diffferent - what, emp_id, l_name respectively.) Now when I check explain plans for sub queries, they all have two shows complete table for the employee of the table scan. FYI - employee table is non-parittioned.

    Can someone tell me why 3 indices are not used here?

    (1) select emp_id, upper (f_name), upper (l_name) of the employee

    (2) select upper (f_name), mp_id, upper (l_name) of the employee

    where upper (f_name) = upper (f_name)

    and emp_id = emp_id

    and upper (l_name) = upper (l_name)

    If I can push oracle (version 11) to use these indexes somewho - maybe using tips? Any help is appreciated.

    
    Observations:
    
    SQL> desc emp1;
     Name                                      Null?    Type
     ----------------------------------------- -------- -----------------
     EMPID                                      NOT NULL NUMBER
     F_NAME                                    NOT NULL VARCHAR2(3)
     L_NAME                                    NOT NULL VARCHAR2(3)
     SALARY                                    NUMBER
     JOB_ROLE                                 VARCHAR2(5)
     DEPTID                                     NUMBER
    
    create index idx2 on emp1(empid);
    create index idx1 on emp1(upper(f_name) );
    create index idx3 on emp1(f_name,empid, l_name);
    exec dbms_stats.gather_table_stats(user,'EMP1', cascade=>true);
    
    8 rows selected.
    
    SQL> explain plan for
      2  select /*+ index_join(e idx1 idx2 idx3)*/   upper(l_name),empid, upper(f_name) from emp1 e;
    
    Explained.
    
    SQL> select * from table(dbms_xplan.display);
    
    PLAN_TABLE_OUTPUT
    --------------------------------------------------------------------------------
    Plan hash value: 3449967945
    
    -------------------------------------------------------------------------
    | Id  | Operation        | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    -------------------------------------------------------------------------
    |   0 | SELECT STATEMENT |      | 20000 |   175K|    14   (0)| 00:00:01 |
    |   1 |  INDEX FULL SCAN | IDX3 | 20000 |   175K|    14   (0)| 00:00:01 |
    -------------------------------------------------------------------------
    
    8 rows selected.
    
    SQL> explain plan for
      2  select    upper(f_name),empid,upper(l_name) from emp1 e;
    
    Explained.
    
    SQL> select * from table(dbms_xplan.display);
    
    PLAN_TABLE_OUTPUT
    --------------------------------------------------------------------------------
    Plan hash value: 3449967945
    
    -------------------------------------------------------------------------
    | Id  | Operation        | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    -------------------------------------------------------------------------
    |   0 | SELECT STATEMENT |      | 20000 |   175K|    14   (0)| 00:00:01 |
    |   1 |  INDEX FULL SCAN | IDX3 | 20000 |   175K|    14   (0)| 00:00:01 |
    -------------------------------------------------------------------------
    
    8 rows selected.
    
    SQL> explain plan for
      2  select /*+ index_ffs(e idx3)*/   upper(l_name),empid, upper(f_name) from emp1 e;
    
    Explained.
    
    SQL> select * from table(dbms_xplan.display);
    
    PLAN_TABLE_OUTPUT
    --------------------------------------------------------------------------------
    Plan hash value: 2496145112
    
    -----------------------------------------------------------------------------
    | Id  | Operation            | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    -----------------------------------------------------------------------------
    |   0 | SELECT STATEMENT     |      | 20000 |   175K|    14   (0)| 00:00:01 |
    |   1 |  INDEX FAST FULL SCAN| IDX3 | 20000 |   175K|    14   (0)| 00:00:01 |
    -----------------------------------------------------------------------------
    
    8 rows selected.
    
    SQL> explain plan for
      2  select /*+ index(e idx3)*/   upper(l_name),empid, upper(f_name) from emp1 e;
    
    Explained.
    
    SQL> select * from table(dbms_xplan.display);
    
    PLAN_TABLE_OUTPUT
    --------------------------------------------------------------------------------
    Plan hash value: 3449967945
    
    -------------------------------------------------------------------------
    | Id  | Operation        | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    -------------------------------------------------------------------------
    |   0 | SELECT STATEMENT |      | 20000 |   175K|    14   (0)| 00:00:01 |
    |   1 |  INDEX FULL SCAN | IDX3 | 20000 |   175K|    14   (0)| 00:00:01 |
    -------------------------------------------------------------------------
    
    8 rows selected.
    
    SQL> explain plan for
      2  select    upper(f_name),empid,upper(l_name) from emp1 e;
    
    Explained.
    
    SQL> select * from table(dbms_xplan.display);
    
    PLAN_TABLE_OUTPUT
    --------------------------------------------------------------------------------
    Plan hash value: 3449967945
    
    -------------------------------------------------------------------------
    | Id  | Operation        | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    -------------------------------------------------------------------------
    |   0 | SELECT STATEMENT |      | 20000 |   175K|    14   (0)| 00:00:01 |
    |   1 |  INDEX FULL SCAN | IDX3 | 20000 |   175K|    14   (0)| 00:00:01 |
    -------------------------------------------------------------------------
    
    8 rows selected.
    
    SQL> drop index idx3;
    
    Index dropped.
    
    SQL> explain plan for
      2     select   upper(l_name),empid, upper(f_name) from emp1 e;
    
    Explained.
    
    SQL> select * from table(dbms_xplan.display);
    
    PLAN_TABLE_OUTPUT
    --------------------------------------------------------------------------------
    Plan hash value: 3330885630
    
    --------------------------------------------------------------------------
    | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    --------------------------------------------------------------------------
    |   0 | SELECT STATEMENT  |      | 20000 |   175K|    18   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS FULL| EMP1 | 20000 |   175K|    18   (0)| 00:00:01 |
    --------------------------------------------------------------------------
    
    8 rows selected.
    
    SQL> create index idx3 on emp1(f_name,empid, l_name );
    
    Index created.
    
    SQL>  explain plan for
      2     select   upper(l_name),empid, upper(f_name) from emp1 e;
    
    Explained.
    
    SQL> select * from table(dbms_xplan.display);
    
    PLAN_TABLE_OUTPUT
    --------------------------------------------------------------------------------
    Plan hash value: 3449967945
    
    -------------------------------------------------------------------------
    | Id  | Operation        | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    -------------------------------------------------------------------------
    |   0 | SELECT STATEMENT |      | 20000 |   175K|    14   (0)| 00:00:01 |
    |   1 |  INDEX FULL SCAN | IDX3 | 20000 |   175K|    14   (0)| 00:00:01 |
    
  • Look at an explain plan

    version 11.2.0.4.0

    Solaris x 64 operating system

    Toad 9.0

    Hi, I'm trying to give a new user privleges see explain the plan. for this, I did the following

    grant select_catalog_role < username >;

    Grant execute on sys.dbms_xplan_type < username >;

    Grant execute on sys.dbms_xplan_type_table < username >;

    It didn't work, and then I have granted the select privilege on the table of existing plan to a new user.

    Grant select on sys.plan_table < username >;

    create synonym plan_table for sys.plan_table

    Yet it did not work, I got the error "ORA-01031: insufficient privileges" when you try to view explain plan.

    I even tried to create a new table of plan in this new scheme of the user by running the utlxplan.sql, but I get an error message saying that the table already exists.

    can someone help me please on where I'm wrong.

    Thank you

    «The question one EXPLAIN PLAN statement, you must have the necessary privileges to insert rows into a table of existing output that you specify to hold execution plan.»

    You must also have the necessary privileges to run the SQL statement to determine the execution plan. If the SQL statement accesses a view, you must have privileges to access any tables and views on which the opinion is based. If the view is of another opinion which is based on a table, you must have privileges to access the other point of view and its underlying table.

    To examine the execution plan produced by a EXPLAIN PLAN statement, you must have the necessary privileges to query the table of output.

    The EXPLAIN PLAN statement is a statement data manipulation language (DML), rather than a data definition language (DDL) statement. Therefore, Oracle database does not implicitly commit changes made by one EXPLAIN PLAN statement. If you want to keep the lines that are generated by a EXPLAIN PLAN in the output table, then you must commit to the transaction that contains the statement. »

    http://docs.Oracle.com/CD/E16655_01/server.121/e17209/statements_9010.htm#sthref6316

  • explain plan for the same query diff

    Hi experts,

    Please, help me understand explain the plan.  I have tow Server (server and two server). The server are same table, even the type of database, even version Oracle (gr 11 (2), same operating system (linux Redhat 5.5) and same table and index.

    but when I explain the plan for the same query on the two server. I got diff--diff to explain the plan. reason it has different, according to my understanding, it should be same. explain please, I share the explain plan and lower indices for the two server.

    Server a

    SQL > col COLUMN_NAME format a20

    SQL > select index_name, column_name, position_colonne from user_ind_columns where table_name = 'LOAN_RUNNING_DETAILS_SOUTH"of order 1.

    INDEX_NAME COLUMN_NAME POSITION_COLONNE

    ------------------------------ -------------------- ---------------

    DATE_IND1_S LOANDATETIME 1

    IND_MSI_LN_LNS1_S MSISDN 1

    IND_MSI_LN_LNS1_S LOANDATETIME 2

    IND_MSI_LN_LNS1_S LOANSTATUS 3

    LAST_INDEX L_INDX_MSISDN_S 1

    MSISDN L_INDX_MSISDN_S 2

    SQL > select decode (status, 'N/a', 'Part Hdr', 'Global') ind_type, index_name, NULL nom_partition, status

    2 from user_indexes where table_name = 'LOAN_RUNNING_DETAILS_SOUTH '.

    3 union

    4. Select 'Local' ind_type, index_name, nom_partition, status

    5 to user_ind_partitions where index-name in (select index_name in user_indexes where table_name = 'LOAN_RUNNING_DETAILS_SOUTH')

    6 order of 1,2,3;

    IND_TYPE INDEX_NAME NOM_PARTITION STATUS

    -------- ------------------------------ ------------------------------ --------

    Global DATE_IND1_S VALID

    Global IND_MSI_LN_LNS1_S VALID

    Global L_INDX_MSISDN_S VALID

    SQL > explain plan for the small circle of MSISDN, TID, of LOAN_RUNNING_DETAILS_SOUTH where LOANDATETIME < = sysdate-2 and LOANDATETIME > sysdate-15 and LOANTYPE = 1;

    He explained.

    SQL > SQL > set line 200

    @?/rdbms/admin/utlxpls.sql

    SQL >

    PLAN_TABLE_OUTPUT

    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    Hash value of plan: 3659874059

    ------------------------------------------------------------------------------------------------------------------

    | ID | Operation | Name                       | Lines | Bytes | Cost (% CPU). Time | Pstart. Pstop |

    ------------------------------------------------------------------------------------------------------------------

    |   0 | SELECT STATEMENT |                            |  1448K |    58 M | 21973 (2) | 00:04:24 |       |       |

    |*  1 |  FILTER |                            |       |       |            |          |       |       |

    |   2.   PARTITION LIST ALL |                            |  1448K |    58 M | 21973 (2) | 00:04:24 |     1.    11.

    |*  3 |    TABLE ACCESS FULL | LOAN_RUNNING_DETAILS_SOUTH |  1448K |    58 M | 21973 (2) | 00:04:24 |     1.    11.

    ------------------------------------------------------------------------------------------------------------------

    PLAN_TABLE_OUTPUT

    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    Information of predicates (identified by the operation identity card):

    ---------------------------------------------------

    1 - filter(SYSDATE@!-2>SYSDATE@!-15)

    3 - filter("LOANTYPE"=1 AND "LOANDATETIME">SYSDATE@!-15 AND "LOANDATETIME"<=SYSDATE@!-2)

    16 selected lines.

    Second server

    SQL > select index_name, column_name, position_colonne from user_ind_columns where table_name = 'LOAN_RUNNING_DETAILS_SOUTH"of order 1.

    INDEX_NAME COLUMN_NAME POSITION_COLONNE

    ------------------------------ -------------------- ---------------

    DATE_IND1_S LOANDATETIME 1

    IND_MSI_LN_LNS1_S MSISDN 1

    IND_MSI_LN_LNS1_S LOANDATETIME 2

    IND_MSI_LN_LNS1_S LOANSTATUS 3

    LAST_INDEX L_INDX_MSISDN_S 1

    MSISDN L_INDX_MSISDN_S 2

    SQL > select decode (status, 'N/a', 'Part Hdr', 'Global') ind_type, index_name, NULL nom_partition, status

    2 from user_indexes where table_name = 'LOAN_RUNNING_DETAILS_SOUTH '.

    Union

    3 4 Select 'Local' ind_type, index_name, nom_partition, status

    5 to user_ind_partitions where index-name in (select index_name in user_indexes where table_name = 'LOAN_RUNNING_DETAILS_SOUTH')

    6 order of 1,2,3;

    IND_TYPE INDEX_NAME NOM_PARTITION STATUS

    -------- ------------------------------ ------------------------------ --------

    Global DATE_IND1_S VALID

    Global IND_MSI_LN_LNS1_S VALID

    Global L_INDX_MSISDN_S VALID

    SQL > explain plan for the small circle of MSISDN, TID, of LOAN_RUNNING_DETAILS_SOUTH where LOANDATETIME < = sysdate-2 and LOANDATETIME > sysdate-15 and LOANTYPE = 1;

    SQL > set line 200

    @?/rdbms/admin/utlxpls.sql

    SQL >

    PLAN_TABLE_OUTPUT

    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    Hash value of plan: 1161680601

    ----------------------------------------------------------------------------------------------------------------------------------

    | ID | Operation | Name                       | Lines | Bytes | Cost (% CPU). Time | Pstart. Pstop |

    ----------------------------------------------------------------------------------------------------------------------------------

    |   0 | SELECT STATEMENT |                            |     2.    84.     5 (0) | 00:00:01 |       |       |

    |*  1 |  FILTER                             |                            |       |       |            |          |       |       |

    |*  2 |   TABLE ACCESS BY INDEX ROWID | LOAN_RUNNING_DETAILS_SOUTH |     2.    84.     5 (0) | 00:00:01 | ROWID | ROWID |

    |*  3 |    INDEX RANGE SCAN | DATE_IND1_S |     2.       |     3 (0) | 00:00:01 |       |       |

    ----------------------------------------------------------------------------------------------------------------------------------

    PLAN_TABLE_OUTPUT

    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    Information of predicates (identified by the operation identity card):

    ---------------------------------------------------

    1 - filter(SYSDATE@!-2>SYSDATE@!-15)

    2 - filter ("LOANTYPE" = 1)

    3 - access("LOANDATETIME">SYSDATE@!-15 AND "LOANDATETIME"<=SYSDATE@!-2)

    17 selected lines.

    Reg,

    Hard

    Hi , HemantKChitale,

    I also update statistics manual as you say, but not see 'TABLE ACCESS FULL' good result

    What should I do? my need of production tuning, but I cannot able tune this...

    SQL > exec dbms_stats.gather_table_stats (-online 'ttt' ownname, tabname => 'LOAN_RUNNING_DETAILS_SOUTH', cascade => TRUE, estimate_percent => NULL, method_opt => 'for all columns size 254', => of degree 4);

    PL/SQL procedure successfully completed.

    SQL > explain plan for the small circle of MSISDN, TID, of LOAN_RUNNING_DETAILS_SOUTH where LOANDATETIME<=sysdate-2 and="" loandatetime="">sysdate-15 and LOANTYPE = 1;

    He explained.

    SQL > set line 200

    @?/rdbms/admin/utlxpls.sql

    SQL >

    PLAN_TABLE_OUTPUT

    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    Hash value of plan: 3659874059

    ------------------------------------------------------------------------------------------------------------------

    | ID | Operation | Name                       | Lines | Bytes | Cost (% CPU). Time | Pstart. Pstop |

    ------------------------------------------------------------------------------------------------------------------

    |   0 | SELECT STATEMENT |                            |  1874K |    75 M | 19626 (2) | 00:03:56 |       |       |

    |*  1 |  FILTER |                            |       |       |            |          |       |       |

    |   2.   PARTITION LIST ALL |                            |  1874K |    75 M | 19626 (2) | 00:03:56 |     1.    11.

    |*  3 |    TABLE ACCESS FULL | LOAN_RUNNING_DETAILS_SOUTH |  1874K |    75 M | 19626 (2) | 00:03:56 |     1.    11.

    ------------------------------------------------------------------------------------------------------------------

    PLAN_TABLE_OUTPUT

    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    Information of predicates (identified by the operation identity card):

    ---------------------------------------------------

    1 - filter(SYSDATE@!-2>SYSDATE@!-15)

    3 - filter("LOANDATETIME">SYSDATE@!-15 AND "LOANTYPE"=1 AND "LOANDATETIME")<>

    16 selected lines.

  • Explain Plan shows not good results.

    Hi gurus,

    Please help me understand under question.

    Whenever I have do explain plan on any sql statements he says as explained but when retriving explain plan output it shows same results again and again.

    DB - 11 GR 2 Stand alone
    ASM - configured.
    OS - RHEL 6.2.


    SQL > select count (*) in the t2114;

    COUNT (*)
    ----------
    639292

    SQL > explain plan for select count (*) from t2114;

    He explained.

    SQL > @?/rdbms/admin/utlxpls.sql

    PLAN_TABLE_OUTPUT
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Hash value of plan: 1497650422

    ----------------------------------------------------------------------------------------
    | ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time |
    ----------------------------------------------------------------------------------------
    | 0 | SELECT STATEMENT | 6634. 524K | 2993 (19) | 00:00:01 |
    | 1. SORT ORDER BY | 6634. 524K | 2993 (19) | 00:00:01 |
    | 2. TABLE ACCESS BY INDEX ROWID | T2210 | 6634. 524K | 2947 (17) | 00:00:01 |
    |* 3 | INDEX RANGE SCAN | T2210_T | 6842. 108 (22) | 00:00:01 |
    ----------------------------------------------------------------------------------------

    Information of predicates (identified by the operation identity card):
    ---------------------------------------------------

    3 - access("T2210".") C490008000 ' =: SYS_B_0 AND "T2210".» C490009100 ' =: SYS_B_2.
    (AND "T2210". ' C301363300 '= TO_NUMBER (:SYS_B_1)).

    16 selected lines.


    SQL > explain the plan for
    2. SELECT T2114. C1 FROM T2114 WHERE ((T2114. C1000000001 =: 'SYS_B_0') AND (T2114. C536871442 =: 'SYS_B_1') AND (T2114. C536871477 =: 'SYS_B_2') AND ((: "SYS_B_3" - T2114.)) (C3) > =: 'SYS_B_4') AND ((: "SYS_B_5" - T2114.)) (C3) < =: 'SYS_B_6') AND (T2114. C1000000217 AS: 'SYS_B_7') AND (T2114. C536871478 <: 'SYS_B_8')) ORDER BY C1000000161 DESC,: 'SYS_B_9' ASC;

    He explained.

    SQL > SELECT * FROM TABLE (dbms_xplan.display);

    PLAN_TABLE_OUTPUT
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Hash value of plan: 1497650422

    ----------------------------------------------------------------------------------------
    | ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time |
    ----------------------------------------------------------------------------------------
    | 0 | SELECT STATEMENT | 6634. 524K | 2993 (19) | 00:00:01 |
    | 1. SORT ORDER BY | 6634. 524K | 2993 (19) | 00:00:01 |
    | 2. TABLE ACCESS BY INDEX ROWID | T2210 | 6634. 524K | 2947 (17) | 00:00:01 |
    |* 3 | INDEX RANGE SCAN | T2210_T | 6842. 108 (22) | 00:00:01 |
    ----------------------------------------------------------------------------------------

    Information of predicates (identified by the operation identity card):
    ---------------------------------------------------

    3 - access("T2210".") C490008000 ' =: SYS_B_0 AND "T2210".» C490009100 ' =: SYS_B_2.
    (AND "T2210". ' C301363300 '= TO_NUMBER (:SYS_B_1)).

    16 selected lines.

    In the future, please do not use * on object.
    Use the owner, object_type, object_name
    You avoid output unreadable in doing so.

    In the output that you show, you would need to know where the PUBLIC synonym points, by querying dba_synonyms or all_synonyms.
    If she SYS. Plan_table, you can drop ARADMIN. PLAN_TABLE.
    If there is no PLAN_TABLE SYS, you have to solve this problem.

    -----------
    Sybrand Bakker
    Senior Oracle DBA

  • what code is better-how reading explain plan

    10g. How to read explain plan
    explain plan for
    with av as
    (
    SELECT  last_name, salary, 
            department_id,
              round(avg(salary) over (partition by department_id) ) avg_sal
    FROM    employees
    )
    
    select * from av where salary > avg_sal
    order by last_name;
    
    select * from table(dbms_xplan.display)
     
    explain plan

    Plan hash value: 1582291400
     
    ----------------------------------------------------------------------------------
    | Id  | Operation            | Name      | Rows  | Bytes | Cost (%CPU)| Time     |
    ----------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT     |           |   107 |  5671 |     5  (40)| 00:00:01 |
    |   1 |  SORT ORDER BY       |           |   107 |  5671 |     5  (40)| 00:00:01 |
    |*  2 |   VIEW               |           |   107 |  5671 |     4  (25)| 00:00:01 |
    |   3 |    WINDOW SORT       |           |   107 |  1605 |     4  (25)| 00:00:01 |
    |   4 |     TABLE ACCESS FULL| EMPLOYEES |   107 |  1605 |     3   (0)| 00:00:01 |
    ----------------------------------------------------------------------------------
     
    Predicate Information (identified by operation id):
    ---------------------------------------------------
     
       2 - filter("SALARY">"AVG_SAL")
    explain plan for
    
    SELECT  a.last_name, a.salary, 
            a.department_id, b.salavg
    FROM    employees a, (SELECT   department_id, 
                          AVG(salary) salavg
                          FROM     employees
                          GROUP BY department_id) b
    WHERE   a.department_id = b.department_id
    AND     a.salary > b.salavg
    order by last_name
    
    select * from table(dbms_xplan.display)
    Plan hash value: 802276651
     
    ----------------------------------------------------------------------------------
    | Id  | Operation            | Name      | Rows  | Bytes | Cost (%CPU)| Time     |
    ----------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT     |           |   165 |  5610 |     8  (25)| 00:00:01 |
    |*  1 |  FILTER              |           |       |       |            |          |
    |   2 |   SORT GROUP BY      |           |   165 |  5610 |     8  (25)| 00:00:01 |
    |*  3 |    HASH JOIN         |           |  3296 |   109K|     7  (15)| 00:00:01 |
    |   4 |     TABLE ACCESS FULL| EMPLOYEES |   107 |  2889 |     3   (0)| 00:00:01 |
    |   5 |     TABLE ACCESS FULL| EMPLOYEES |   107 |   749 |     3   (0)| 00:00:01 |
    ----------------------------------------------------------------------------------
     
    Predicate Information (identified by operation id):
    ---------------------------------------------------
     
       1 - filter("A"."SALARY">SUM("SALARY")/COUNT("SALARY"))
       3 - access("A"."DEPARTMENT_ID"="DEPARTMENT_ID")

    Rahul India wrote:

    ----------------------------------------------------------------------------------
    | Id  | Operation            | Name      | Rows  | Bytes | Cost (%CPU)| Time     |
    ----------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT     |           |   107 |  5671 |     5  (40)| 00:00:01 |
    |   1 |  SORT ORDER BY       |           |   107 |  5671 |     5  (40)| 00:00:01 |
    |*  2 |   VIEW               |           |   107 |  5671 |     4  (25)| 00:00:01 |
    |   3 |    WINDOW SORT       |           |   107 |  1605 |     4  (25)| 00:00:01 |
    |   4 |     TABLE ACCESS FULL| EMPLOYEES |   107 |  1605 |     3   (0)| 00:00:01 |
    ----------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    2 - filter("SALARY">"AVG_SAL")
    

    ----------------------------------------------------------------------------------
    | ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time |
    ----------------------------------------------------------------------------------
    | 0 | SELECT STATEMENT | 165. 5610 | 8 (25) | 00:00:01 |
    |* 1 | FILTER |
    | 2. GROUP SORT BY | 165. 5610 | 8 (25) | 00:00:01 |
    |* 3 | HASH JOIN | 3296. 109K | 7 (15) | 00:00:01 |
    | 4. TABLE ACCESS FULL | EMPLOYEES | 107. 2889 | 3 (0) | 00:00:01 |
    | 5. TABLE ACCESS FULL | EMPLOYEES | 107. 749. 3 (0) | 00:00:01 |
    ----------------------------------------------------------------------------------

    Information of predicates (identified by the operation identity card):
    ---------------------------------------------------
    1 - filter("A".") SALARY "> SUM ("SALARY") COUNT ("SALARY"))"
    3 - access("A".") DEPARTMENT_ID "=" DEPARTMENT_ID")

    As a general rule, there is no way, you can decide which is the best plan without knowing what data happens in the request, and what will come out.
    You will notice, among other things, that Oracle has used a view complex merger to change your query with the aggragate inline view in a simple join with aggregation end (see http://jonathanlewis.wordpress.com/2007/03/08/transformation-and-optimisation/ for invasive how it may be). With a different dataset the optimizer might decide to regroup before joining - just the way you wrote the application.

    An essential difference between your two plans is (as others have pointed out) that one of them analyse the table twice, the other once - however, the other key difference is that the whole dataset COULD BE relevant to be sorted by the analytical application and resources used in the genre could well take on the resources used by a second analysis and integration of a single column.

    The difference is irrelevant in this case - but the difference exists and must be considered in the greatest examples.

    You could also write the query to use a subquery to correlated - which the optimizer may rewrite the same plan 'join then aggregate' one of your queries achieved - but once again as an intelligent agent, you can decide that (in some cases), the best plan is the subquery filter implied by the form of the SQL.

    Concerning
    Jonathan Lewis

  • Book advises explain plan

    Hi guys,.

    I have 2 questions. The first is as you know before, I would like to learn the secrets behind explain plan and how how oracle works behind the scene. I have studied some books. I found Oracle SQL Tuning: A Close Look at explain Plans by Dan Hotka. Do you recommend this book? I just read a page of this book, I thnik the language of this book is simple and he explains the situation from the beginning. In my view, it is helpful for beginners like me. Because things get difficult to learn in first time for beginners. As a result I just want to learn you recommend this book?

    My second question is, I want to buy this book, but I couldn't find in England (Paperback, not e book). But appereantly I have to buy online as ebook. Do you know any site web confidence that I can buy the ebook of this book version?

    Thanks a lot for your help.

    944258 wrote:
    Hi guys,.

    I have 2 questions. The first is as you know before, I would like to learn the secrets behind explain plan and how how oracle works behind the scene. I have studied some books. I found Oracle SQL Tuning: A Close Look at explain Plans by Dan Hotka. Do you recommend this book? I just read a page of this book, I thnik the language of this book is simple and he explains the situation from the beginning. In my view, it is helpful for beginners like me. Because things get difficult to learn in first time for beginners. As a result I just want to learn you recommend this book?

    Hi, why not start here everything first: http://www.orafaq.com/node/1420. There is probably more information about execution plans available online, as it is in the books. At least the part that you want to find out and try to remember will be available online :-)

    >

    My second question is, I want to buy this book, but I couldn't find in England (Paperback, not e book). But appereantly I have to buy online as ebook. Do you know any site web confidence that I can buy the ebook of this book version?

    http://www.Amazon.com/Oracle-SQL-Tuning-close-explain/DP/1453804196

    See you soon
    FJFranken

  • Caching in oracle execution plan

    Oracle stores the explain plan in cache memory?

    Published by: :) August 2, 2011 22:45

    It depends on.

    In general, plan execution change if Oracle has found a shared cursor in the shared pool, even if the data in the table changes.

    But it may depend on the Oracle version, on the use of variables in the query binding (see Adaptive cursor sharing 11 g). It also depends on if the statistics for the objects and the related tables have been recalculated with a flag or not to invalidate the plan (aka sliders).

    Tom Kyte wrote in his book Expert Oracle (page 148 that you can read online with Google Book Search):

    >
    The shared pool is designed so that the query plans would be used over and over again.
    >

    Edited by: P. Forstmann August 2, 2011 19:38

    Edited by: P. Forstmann August 2, 2011 19:42

  • EXPLAIN Explain plan

    Hello
    can someone point me to full details of the Plan, including how to understand the syntax in the statement "3-filter...". "marked in red.
    This cross-history. I expect to see <>(not the equal sign) between these columns, but there is nothing:
    Actual results is also 14 ranks, but I do not see that the figure anywhere in the plan, only "12" will be one any correlation between the numbers of plan and result?
    T1 (col_1 number):
    1
    2
    3
    4
    
    T2 (col_1 number):
    3
    4
    5
    6
    
    
    SQL> explain plan for  select t1.col_1 from t1, t2 where t1.col_1 != t2.col_1;
     
    Explained.
     
    SQL> select * from table(dbms_xplan.display);
     
    PLAN_TABLE_OUTPUT
    ------------------------------------------------------------------------------------------------------------------------------------
    Plan hash value: 1967407726
     
    ---------------------------------------------------------------------------
    | Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    ---------------------------------------------------------------------------
    |   0 | SELECT STATEMENT   |      |    12 |   312 |     6   (0)| 00:00:01 |
    |   1 |  NESTED LOOPS      |      |    12 |   312 |     6   (0)| 00:00:01 |
    |   2 |   TABLE ACCESS FULL| T1   |     4 |    52 |     2   (0)| 00:00:01 |
    |*  3 |   TABLE ACCESS FULL| T2   |     3 |    39 |     1   (0)| 00:00:01 |
    ---------------------------------------------------------------------------
     
    Predicate Information (identified by operation id):
    ---------------------------------------------------
     
       3 - filter("T1"."COL_1""T2"."COL_1")          ---/*XXX
     
    Note
    -----
       - dynamic sampling used for this statement
     

    the cost based optimizer uses internal statistics to determine the number of rows that an operation will be back. For the simple query in your example, these estimates would be quite accurate if statistics have been sufficient - but they are not since we see the dynamic sampling note that indicates the missing statistics: http://blogs.oracle.com/optimizer/entry/dynamic_sampling_and_its_impact_on_the_optimizer

    -- without statistics
    ---------------------------------------------------------------------------
    | Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    ---------------------------------------------------------------------------
    |   0 | SELECT STATEMENT   |      |    12 |   312 |    13   (0)| 00:00:01 |
    |   1 |  NESTED LOOPS      |      |    12 |   312 |    13   (0)| 00:00:01 |
    |   2 |   TABLE ACCESS FULL| T1   |     4 |    52 |     4   (0)| 00:00:01 |
    |*  3 |   TABLE ACCESS FULL| T2   |     3 |    39 |     2   (0)| 00:00:01 |
    ---------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       3 - filter("T1"."ID"<>"T2"."ID")
    
    Note
    -----
       - dynamic sampling used for this statement (level=2)
    
    -- gather statistics
    exec dbms_stats.gather_table_stats(user, 'T1')
    exec dbms_stats.gather_table_stats(user, 'T2')
    
    -- with statistics (we see the 4 * 4 = 16 rows we expect)
    ---------------------------------------------------------------------------
    | Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    ---------------------------------------------------------------------------
    |   0 | SELECT STATEMENT   |      |    16 |    96 |    13   (0)| 00:00:01 |
    |   1 |  NESTED LOOPS      |      |    16 |    96 |    13   (0)| 00:00:01 |
    |   2 |   TABLE ACCESS FULL| T1   |     4 |    12 |     4   (0)| 00:00:01 |
    |*  3 |   TABLE ACCESS FULL| T2   |     4 |    12 |     2   (0)| 00:00:01 |
    ---------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       3 - filter("T1"."ID"<>"T2"."ID")
    

    The filter says that operation 3 complete analysis results are filtered by the given condition. If we had clues you might see an access descriptor.

    Concerning

    Martin Preiss

Maybe you are looking for