Understand the output of explain plan

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

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

Similar Messages

  • Help in interpreting the output of explain plan

    Hi,
    I have written a query in two different ways and then run an explain plan on both of them. Both these queries give same result. I want to know which one will be more efficient. I am giving the output of explain plan for both the queries:
    The second plan has a lower cost but has much higher consistent gets !!
    Please advise.
    Plan 1:
    Execution Plan
       0      SELECT STATEMENT Optimizer=HINT: FIRST_ROWS (Cost=8637 Card= 1 Bytes=10132)
       1    0   SORT (ORDER BY) (Cost=8637 Card=1 Bytes=10132)
       2    1     WINDOW (SORT) (Cost=8637 Card=1 Bytes=10132)
       3    2       COUNT (STOPKEY)
       4    3         VIEW (Cost=8635 Card=1 Bytes=10132)
       5    4           SORT (ORDER BY) (Cost=8635 Card=1 Bytes=862)
       6    5             WINDOW (SORT) (Cost=8635 Card=1 Bytes=862)
       7    6               MAT_VIEW ACCESS (FULL) OF 'PRD_SEARCH_MVW' (MAT_VIEW) (Cost=8633 Card=1 Bytes=862)
    Statistics
            577  recursive calls
              0  db block gets
          39202  consistent gets
          34798  physical reads
              0  redo size
          72348  bytes sent via SQL*Net to client
           4295  bytes received via SQL*Net from client
              9  SQL*Net roundtrips to/from client
             10  sorts (memory)
              0  sorts (disk)
            100  rows processed
    Plan-2
    Execution Plan
       0      SELECT STATEMENT Optimizer=HINT: FIRST_ROWS (Cost=982 Card=1 Bytes=10145)
       1    0   SORT (ORDER BY) (Cost=982 Card=1 Bytes=10145)
       2    1     WINDOW (SORT) (Cost=982 Card=1 Bytes=10145)
       3    2       COUNT (STOPKEY)
       4    3         VIEW (Cost=980 Card=1 Bytes=10145)
       5    4           SORT (ORDER BY) (Cost=980 Card=1 Bytes=10132)
       6    5             WINDOW (SORT) (Cost=980 Card=1 Bytes=10132)
       7    6               WINDOW (SORT) (Cost=980 Card=1 Bytes=10132)
       8    7                 VIEW (Cost=977 Card=1 Bytes=10132)
       9    8                   WINDOW (SORT PUSHED RANK) (Cost=977 Card=1 Bytes=889)
      10    9                     NESTED LOOPS (Cost=976 Card=1 Bytes=889)
      11   10                       HASH JOIN (Cost=305 Card=670 Bytes=18090)
      12   11                         HASH JOIN (Cost=23 Card=140 Bytes=2240)
      13   12                           INDEX (FAST FULL SCAN) OF 'GLCAT_GRP_TO_CAT_PK' (INDEX (UNIQUE)) (Cost=2 Card=52 Bytes=364)
      14   12                           MAT_VIEW ACCESS (FULL) OF 'GLCAT_CAT_TO_MCAT' (MAT_VIEW) (Cost=20 Card=1039 Bytes=9351)
      15   11                         INDEX (FAST FULL SCAN) OF 'PCITEM2GLCATMCAT_FK_IDS' (INDEX) (Cost=281 Card=16903 Bytes=185933)
      16   10                       MAT_VIEW ACCESS (BY INDEX ROWID) OF 'PRD_SEARCH_MVW' (MAT_VIEW) (Cost=1 Card=1 Bytes=862)
      17   16                         INDEX (UNIQUE SCAN) OF 'PK_PRD_SEARCH_ID' (INDEX (UNIQUE)) (Cost=0 Card=1)
    Statistics
            481    recursive calls
              2      db block gets
         195742  consistent gets
           7516  physical reads
              0  redo size
          71567  bytes sent via SQL*Net to client
           6629  bytes received via SQL*Net from client
              9  SQL*Net roundtrips to/from client
             15  sorts (memory)
              1  sorts (disk)
            100  rows processedRegards
    Madhup
    Message was edited by:
    Madhup

    Thanks a lot for you input. I am posting both the queries below. My requirements are following:
    1) I have a products table
    2) I have Created grouping hierarchy - Groups, Categories and then Micro-categories - and have setup a separate table for each of them in my database
    3) Then I have mapping tables, i.e. a table that stores group to category mapping, another table that stores category to micro-category mapping.
    4) Products are mapped directly to micro-categories and one product could be mapped to multiple micro-categories.
    5) I have created a materialized view on product and store the mappings as comma separated list of IDs - I have three fields there, on to store comma separated group id, second to store comma separated category ids and third to store the comma separated micro category ids to which the product is mapped.
    Now I want to write a query that will return a specified number of matches from this table based on user defined criterion. There are few other filter cirterion apart from Group/Category and Microcategory. These are Company Name, Country, Type of company etc.
    This query when run on production will be accessed very frequently - I expect the access to be in the tune of around 5-10 times per second.
    There are 50 records in the group table
    There are 500 categories
    There are 20000 micro-categories
    Group to category mapping table has around 1000 records
    Category to microcategory table has around 25000 records
    The product table has around 100,000 products.
    Product to microcategory mapping table has 350000 records
    The product mview has the same number of records as that in products table.
    The first query uses the single materialized view to access data, however, it always does a full table scan and does not use any index.
    When I noticed this in the explain plan, then I tried to write the second query which is using JOINs to arrive at the same output.
    The explain plan now says that it is using Index scans.
    I did a sample run of both the queries on my production system and I had to withdraw both of them as both brought my system to grinding halt within few minutes of going live.
    My system at present receives around 3000 requests per hour during peak load and around 600 requests per hour during off-peak hours.
    And I was testing these queries in Off-peak hours !!
    Here are the two sql queries just for reference - there are several variables plugged in where clause which are the key drivers of the query:
    SQL-1
    SELECT DECODE(:OPT,2,A.SC,(MAX(A.SC) OVER (PARTITION BY A.PRD_SEARCH_COMPANY))) AS SO,
         A.SC,                           A.PRD_SEARCH_ID,
         A.PRD_SEARCH_COMPANY_ID,        A.PRD_SEARCH_COMPANY,            A.PRD_SEARCH_COMPANYID_ENCRYPTED,
         A.PRD_SEARCH_PCID,              A.PRD_SEARCH_URL,                A.PRD_SEARCH_PC_CLNT_HOME,
         A.PRD_SEARCH_CLNT_ENABLED,      A.PRD_SEARCH_CODE,               A.PRD_SEARCH_NAME,
         A.PRD_SEARCH_DESC_SMALL,        A.PRD_SEARCH_DESC_DETAILED,      A.PRD_SEARCH_DESC_HTML,
         A.PRD_SEARCH_IMG_SMALL,         A.PRD_SEARCH_IMG_LARGE,          A.PRD_SEARCH_WEIGHT_ITEM,
         A.PRD_SEARCH_MODIFIEDDATE,      A.PRD_SEARCH_SIZE,               A.PRD_SEARCH_LABEL1,
         A.PRD_SEARCH_LABEL1_VALUE,      A.PRD_SEARCH_LABEL2,             A.PRD_SEARCH_LABEL2_VALUE,
         A.PRD_SEARCH_LABEL3,            A.PRD_SEARCH_LABEL3_VALUE,       A.PRD_SEARCH_LABEL4,
         A.PRD_SEARCH_LABEL4_VALUE,      A.PRD_SEARCH_LABEL5,             A.PRD_SEARCH_LABEL5_VALUE,
         A.PRD_SEARCH_LABEL6,            A.PRD_SEARCH_LABEL6_VALUE,       A.PRD_SEARCH_CAT_ID,
         A.PRD_SEARCH_CAT_NAME,          A.PRD_SEARCH_CAT_FLNAME,         A.PRD_SEARCH_NAVIGATION_TREE,
         A.PRD_SEARCH_NAVIGATION_TREE_ID,A.PRD_SEARCH_CITY,               A.PRD_SEARCH_STATE,
         A.PRD_SEARCH_COUNTRY,           A.PRD_SEARCH_PRICE_SALE,         A.PRD_SEARCH_PC_CLNT_TYPE,
         A.PRD_SEARCH_PC_CLNT_TYPE_DESC,
         A.PRD_SEARCH_COMPANY_PHONE,     A.PRD_SEARCH_COMPANY_MOBILE,     A.PRD_SEARCH_COMPANY_FAX,
         A.PRD_SEARCH_COMPANY_EMAIL,     A.PRD_SEARCH_GLCAT_MCAT_ID_LIST, A.PRD_SEARCH_GLCAT_CAT_ID_LIST,
         A.PRD_SEARCH_GLCAT_GRP_ID_LIST, A.PRD_SEARCH_GL_COUNTRY_ISO,     A.PRD_SEARCH_GLUSR_USR_ID,
         A.PRD_SEARCH_TRUSTSEAL_CODE,    A.PRD_SEARCH_CUSTTYPE_ID,        A.PRD_SEARCH_CUSTTYPE_NAME,
         A.PRD_SEARCH_CUSTTYPE_WEIGHT,   A.PRD_SEARCH_CUSTTYPE_WEIGHT_TZ, A.PRD_SEARCH_CUSTTYPE_RANK,
         A.PRD_SEARCH_PC_ITEM_HOTNEW,    A.RK
         FROM
              (SELECT  /*+ FIRST_ROWS (500) */     DECODE(:S_MODE,2,1,3,to_number(to_char(PRD_SEARCH_MODIFIEDDATE,'yyyymmdd')),1) AS SC,
              PRD_SEARCH_ID,
              PRD_SEARCH_COMPANY_ID,        PRD_SEARCH_COMPANY,            PRD_SEARCH_COMPANYID_ENCRYPTED,
              PRD_SEARCH_PCID,              PRD_SEARCH_URL,                PRD_SEARCH_PC_CLNT_HOME,
              PRD_SEARCH_CLNT_ENABLED,      PRD_SEARCH_CODE,               PRD_SEARCH_NAME,
              PRD_SEARCH_DESC_SMALL,        PRD_SEARCH_DESC_DETAILED,      PRD_SEARCH_DESC_HTML,
              PRD_SEARCH_IMG_SMALL,         PRD_SEARCH_IMG_LARGE,          PRD_SEARCH_WEIGHT_ITEM,
              PRD_SEARCH_MODIFIEDDATE,      PRD_SEARCH_SIZE,               PRD_SEARCH_LABEL1,
              PRD_SEARCH_LABEL1_VALUE,      PRD_SEARCH_LABEL2,             PRD_SEARCH_LABEL2_VALUE,
              PRD_SEARCH_LABEL3,            PRD_SEARCH_LABEL3_VALUE,       PRD_SEARCH_LABEL4,
              PRD_SEARCH_LABEL4_VALUE,      PRD_SEARCH_LABEL5,             PRD_SEARCH_LABEL5_VALUE,
              PRD_SEARCH_LABEL6,            PRD_SEARCH_LABEL6_VALUE,       PRD_SEARCH_CAT_ID,
              PRD_SEARCH_CAT_NAME,          PRD_SEARCH_CAT_FLNAME,         PRD_SEARCH_NAVIGATION_TREE,
              PRD_SEARCH_NAVIGATION_TREE_ID,PRD_SEARCH_CITY,               PRD_SEARCH_STATE,
              PRD_SEARCH_COUNTRY,           PRD_SEARCH_PRICE_SALE,         PRD_SEARCH_PC_CLNT_TYPE,
              PRD_SEARCH_PC_CLNT_TYPE_DESC,
              PRD_SEARCH_COMPANY_PHONE,     PRD_SEARCH_COMPANY_MOBILE,     PRD_SEARCH_COMPANY_FAX,
              PRD_SEARCH_COMPANY_EMAIL,     PRD_SEARCH_GLCAT_MCAT_ID_LIST, PRD_SEARCH_GLCAT_CAT_ID_LIST,
              PRD_SEARCH_GLCAT_GRP_ID_LIST, PRD_SEARCH_GL_COUNTRY_ISO,     PRD_SEARCH_GLUSR_USR_ID,
              PRD_SEARCH_TRUSTSEAL_CODE,    PRD_SEARCH_CUSTTYPE_ID,        PRD_SEARCH_CUSTTYPE_NAME,
              PRD_SEARCH_CUSTTYPE_WEIGHT,   PRD_SEARCH_CUSTTYPE_WEIGHT_TZ, PRD_SEARCH_CUSTTYPE_RANK,
              PRD_SEARCH_PC_ITEM_HOTNEW,
              ROW_NUMBER() OVER (PARTITION BY PRD_SEARCH_COMPANY_ID
                                  ORDER BY DECODE(:S_MODE,2,1,3,to_number(to_char(PRD_SEARCH_MODIFIEDDATE,'yyyymmdd')),1) DESC) AS RK
              FROM      PRD_SEARCH
              WHERE     DECODE(:GRP_ID_STR,NULL,1,REGEXP_INSTR(','||REPLACE(PRD_SEARCH_GLCAT_GRP_ID_LIST,' ','')||',',:MYGRP_ID_STR)) > 0
              AND       DECODE(:CAT_ID_STR,NULL,1,REGEXP_INSTR(','||REPLACE(PRD_SEARCH_GLCAT_CAT_ID_LIST,' ','')||',',:MYCAT_ID_STR)) > 0
              AND       DECODE(:MCAT_ID_STR,NULL,1,REGEXP_INSTR(','||REPLACE(PRD_SEARCH_GLCAT_MCAT_ID_LIST,' ','')||',',:MYMCAT_ID_STR)) > 0
              AND       DECODE(:ITEM_ID_STR,NULL,1,REGEXP_INSTR(','||PRD_SEARCH_ID||',',:MYITEM_ID_STR)) > 0
              AND       DECODE(:COUNTRY_ISO,NULL,1,REGEXP_INSTR(','||PRD_SEARCH_GL_COUNTRY_ISO||',',:COUNTRY_ISO)) > 0
              AND       DECODE(nvl(NULL,0),0,1,PRD_SEARCH_COMPANY_ID) = DECODE(nvl(NULL,0),0,1,NULL)
              AND       DECODE(nvl(NULL,0),0,1,PRD_SEARCH_GLUSR_USR_ID) = DECODE(nvl(NULL,0),0,1,NULL)
              AND       PRD_SEARCH_CLNT_ENABLED >= nvl(:LIST_TYPE,0)
              AND       NVL(Length(PRD_SEARCH_TRUSTSEAL_CODE),0) >= :TSONLY
              ORDER BY SC DESC, PRD_SEARCH_CUSTTYPE_WEIGHT ASC, DBMS_RANDOM.RANDOM
              )  A
    WHERE A.RK <= :MY_PRD_PER_COMP
    AND   ROWNUM <= :MYMAXREC
    ORDER BY SO DESC, DECODE(:OPT,2,'1',A.PRD_SEARCH_COMPANY), A.RK ASC, DBMS_RANDOM.RANDOM
    SQL-2
         SELECT
              DECODE(:OPT,2,SC,(MAX(SC) OVER (PARTITION BY PRD_SEARCH_COMPANY))) AS SO,
              SC,                           PRD_SEARCH_ID,
              PRD_SEARCH_COMPANY_ID,        PRD_SEARCH_COMPANY,            PRD_SEARCH_COMPANYID_ENCRYPTED,
              PRD_SEARCH_PCID,              PRD_SEARCH_URL,                PRD_SEARCH_PC_CLNT_HOME,
              PRD_SEARCH_CLNT_ENABLED,      PRD_SEARCH_CODE,               PRD_SEARCH_NAME,
              PRD_SEARCH_DESC_SMALL,        PRD_SEARCH_DESC_DETAILED,      PRD_SEARCH_DESC_HTML,
              PRD_SEARCH_IMG_SMALL,         PRD_SEARCH_IMG_LARGE,          PRD_SEARCH_WEIGHT_ITEM,
              PRD_SEARCH_MODIFIEDDATE,      PRD_SEARCH_SIZE,               PRD_SEARCH_LABEL1,
              PRD_SEARCH_LABEL1_VALUE,      PRD_SEARCH_LABEL2,             PRD_SEARCH_LABEL2_VALUE,
              PRD_SEARCH_LABEL3,            PRD_SEARCH_LABEL3_VALUE,       PRD_SEARCH_LABEL4,
              PRD_SEARCH_LABEL4_VALUE,      PRD_SEARCH_LABEL5,             PRD_SEARCH_LABEL5_VALUE,
              PRD_SEARCH_LABEL6,            PRD_SEARCH_LABEL6_VALUE,       PRD_SEARCH_CAT_ID,
              PRD_SEARCH_CAT_NAME,          PRD_SEARCH_CAT_FLNAME,         PRD_SEARCH_NAVIGATION_TREE,
              PRD_SEARCH_NAVIGATION_TREE_ID,PRD_SEARCH_CITY,               PRD_SEARCH_STATE,
              PRD_SEARCH_COUNTRY,           PRD_SEARCH_PRICE_SALE,         PRD_SEARCH_PC_CLNT_TYPE,
              PRD_SEARCH_PC_CLNT_TYPE_DESC,
              PRD_SEARCH_COMPANY_PHONE,     PRD_SEARCH_COMPANY_MOBILE,     PRD_SEARCH_COMPANY_FAX,
              PRD_SEARCH_COMPANY_EMAIL,     PRD_SEARCH_GLCAT_MCAT_ID_LIST, PRD_SEARCH_GLCAT_CAT_ID_LIST,
              PRD_SEARCH_GLCAT_GRP_ID_LIST, PRD_SEARCH_GL_COUNTRY_ISO,     PRD_SEARCH_GLUSR_USR_ID,
              PRD_SEARCH_TRUSTSEAL_CODE,    PRD_SEARCH_CUSTTYPE_ID,        PRD_SEARCH_CUSTTYPE_NAME,
              PRD_SEARCH_CUSTTYPE_WEIGHT,   PRD_SEARCH_CUSTTYPE_WEIGHT_TZ, PRD_SEARCH_CUSTTYPE_RANK,
              PRD_SEARCH_PC_ITEM_HOTNEW,    RK
         FROM
                   SELECT
                        /*+ FIRST_ROWS (500) */ DECODE(:OPT,2,SC,(MAX(SC) OVER (PARTITION BY PRD_SEARCH_COMPANY))) AS SO,
                        SC,PRD_SEARCH_ID,
                        PRD_SEARCH_COMPANY_ID,        PRD_SEARCH_COMPANY,            PRD_SEARCH_COMPANYID_ENCRYPTED,
                        PRD_SEARCH_PCID,              PRD_SEARCH_URL,                PRD_SEARCH_PC_CLNT_HOME,
                        PRD_SEARCH_CLNT_ENABLED,      PRD_SEARCH_CODE,               PRD_SEARCH_NAME,
                        PRD_SEARCH_DESC_SMALL,        PRD_SEARCH_DESC_DETAILED,      PRD_SEARCH_DESC_HTML,
                        PRD_SEARCH_IMG_SMALL,         PRD_SEARCH_IMG_LARGE,          PRD_SEARCH_WEIGHT_ITEM,
                        PRD_SEARCH_MODIFIEDDATE,      PRD_SEARCH_SIZE,               PRD_SEARCH_LABEL1,
                        PRD_SEARCH_LABEL1_VALUE,      PRD_SEARCH_LABEL2,             PRD_SEARCH_LABEL2_VALUE,
                        PRD_SEARCH_LABEL3,            PRD_SEARCH_LABEL3_VALUE,       PRD_SEARCH_LABEL4,
                        PRD_SEARCH_LABEL4_VALUE,      PRD_SEARCH_LABEL5,             PRD_SEARCH_LABEL5_VALUE,
                        PRD_SEARCH_LABEL6,            PRD_SEARCH_LABEL6_VALUE,       PRD_SEARCH_CAT_ID,
                        PRD_SEARCH_CAT_NAME,          PRD_SEARCH_CAT_FLNAME,         PRD_SEARCH_NAVIGATION_TREE,
                        PRD_SEARCH_NAVIGATION_TREE_ID,PRD_SEARCH_CITY,               PRD_SEARCH_STATE,
                        PRD_SEARCH_COUNTRY,           PRD_SEARCH_PRICE_SALE,         PRD_SEARCH_PC_CLNT_TYPE,
                        PRD_SEARCH_PC_CLNT_TYPE_DESC,
                        PRD_SEARCH_COMPANY_PHONE,     PRD_SEARCH_COMPANY_MOBILE,     PRD_SEARCH_COMPANY_FAX,
                        PRD_SEARCH_COMPANY_EMAIL,     PRD_SEARCH_GLCAT_MCAT_ID_LIST, PRD_SEARCH_GLCAT_CAT_ID_LIST,
                        PRD_SEARCH_GLCAT_GRP_ID_LIST, PRD_SEARCH_GL_COUNTRY_ISO,     PRD_SEARCH_GLUSR_USR_ID,
                        PRD_SEARCH_TRUSTSEAL_CODE,    PRD_SEARCH_CUSTTYPE_ID,        PRD_SEARCH_CUSTTYPE_NAME,
                        PRD_SEARCH_CUSTTYPE_WEIGHT,   PRD_SEARCH_CUSTTYPE_WEIGHT_TZ, PRD_SEARCH_CUSTTYPE_RANK,
                        PRD_SEARCH_PC_ITEM_HOTNEW,
                        ROW_NUMBER() OVER (PARTITION BY PRD_SEARCH_COMPANY_ID
                                  ORDER BY DECODE(:S_MODE,2,1,3,TO_NUMBER(TO_CHAR(PRD_SEARCH_MODIFIEDDATE,'YYYYMMDD')),1) DESC) AS RK
                   FROM
                             SELECT
                                  DECODE(:S_MODE,2,1,3,TO_NUMBER(TO_CHAR(PRD_SEARCH_MODIFIEDDATE,'YYYYMMDD')),1) AS SC,
                                  PRD_SEARCH_ID,
                                  PRD_SEARCH_COMPANY_ID,        PRD_SEARCH_COMPANY,            PRD_SEARCH_COMPANYID_ENCRYPTED,
                                  PRD_SEARCH_PCID,              PRD_SEARCH_URL,                PRD_SEARCH_PC_CLNT_HOME,
                                  PRD_SEARCH_CLNT_ENABLED,      PRD_SEARCH_CODE,               PRD_SEARCH_NAME,
                                  PRD_SEARCH_DESC_SMALL,        PRD_SEARCH_DESC_DETAILED,      PRD_SEARCH_DESC_HTML,
                                  PRD_SEARCH_IMG_SMALL,         PRD_SEARCH_IMG_LARGE,          PRD_SEARCH_WEIGHT_ITEM,
                                  PRD_SEARCH_MODIFIEDDATE,      PRD_SEARCH_SIZE,               PRD_SEARCH_LABEL1,
                                  PRD_SEARCH_LABEL1_VALUE,      PRD_SEARCH_LABEL2,             PRD_SEARCH_LABEL2_VALUE,
                                  PRD_SEARCH_LABEL3,            PRD_SEARCH_LABEL3_VALUE,       PRD_SEARCH_LABEL4,
                                  PRD_SEARCH_LABEL4_VALUE,      PRD_SEARCH_LABEL5,             PRD_SEARCH_LABEL5_VALUE,
                                  PRD_SEARCH_LABEL6,            PRD_SEARCH_LABEL6_VALUE,       PRD_SEARCH_CAT_ID,
                                  PRD_SEARCH_CAT_NAME,          PRD_SEARCH_CAT_FLNAME,         PRD_SEARCH_NAVIGATION_TREE,
                                  PRD_SEARCH_NAVIGATION_TREE_ID,PRD_SEARCH_CITY,               PRD_SEARCH_STATE,
                                  PRD_SEARCH_COUNTRY,           PRD_SEARCH_PRICE_SALE,         PRD_SEARCH_PC_CLNT_TYPE,
                                  PRD_SEARCH_PC_CLNT_TYPE_DESC,
                                  PRD_SEARCH_COMPANY_PHONE,     PRD_SEARCH_COMPANY_MOBILE,     PRD_SEARCH_COMPANY_FAX,
                                  PRD_SEARCH_COMPANY_EMAIL,     PRD_SEARCH_GLCAT_MCAT_ID_LIST, PRD_SEARCH_GLCAT_CAT_ID_LIST,
                                  PRD_SEARCH_GLCAT_GRP_ID_LIST, PRD_SEARCH_GL_COUNTRY_ISO,     PRD_SEARCH_GLUSR_USR_ID,
                                  PRD_SEARCH_TRUSTSEAL_CODE,    PRD_SEARCH_CUSTTYPE_ID,        PRD_SEARCH_CUSTTYPE_NAME,
                                  PRD_SEARCH_CUSTTYPE_WEIGHT,   PRD_SEARCH_CUSTTYPE_WEIGHT_TZ, PRD_SEARCH_CUSTTYPE_RANK,
                                  PRD_SEARCH_PC_ITEM_HOTNEW,
                                  ROW_NUMBER() OVER (PARTITION BY P.PRD_SEARCH_ID ORDER BY P.PRD_SEARCH_ID) RK1
                             FROM
                                  GLCAT_GRP_TO_CAT G2C, GLCAT_CAT_TO_MCAT C2M, PC_ITEM_TO_GLCAT_MCAT M, PRD_SEARCH P
                             WHERE
                                  G2C.FK_GLCAT_CAT_ID = C2M.FK_GLCAT_CAT_ID
                                  AND C2M.FK_GLCAT_MCAT_ID = M.FK_GLCAT_MCAT_ID
                                  AND M.FK_PC_ITEM_ID = P.PRD_SEARCH_ID
                                  AND DECODE(:MCAT_ID_STR, NULL, 1, INSTR(','||:MCAT_ID_STR||',',','||M.FK_GLCAT_MCAT_ID||',',1))> 0
                                  AND DECODE(:CAT_ID_STR, NULL, 1, INSTR(','||:CAT_ID_STR||',',','||C2M.FK_GLCAT_CAT_ID||',',1)) > 0
                                  AND DECODE(:GRP_ID_STR, NULL, 1, INSTR(','||:GRP_ID_STR||',',','||G2C.FK_GLCAT_GRP_ID||',',1)) > 0
                                  AND DECODE(:ITEM_ID_STR,NULL,1,INSTR(','||:ITEM_ID_STR||',' , ','||P.PRD_SEARCH_ID||',')) > 0
                                  AND DECODE(:COUNTRY_ISO,NULL,1,INSTR(','||:COUNTRY_ISO||',', ','||P.PRD_SEARCH_GL_COUNTRY_ISO||',')) > 0
                                  AND DECODE(NVL(:COMPANY_ID,0),0,1,P.PRD_SEARCH_COMPANY_ID) = DECODE(NVL(:COMPANY_ID,0),0,1,:COMPANY_ID)
                                  AND DECODE(NVL(:GLUSR_ID,0),0,1,P.PRD_SEARCH_GLUSR_USR_ID) = DECODE(NVL(:GLUSR_ID,0),0,1,:GLUSR_ID)
                                  AND P.PRD_SEARCH_CLNT_ENABLED >= NVL(:LIST_TYPE,0)
                                  AND NVL(LENGTH(P.PRD_SEARCH_TRUSTSEAL_CODE),0) >= :TSONLY
                   WHERE RK1=1
                   ORDER BY SC DESC, PRD_SEARCH_CUSTTYPE_WEIGHT ASC, DBMS_RANDOM.RANDOM
              ) A
         WHERE A.RK <= :MY_PRD_PER_COMP
         AND   ROWNUM <= :MYMAXREC
         ORDER BY A.SO DESC, DECODE(:OPT,2,'1', A.PRD_SEARCH_COMPANY), A.RK ASC, DBMS_RANDOM.RANDOMRegards
    Madhup

  • Not Understanding the filter in Explain Plan - filter(NULL IS NOT NULL)

    Hi All,
    Request your help in understanding the below scenario. (I am not aware of teh application and table details. Just trying to help my friend)
    SQL> conn
    Enter user-name: [email protected]
    Enter password:
    Connected.
    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bi
    PL/SQL Release 10.2.0.3.0 - Production
    CORE    10.2.0.3.0      Production
    TNS for Linux: Version 10.2.0.3.0 - Production
    NLSRTL Version 10.2.0.3.0 - Production
    --Checking the count in PO_LINES
    SQL> select count(*) from po_lines;
      COUNT(*)
             0
    --PO_LINES is a synonym
    SQL> select object_type,owner from dba_objects where object_name = 'PO_LINES';
    OBJECT_TYPE         OWNER
    SYNONYM             APPS
    --The synonym is pointing to PO.PO_LINES_ALL
    SQL> select * from user_synonyms where synonym_name = 'PO_LINES';
    SYNONYM_NAME                   TABLE_OWNER                    TABLE_NAME                     DB_LINK
    PO_LINES                       PO                             PO_LINES_ALL
    --But when counting PO.PO_LINES_ALL I am getting different result
    SQL> select count(*) c from po.po_lines_all;
             C
          8828
    --Explain plan of teh original query is
    SQL> explain plan for
      2  select
      3  * from po_lines;
    Explained.
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    | Id  | Operation          | Name         | Rows  | Bytes | Cost (%CPU)|
    |   0 | SELECT STATEMENT   |              |     1 |   252 |     0   (0)|
    |*  1 |  FILTER            |              |       |       |            |
    |   2 |   TABLE ACCESS FULL| PO_LINES_ALL |  8796 |  2164K|   106   (4)|
    Predicate Information (identified by operation id):
       1 - filter(NULL IS NOT NULL)
    --Now the object PO.PO_LINES_ALL is TABLE, not an mview.
    SQL> select object_type,owner from dba_objects where object_name = 'PO_LINES_ALL';
    OBJECT_TYPE         OWNER
    TABLE               POSeek your help in understanding what is happening here.
    Thanks in Advance,
    jeneesh

    Next time, prefix with APPS. when you show us the explain plan:
    SQL> explain plan for
      2  select
      3  * from apps.po_lines;  -- added the prefix of owner.Just like you prefixed with PO. when you showed us the query on PO_LINES_ALL. It ensures that you are using the synonym which you showed us.
    Btw. PO_LINES_ALL, could still be a VIEW given your overview of the situation.
    Anyway a filter "NULL IS NOT NULL" is indicative that the optimizer performed something called semantic query optimization (SQO).
    SQO is the process of deducing new predicates based upon a) existing predicates in your query (which there is none), b) added predicates to your query (eg. by a VPD policy function), and c) declared constraints on the tables invovled in your query.
    A typical example of when a "NOT is NOT NULL" predicate will show up is when for instance in the EMP table there is a declared constraint on EMPNO like this:
    check(EMPNO > 0)And your query would hold a predicate that is inconsistent with the constraint, for instance like this:
    select *
    from EMP
    where EMPNO <= 0Oracle will deduce that EMPNO cannot be both greater than zero (constraint) as well as smaller than or equal to zero (your query predicate), and will transform the query into:
    select *
    from EMP
    where EMPNO <= 0
      and NULL is NOT NULLThus preventing accessing the EMP table all together, and immediately returning this query with no data found.
    Edited by: Toon Koppelaars on Mar 15, 2010 7:17 AM

  • Looking for a book or link to  understand indexes stats an explain plan

    Please,
    Where could I find a good book or link to leran more about indexes statistics:
    My Concerns are:
    How could I know indexes in the database that are most used,less used and used at all in order to get rid of the last one?
    A book or link to fully undertstand how to analyze explain plan give some advices from that.
    Thank a lot for your coperation

    There is any link where I can find how to analyze explain plan output?Again, the manuals are usually a good place to start:
    http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14211/ex_plan.htm#g42231

  • What is the base of Explain Plan?

    On what basis oracle generates explain plan? I mean, is it based on table structure which we are using in SQL query OR it is based on rows exists in table, Or something else.

    user2081225 wrote:
    On what basis oracle generates explain plan? I mean, is it based on table structure which we are using in SQL query OR it is based on rows exists in table, Or something else.SQL data is stored in specific data structures. Some SQL data will be indexed. These indexes are also stored in specific data structures.
    To retrieve data from these structures, you need a program (a series of executable commands that can find and retrieve the required data).
    A SQL query is human readable source code that means nothing to Oracle ito how to find the required rows. It needs to take that source code and compile it into binary machine-like code. In other words, it needs to create an executable program (called a cursor) that can be run to find the required rows.
    The execution plan is a human readable format of this program - it shows how the cursor will be executed.
    How does it construct the program?
    It has a set of modules that can do different things (ito data access). E.g. scan an entire table using a full table scan. Scan a unique index to find the address (rowid) of a row. Scan a non-unique indexes using a range scan and return a range of row addresses. Etc.
    It also has algorithms on how to combine these data retrieval methods. For example, hash joining the output of such operations. Merge joining the output of index scans. Using a nested loop, where the inner loop is executed for the data found by the outer loop. Etc.
    So the CBO dynamically builds a program (cursor) that consists of methods to get to the data required, and processing algorithms to glue these methods together into a logical process flow.
    It does this based on data (stats) it has about the tables and indexes (data volumes, distribution, etc), about the type of data structures used for the relevant tables and indexes (hash tables, iot's, b-trees, bitmaps, partitions, clusters..), and so on.
    The CBO is a pretty clever piece of software that dynamically writes data retrieval programs called cursors. And unfortunately this complexity is often underestimated and misunderstood.

  • Can't understand the output of the exercise

    here is the problem:-
    An audio signal is sometimes stored as a list of int values. The values represent the intensity of the signal at successive time intervals. Of course, in a program the signal is represented with an array.
    Often a small amount of noise is included in the signal. Noise is usually small, momentary changes in the signal level. An example is the "static" that is heard in addition to the signal in AM radio.
    Smoothing a signal removes some of the noise and improves the perceptual quality of the signal. This exercise is to smooth the values in an integer array.
    Say that the original values are in the array "signal". Compute the smoothed array by doing this: Each value smooth[N] is the average of three values: signal[N-1], signal[N], and signal[N+1].
    For the first element of smooth, average the first two elements of signal. For the last element of smooth, average the last two elements of signal.
    here is the original data for the signal array.
    int[] signal  = {5, 5, 4, 5, 6, 6, 7, 6, 5, 4, 1, 4};i had to declare another array by the name of smooth.
    int[] smooth Now i am having a big problem. here is the output of the program from author point of view using the original data in signal array.
    C:\>java Smooth
    signal: 1 5 4 5 7 6 8 6 5 4 5 4
    smooth: 3 3 4 5 6 7 6 6 5 4 4 4
    C:\>i got completely lost. the original signal data is replaced by a new one but how ? if i can get a more detail explanation on this problem by anyone it would be great. so i thought to assign some duke dollars if i can understand the logic not trying to be greedy but to see who is a good teacher. thanks.
    once i get a good explanation i can go ahead and start coding and see if i can achieve this. i am pretty much sure it is a simple task but author made it looks like my worst nightmare.

    here is the problem:-
    An audio signal is sometimes stored as a list of int values. The values represent the intensity of the signal at successive time intervals. Of course, in a program the signal is represented with an array.
    Often a small amount of noise is included in the signal. Noise is usually small, momentary changes in the signal level. An example is the "static" that is heard in addition to the signal in AM radio.
    Smoothing a signal removes some of the noise and improves the perceptual quality of the signal. This exercise is to smooth the values in an integer array.
    Say that the original values are in the array "signal". Compute the smoothed array by doing this: Each value smooth[N] is the average of three values: signal[N-1], signal[N], and signal[N+1].
    For the first element of smooth, average the first two elements of signal. For the last element of smooth, average the last two elements of signal.
    here is the original data for the signal array.
    int[] signal  = {5, 5, 4, 5, 6, 6, 7, 6, 5, 4, 1, 4};i had to declare another array by the name of smooth.
    int[] smooth Now i am having a big problem. here is the output of the program from author point of view using the original data in signal array.
    C:\>java Smooth
    signal: 1 5 4 5 7 6 8 6 5 4 5 4
    smooth: 3 3 4 5 6 7 6 6 5 4 4 4
    C:\>i got completely lost. the original signal data is replaced by a new one but how ? if i can get a more detail explanation on this problem by anyone it would be great. so i thought to assign some duke dollars if i can understand the logic not trying to be greedy but to see who is a good teacher. thanks.
    once i get a good explanation i can go ahead and start coding and see if i can achieve this. i am pretty much sure it is a simple task but author made it looks like my worst nightmare.

  • Cannot understand the output of x*y

    Hello All,
    I was running the following program.
    import java.io.*;
    public class Basics {
         public static void main(String[] args) {
    System.out.println("---------" + args.length + "---------");
              System.out.println("argument is " + args[1]);
    If i run the program with arguments 3+4(numbers could be anything),it runs fine ,provides the desired output.
    But if i run the program with 3*7 as its arguments it gives me the following output.
    ---------9---------
    argument is .classpath
    *Please explain why this difference in output                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Try:
    public class Basics {
      public static void main(String[] args) {
        System.out.println("---------" + args.length + "---------");
        for (int i = 0; i < args.length; i++)
          System.out.println("Argument #" + i + " is: " + args);
    It may be more revealing...

  • Cannot understand the output

    class TrickyTest {
         public static void main ( String args [ ] ) {
              int i = 10 ; // line 1
              i = ++i ; // line 2
              i = i++ ; // line 3
              System . out . println ( i ); // line 4
    };The answer is 11. Why not 12?

    FFS!
    1. NEVER write code like i = i++
    2. Search the forum or google. This has been asked plenty of times.

  • Explain plan output  for a sql in JSP page

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

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

  • About explain plan

    Hello ALL,
    I have the following explain plan, can any body explain the meaning of this explain plan
    SELECT * FROM
    2 TABLE(DBMS_XPLAN.DISPLAY('PLAN_TABLE','111'));
    | Id | Operation | Name | Rows | Bytes |TempSpc| Cost |
    | 0 | SELECT STATEMENT | | 401 | 25263 | | 751K|
    | 1 | MERGE JOIN SEMI | | 401 | 25263 | | 751K|
    | 2 | SORT JOIN | | 17M| 820M| 2108M| 75297 |
    | 3 | TABLE ACCESS FULL | TABLE1 | 17M| 820M| | 3520 |
    |* 4 | SORT UNIQUE | | 275M| 3412M| 10G| 676K|
    | 5 | VIEW | VW_NSO_1 | 275M| 3412M| | 3538 |
    |* 6 | HASH JOIN | | 275M| 7874M| | 3538 |
    |* 7 | TABLE ACCESS FULL| TABLE2 | 16 | 128 | | 2 |
    |* 8 | TABLE ACCESS FULL| TABLE1 | 17M| 360M| | 3520 |
    Predicate Information (identified by operation id):
    4 - access("TABLE1"."POSITION"="VW_NSO_1"."$nso_col_1")
    filter("TABLE1"."POSITION"="VW_NSO_1"."$nso_col_1")
    6 - access("TABLE2"."VERSION_NO"="TABLE1"."VERSION_NO")
    7 - filter("TABLE2"."STATIC_UPD_FLAG"='N')
    8 - filter("TABLE1"."DATETIME_INSERTED">TO_DATE('0004-01-01 00:00:00',
    'yyyy-mm-dd hh24:mi:ss'))
    Note: cpu costing is off
    26 rows selected.
    SQL>

    There is a section in the manual on interpreting the output of explain plan http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96533/ex_plan.htm#16972 Tom Kyte also discusses interpreting the plan http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:231814117467#7344298017927 (page down about halfway where he starts his book excerpt).
    Rows, bytes, and temp space are the cost-based optimizer's guess about the number of rows, bytes, and temp space that will be touched (or consumed) by the operation. The cost is an internal number that has no significance to you when you're reading an explain plan-- it does have some significance when you are examining an event 10046 trace.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Explain plan left the building

    Hello guys, i have interesting problem, at least it seemed to me like that.
    I am on 10.2.0.4.0 and for every statement i do explain plan i get the same plan ???.
    Propably very known issue to some, but i didn't exeperienced that till now, so if somene have some advice, please share.
    E.g.
    SQL> explain plan for select user from dual;
    Explained.
    SQL> select * from table(dbms_xplan.display);
    Plan hash value: 3995103059
    | Id  | Operation                    | Name           | Rows  | Bytes | Cost (%CPU)| Time     | Inst   |
    |   0 | SELECT STATEMENT REMOTE      |                |     1 |    96 | 97591   (5)| 00:05:07 |        |
    |   1 |  SORT ORDER BY               |                |     1 |    96 | 97591   (5)| 00:05:07 |        |
    |*  2 |   TABLE ACCESS BY INDEX ROWID| CCONTACT_ALL   |     1 |    54 |     3   (0)| 00:00:01 | VIPBS~ |
    |   3 |    NESTED LOOPS              |                |     1 |    96 | 97590   (5)| 00:05:07 |        |
    |*  4 |     TABLE ACCESS FULL        | CUSTOMER_ALL   |     1 |    42 | 97587   (5)| 00:05:07 | VIPBS~ |
    |*  5 |     INDEX RANGE SCAN         | PKCCONTACT_ALL |     1 |       |     2   (0)| 00:00:01 | VIPBS~ |
    Predicate Information (identified by operation id):
       2 - filter("A1"."CCCONTRACT"='X')
       4 - filter((TO_NUMBER("A2"."CSCOMPTAXNO")=3007943362918 OR
                  TO_NUMBER("A2"."PASSPORTNO")=0109965330447) AND (TO_NUMBER("A2"."CSLEVEL")=10 OR
                  TO_NUMBER("A2"."CSLEVEL")=20 AND "A2"."TMCODE"<>59 AND "A2"."TMCODE"<>42 AND "A2"."TMCODE"<>61
                  AND "A2"."TMCODE"<>11 AND "A2"."TMCODE"<>19) AND "A2"."CSTYPE"='a' AND "A2"."PAYMNTRESP"='X')
       5 - access("A1"."CUSTOMER_ID"="A2"."CUSTOMER_ID")
           filter("A1"."CUSTOMER_ID"<>0)
    Note
       - 'PLAN_TABLE' is old version
       - fully remote statement
    28 rows selected....so, it looks like i am doing all that just with select user from dual .... : ) ... ok
    SQL> explain plan for
      2  SELECT param_value
      3  FROM ncis.cis_case_script_vars
      4  WHERE case_id = 296645706 AND seq = 1 AND param_name = 'OHOPNAMT';
    Explained.
    SQL> select * from table(dbms_xplan.display);
    Plan hash value: 3995103059
    | Id  | Operation                    | Name           | Rows  | Bytes | Cost (%CPU)| Time     | Inst   |
    |   0 | SELECT STATEMENT REMOTE      |                |     1 |    96 | 97591   (5)| 00:05:07 |        |
    |   1 |  SORT ORDER BY               |                |     1 |    96 | 97591   (5)| 00:05:07 |        |
    |*  2 |   TABLE ACCESS BY INDEX ROWID| CCONTACT_ALL   |     1 |    54 |     3   (0)| 00:00:01 | VIPBS~ |
    |   3 |    NESTED LOOPS              |                |     1 |    96 | 97590   (5)| 00:05:07 |        |
    |*  4 |     TABLE ACCESS FULL        | CUSTOMER_ALL   |     1 |    42 | 97587   (5)| 00:05:07 | VIPBS~ |
    |*  5 |     INDEX RANGE SCAN         | PKCCONTACT_ALL |     1 |       |     2   (0)| 00:00:01 | VIPBS~ |
    Predicate Information (identified by operation id):
       2 - filter("A1"."CCCONTRACT"='X')
       4 - filter((TO_NUMBER("A2"."CSCOMPTAXNO")=3007943362918 OR
                  TO_NUMBER("A2"."PASSPORTNO")=0109965330447) AND (TO_NUMBER("A2"."CSLEVEL")=10 OR
                  TO_NUMBER("A2"."CSLEVEL")=20 AND "A2"."TMCODE"<>59 AND "A2"."TMCODE"<>42 AND "A2"."TMCODE"<>61
                  AND "A2"."TMCODE"<>11 AND "A2"."TMCODE"<>19) AND "A2"."CSTYPE"='a' AND "A2"."PAYMNTRESP"='X')
       5 - access("A1"."CUSTOMER_ID"="A2"."CUSTOMER_ID")
           filter("A1"."CUSTOMER_ID"<>0)
    Note
       - 'PLAN_TABLE' is old version
       - fully remote statement
    28 rows selected.
    SQL>..same plan for different sql...
    ..and now, i am trying to explain plan for several easy sqls but look...
    SQL> explain plan for select * from all_objects where rownum < 2;
    explain plan for select * from all_objects where rownum < 2
    ERROR at line 1:
    ORA-01039: insufficient privileges on underlying objects of the view
    SQL> explain plan for select * from user_tables ;
    explain plan for select * from user_tables
    ERROR at line 1:
    ORA-01039: insufficient privileges on underlying objects of the view
    SQL> desc all_objects
    Name                                                                    Null?    Type
    OWNER                                                                   NOT NULL VARCHAR2(30)
    OBJECT_NAME                                                             NOT NULL VARCHAR2(30)
    SUBOBJECT_NAME                                                                   VARCHAR2(30)
    OBJECT_ID                                                               NOT NULL NUMBER
    DATA_OBJECT_ID                                                                   NUMBER
    OBJECT_TYPE                                                                      VARCHAR2(19)
    CREATED                                                                 NOT NULL DATE
    LAST_DDL_TIME                                                           NOT NULL DATE
    TIMESTAMP                                                                        VARCHAR2(19)
    STATUS                                                                           VARCHAR2(7)
    TEMPORARY                                                                        VARCHAR2(1)
    GENERATED                                                                        VARCHAR2(1)
    SECONDARY                                                                        VARCHAR2(1)...i can't figure this out... maybe i have to flush 'explain plan' ? it's ok if it sounds funny,im off with ideas..
    then i tried to explain this sql:
    SQL> explain plan for
      2  SELECT param_value
      3  FROM ncis.cis_case_script_vars
      4  WHERE case_id = 296645706 AND seq = 1 AND param_name = 'OHOPNAMT';
    Explained.
    SQL> select * from table(dbms_xplan.display);
    Plan hash value: 3995103059
    | Id  | Operation                    | Name           | Rows  | Bytes | Cost (%CPU)| Time     | Inst   |
    |   0 | SELECT STATEMENT REMOTE      |                |     1 |    96 | 97591   (5)| 00:05:07 |        |
    |   1 |  SORT ORDER BY               |                |     1 |    96 | 97591   (5)| 00:05:07 |        |
    |*  2 |   TABLE ACCESS BY INDEX ROWID| CCONTACT_ALL   |     1 |    54 |     3   (0)| 00:00:01 | VIPBS~ |
    |   3 |    NESTED LOOPS              |                |     1 |    96 | 97590   (5)| 00:05:07 |        |
    |*  4 |     TABLE ACCESS FULL        | CUSTOMER_ALL   |     1 |    42 | 97587   (5)| 00:05:07 | VIPBS~ |
    |*  5 |     INDEX RANGE SCAN         | PKCCONTACT_ALL |     1 |       |     2   (0)| 00:00:01 | VIPBS~ |
    Predicate Information (identified by operation id):
       2 - filter("A1"."CCCONTRACT"='X')
       4 - filter((TO_NUMBER("A2"."CSCOMPTAXNO")=3007943362918 OR
                  TO_NUMBER("A2"."PASSPORTNO")=0109965330447) AND (TO_NUMBER("A2"."CSLEVEL")=10 OR
                  TO_NUMBER("A2"."CSLEVEL")=20 AND "A2"."TMCODE"<>59 AND "A2"."TMCODE"<>42 AND "A2"."TMCODE"<>61
                  AND "A2"."TMCODE"<>11 AND "A2"."TMCODE"<>19) AND "A2"."CSTYPE"='a' AND "A2"."PAYMNTRESP"='X')
       5 - access("A1"."CUSTOMER_ID"="A2"."CUSTOMER_ID")
           filter("A1"."CUSTOMER_ID"<>0)
    Note
       - 'PLAN_TABLE' is old version
       - fully remote statement
    28 rows selected.
    SQL>..and got the same plan again....
    anyone with suggestons, anyone encountered this behaviour ?

    Vili Dialis wrote:
    Is there some way to force usage of one of them explicitly, how can i know which one is currently used ?
    So what happend here ?
    I am using what plan table of the above, and why that table generates always the same plan ?
    */To bypass the problem (probably), and to see how it happened (possibly) see http://jonathanlewis.wordpress.com/2010/01/25/old-plan_table/
    Not sure why you keep getting the same plan, but dbms_xplan does a 'select where plan_id = (select max(plan_id) ..) so perhaps the plan_table(s) you keep using have an artificially high plan_id which is always getting selected. (You could try doing: delete from plan_table ; commit; )
    Regards
    Jonathan Lewis
    http://jonathanlewis.wordpress.com
    http://www.jlcomp.demon.co.uk
    A general reminder about "Forum Etiquette / Reward Points": http://forums.oracle.com/forums/ann.jspa?annID=718
    If you never mark your questions as answered people will eventually decide that it's not worth trying to answer you because they will never know whether or not their answer has been of any use, or whether you even bothered to read it.
    It is also important to mark answers that you thought helpful - again it lets other people know that you appreciate their help, but it also acts as a pointer for other people when they are researching the same question, moreover it means that when you mark a bad or wrong answer as helpful someone may be prompted to tell you (and the rest of the forum) what's so bad or wrong about the answer you found helpful.

  • Autotrace explain plan

    Hi
    i like to know how can i understand the output of the autotrace ..
    my current sql explain plan is
    Execution Plan
    Plan hash value: 2038802176
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 9 | 1026 | 332 (3)| 00:00:04 |
    | 1 | SORT ORDER BY | | 9 | 1026 | 332 (3)| 00:00:04 |
    | 2 | HASH UNIQUE | | 9 | 1026 | 331 (3)| 00:00:04 |
    | 3 | NESTED LOOPS | | | | | |
    | 4 | NESTED LOOPS | | 9 | 1026 | 330 (2)| 00:00:04 |
    |* 5 | TABLE ACCESS FULL | EATTEND_STUDENT_ATTENDANCE | 9 | 144 | 294 (3)|
    |* 6 | INDEX RANGE SCAN | PERF_EATTEND_STUDENT_INFO_N99 | 7 | | 2 (0)| 0
    |* 7 | TABLE ACCESS BY INDEX ROWID| EATTEND_STUDENT_INFO | 1 | 98 | 4 (0)| 0
    how will i decide where is the performance issue ???
    thanks

    Don't think you have any issues here, given the small number of rows you're query returns.
    You can find useful information regariding interpreting execution plans by exploring these links:
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14211/ex_plan.htm#i16971
    http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:111012348061
    http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:231814117467
    and do some searches on those sites yourself
    Also, post your execution plan between the {noformat}{noformat} tag, so it'll stay formatted.
    For example, when you type:
    {noformat}select *
    from dual{noformat}
    it will appear as:select *
    from dualwhen you post it on this forum.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Why bother to use explain plan?

    All my colleagues used the third party applications, Crystal Report or TAOD, to query data from the 10g R2 database for some kind of reporting. The problem is they always created the query with multiple outer join (> 10 tables) and they WRITE the codes without using the explain plan. They simply used the query for result of the moment and the query they wrote only were used for few time (< 3), because the manager requested the report kept changing the requirement. They did it on both Dev and Prod
    I think it is bad practice, how can I convience them to change their practice?

    The concept that something is ad hoc and therefore doesn't matter can break down pretty quickly when a bright light is shined upon it. But what you are fighting here is more a question of politics than technology.
    If the system is still chugging along at an acceptable speed, no end-user complaints, and practices in your organization range from sloppy to lazy you should probably just polish up your resume and move to a job where people care about professional standards and doing a good job.
    To change a practice such as this usually one must get to the level of childish schoolyard play and create a competitive atmosphere. Take one of those slow queries and tune it. Challenge someone to do better than you did. Offer a beer to anyone that can write it more efficiently than you did, etc. Make it a game.
    But don't be surprised if the reason they aren't running explain plan is that:
    1. They don't know how
    2. They know how but don't know how to read the output
    3. They know how to read the output but haven't a clue what to do about it.
    As an example ... I know a lot of people that think they know how to output an explain plan. In truth not 10% of them understand this:
    SELECT * FROM TABLE(dbms_xplan.display_cursor('cpm9ss48qd32f', 0));
    http://www.psoug.org/reference/dbms_xplan.html
    Which is really rather sad.

  • :Z in predicate section of explain plan

    Hi Friends,
    What is the meaning of :Z in the predicate section of execution plan of a query ? I didnt understand it .
    Also how do i get the execution plan to format properly?? Earlier using code it would get formatted properly.
    create table table_x nologging as                                                                                                                                                                                                         
    select /*+ parallel(a,4) full(a,4) */                                                                                                                                                                                                                    
    ban, subscriber_no , soc PP, effective_date , expiration_date                                                                                                                                                                                            
    from table_a a                                                                                                                                                                                                                                 
    where service_type = 'P'                                                                                                                                                                                                                                 
    and soc = 'SDDVRP'                                                                                                                                                                                                                                       
    and effective_date <= sysdate                                                                                                                                                                                                                            
    and (expiration_date > sysdate or expiration_date is null)                                                                                                                                                                                               
    PLANS FROM CURSOR
    SQL_ID  fp0591aupqpwd, child number 0                                                                                                                                                                                                                    
    Plan hash value: 679415194                                                                                                                                                                                                                               
    | Id  | Operation              | Name              | Rows  | Bytes | Cost  | Pstart| Pstop |    TQ  |IN-OUT| PQ Distrib |                                                                                                                                
    |   0 | CREATE TABLE STATEMENT |                   |       |       |   291K|       |       |        |      |            |                                                                                                                                
    |   1 |  LOAD AS SELECT        |                   |       |       |       |       |       |        |      |            |                                                                                                                                
    |   2 |   PX COORDINATOR       |                   |       |       |       |       |       |        |      |            |                                                                                                                                
    |   3 |    PX SEND QC (RANDOM) | :TQ10000          |     7 |   315 |   291K|       |       |  Q1,00 | P->S | QC (RAND)  |                                                                                                                                
    |   4 |     PX BLOCK ITERATOR  |                   |     7 |   315 |   291K|     1 |    97 |  Q1,00 | PCWC |            |                                                                                                                                
    |*  5 |      TABLE ACCESS FULL | table_a           |     7 |   315 |   291K|     1 |    97 |  Q1,00 | PCWP |            |                                                                                                                                
    Predicate Information (identified by operation id):                                                                                                                                                                                                      
       5 - access(:Z>=:Z AND :Z<=:Z)                                                                                                                                                                                                                         
           filter(("SERVICE_TYPE"='P' AND "SOC"='SDDVRP' AND "EFFECTIVE_DATE"<=SYSDATE@! AND                                                                                                                                                                 
                  ("EXPIRATION_DATE">SYSDATE@! OR "EXPIRATION_DATE" IS NULL)))

    Hi Jonathan,
    Thanks for explaining that, i understood it now .
    Below is the format for explain plan using your suggestion. Seems it didnt work or i misunderstood your suggestions.
    Also for some reason i dont see any preview option to see the output
    <pre>
    Plan hash value: 679415194                                                                                                                                                                                                                           
    | Id  | Operation              | Name              | Rows  | Bytes | Cost  | Pstart| Pstop |    TQ  |IN-OUT| PQ Distrib |                                                                                                                            
    |   0 | CREATE TABLE STATEMENT |                   |       |       |   291K|       |       |        |      |            |                                                                                                                            
    |   1 |  LOAD AS SELECT        |                   |       |       |       |       |       |        |      |            |                                                                                                                            
    |   2 |   PX COORDINATOR       |                   |       |       |       |       |       |        |      |            |                                                                                                                            
    |   3 |    PX SEND QC (RANDOM) | :TQ10000          |     7 |   315 |   291K|       |       |  Q1,00 | P->S | QC (RAND)  |                                                                                                                            
    |   4 |     PX BLOCK ITERATOR  |                   |     7 |   315 |   291K|     1 |    97 |  Q1,00 | PCWC |            |                                                                                                                            
    |*  5 |      TABLE ACCESS FULL | table_a           |     7 |   315 |   291K|     1 |    97 |  Q1,00 | PCWP |            |                                                                                                                            
    </pre>

  • Query regarding Partition table Explain plan

    Hello,
    We are amidst a tuning activity, wherein a large table has been partitioned for better administration. During testing, I was analyzing the explain plans for long running sql's and found a piece that I was unable to understand. The PSTART and PSTOP columns show ROWID as its value, which in normal partition pruning scenario be the Partition number or the KEY. I tried to look around for this issue but did not get enough information. Can anybody help me of what it means? Also, if there is a good explanation of the same, it will be extremely helpful.
    The snippet from explain plan looks like:
    | Id  | Operation                                | Name                          | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     | Pstart| Pstop |
    7 |        TABLE ACCESS BY GLOBAL INDEX ROWID| XXXXXXXXXXXXXXXXXXXX             | 43874 |  9083K|       |  1386   (1)| 00:00:17 | ROWID | ROWID |
    On another similar query it looks like:
    | Id  | Operation                             | Name                         | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     | Pstart| Pstop |
    |   6 |     TABLE ACCESS BY GLOBAL INDEX ROWID| XXXXXXXXXXXXXX               | 22455 |  4648K|       |   456   (1)| 00:00:06 |     9 |     9 |
    I have another query with regards to the Partition tables. Does it, require/benefit if, the Indexes to be in partitioned mode? I tried to read about it but did not get a conclusive evidence. I am trying to test it and post here the outcome, but if anybody has experience of working with it, it would be great to have some advice.
    Oracle Version:- 10.2.0.4
    Regards,
    Purvesh.

    Hi Purvesh.
    Great explanation and example on this this topic...
    Ask Tom &amp;quot;explain plan on range-partitioned table&amp;quot;
    Hope this help.

Maybe you are looking for

  • How to know the sales order closed using right click menu -Close ???

    I have an sales order with ten item, I have copied the same to delivery and before adding the Delivery I have deleted some items. After adding the Delivery, I manually closed the sales order by using the "right click menu close". The Open Quantity of

  • Warning 20225: Adobe Acrobat 7.0 Setup

    When I install Adobe Acrobat 7 (Professional), Acrobat returns the error "Warning 20225: Adobe Acrobat 7.0 Setup was unable to create a new item: Adobe PDF Converter. The Adobe PDF Printer may be unavailable. GetLastError: The specified module could

  • Gantt Chart in Webdynpro Java

    Hi All, I want to display the Gantt Chart in my Application. I am using following as a reference: [http://help.sap.com/saphelp_nw04/helpdata/en/c6/af11b1423a3c4fb642e357912936e4/frameset.htm] But i am unable to get the Bars in my Chart. I am just get

  • Is iPhoto '11 safe to install yet?

    It been a couple months since the release. Ive heard and read many horror stories about losing photos, computers slowing down, and computers and iphoto crashing. Is it safe yet to install iPhoto '11? Have there been any solutions? Have any problems b

  • Problem with file created through GUI_DOWNLOAD

    Hello, I have the following code REPORT  zprueba. START-OF-SELECTION.   TYPES: BEGIN OF t_type,     field1(20),     field2(20),   END OF t_type.   DATA: lt_data TYPE STANDARD TABLE OF t_type,         ls_data TYPE t_type.   ls_data-field1 = '1'.   ls_