Strange explain plan when query SYS tables

Oracle Version 9.2.0.7
We have an application that runs the following query on Oracle 9.2.0.7
SELECT T1.TABLE_NAME,T1.COLUMN_NAME, T1.SRID, T2.SDO_UB, T2.SDO_LB, T1.OWNER FROM ALL_SDO_GEOM_METADATA T1, TABLE(T1.DIMINFO) T2 WHERE T1.OWNER=UPPER(:"SYS_B_0") AND T1.TABLE_NAME=UPPER(:"SYS_B_1")
Without the self join the query is fine, but with the self join on our customers database the explain plan is doing full table scans and Hash Joins on SYS tables and takes 2 minutes.
Rows Row Source Operation
2 FILTER
2 NESTED LOOPS
1 TABLE ACCESS FULL SDO_GEOM_METADATA_TABLE
2 COLLECTION ITERATOR PICKLER FETCH
1 UNION-ALL
0 FILTER
0 NESTED LOOPS OUTER
0 HASH JOIN
37 TABLE ACCESS FULL TS$
0 HASH JOIN OUTER
0 NESTED LOOPS OUTER
0 NESTED LOOPS OUTER
0 NESTED LOOPS
1 NESTED LOOPS
1 TABLE ACCESS BY INDEX ROWID USER$
1 INDEX UNIQUE SCAN I_USER1 (object id 44)
1 TABLE ACCESS BY INDEX ROWID OBJ$
1 INDEX RANGE SCAN I_OBJ2 (object id 37)
0 TABLE ACCESS CLUSTER TAB$
1 INDEX UNIQUE SCAN I_OBJ# (object id 3)
0 TABLE ACCESS CLUSTER SEG$
0 INDEX UNIQUE SCAN I_FILE#_BLOCK# (object id 9)
0 TABLE ACCESS BY INDEX ROWID OBJ$
0 INDEX UNIQUE SCAN I_OBJ1 (object id 36)
0 TABLE ACCESS FULL USER$
0 INDEX UNIQUE SCAN I_OBJ1 (object id 36)
0 NESTED LOOPS
0 FIXED TABLE FULL X$KZSRO
0 INDEX RANGE SCAN I_OBJAUTH2 (object id 109)
0 FIXED TABLE FULL X$KZSPR
0 FILTER
0 NESTED LOOPS OUTER
0 HASH JOIN
54 TABLE ACCESS FULL USER$
0 HASH JOIN
29447 TABLE ACCESS FULL OBJ$
0 HASH JOIN OUTER
0 HASH JOIN OUTER
0 HASH JOIN OUTER
0 NESTED LOOPS
0 NESTED LOOPS OUTER
0 NESTED LOOPS OUTER
0 NESTED LOOPS
0 NESTED LOOPS
0 NESTED LOOPS
1 NESTED LOOPS
1 TABLE ACCESS BY INDEX ROWID USER$
1 INDEX UNIQUE SCAN I_USER1 (object id 44)
1 TABLE ACCESS BY INDEX ROWID OBJ$
1 INDEX RANGE SCAN I_OBJ2 (object id 37)
0 TABLE ACCESS CLUSTER TAB$
1 INDEX UNIQUE SCAN I_OBJ# (object id 3)
0 TABLE ACCESS CLUSTER TS$
0 INDEX UNIQUE SCAN I_TS# (object id 7)
0 TABLE ACCESS CLUSTER COL$
0 TABLE ACCESS CLUSTER SEG$
0 INDEX UNIQUE SCAN I_FILE#_BLOCK# (object id 9)
0 TABLE ACCESS BY INDEX ROWID OBJ$
0 INDEX UNIQUE SCAN I_OBJ1 (object id 36)
0 TABLE ACCESS CLUSTER COLTYPE$
0 TABLE ACCESS FULL USER$
0 TABLE ACCESS FULL OBJ$
0 TABLE ACCESS FULL USER$
0 INDEX UNIQUE SCAN I_OBJ1 (object id 36)
0 NESTED LOOPS
0 FIXED TABLE FULL X$KZSRO
0 INDEX RANGE SCAN I_OBJAUTH2 (object id 109)
0 FIXED TABLE FULL X$KZSPR
1 FILTER
1 NESTED LOOPS
1 NESTED LOOPS OUTER
1 NESTED LOOPS
1 TABLE ACCESS BY INDEX ROWID USER$
1 INDEX UNIQUE SCAN I_USER1 (object id 44)
1 TABLE ACCESS BY INDEX ROWID OBJ$
1 INDEX RANGE SCAN I_OBJ2 (object id 37)
0 INDEX UNIQUE SCAN I_TYPED_VIEW1 (object id 105)
1 INDEX UNIQUE SCAN I_VIEW1 (object id 104)
0 NESTED LOOPS
0 FIXED TABLE FULL X$KZSRO
0 INDEX RANGE SCAN I_OBJAUTH2 (object id 109)
0 FIXED TABLE FULL X$KZSPR
On our development database it takes 0.07 sec with no full table scans and no hash joins.
Rows Row Source Operation
2 NESTED LOOPS
1 TABLE ACCESS BY INDEX ROWID SDO_GEOM_METADATA_TABLE
1 INDEX RANGE SCAN SDO_GEOM_IDX (object id 36753)
1 UNION-ALL
0 FILTER
0 NESTED LOOPS
0 NESTED LOOPS OUTER
0 NESTED LOOPS OUTER
0 NESTED LOOPS OUTER
0 NESTED LOOPS OUTER
0 NESTED LOOPS
1 NESTED LOOPS
1 TABLE ACCESS BY INDEX ROWID USER$
1 INDEX UNIQUE SCAN I_USER1 (object id 44)
1 TABLE ACCESS BY INDEX ROWID OBJ$
1 INDEX RANGE SCAN I_OBJ2 (object id 37)
0 TABLE ACCESS CLUSTER TAB$
1 INDEX UNIQUE SCAN I_OBJ# (object id 3)
0 TABLE ACCESS BY INDEX ROWID OBJ$
0 INDEX UNIQUE SCAN I_OBJ1 (object id 36)
0 INDEX UNIQUE SCAN I_OBJ1 (object id 36)
0 TABLE ACCESS CLUSTER USER$
0 INDEX UNIQUE SCAN I_USER# (object id 11)
0 TABLE ACCESS CLUSTER SEG$
0 INDEX UNIQUE SCAN I_FILE#_BLOCK# (object id 9)
0 TABLE ACCESS CLUSTER TS$
0 INDEX UNIQUE SCAN I_TS# (object id 7)
0 NESTED LOOPS
0 FIXED TABLE FULL X$KZSRO
0 INDEX RANGE SCAN I_OBJAUTH2 (object id 109)
0 FIXED TABLE FULL X$KZSPR
0 FILTER
0 NESTED LOOPS
0 NESTED LOOPS
0 NESTED LOOPS OUTER
0 NESTED LOOPS OUTER
0 NESTED LOOPS OUTER
0 NESTED LOOPS OUTER
0 NESTED LOOPS OUTER
0 NESTED LOOPS OUTER
0 NESTED LOOPS
0 NESTED LOOPS
0 NESTED LOOPS
0 NESTED LOOPS
1 NESTED LOOPS
1 TABLE ACCESS BY INDEX ROWID USER$
1 INDEX UNIQUE SCAN I_USER1 (object id 44)
1 TABLE ACCESS BY INDEX ROWID OBJ$
1 INDEX RANGE SCAN I_OBJ2 (object id 37)
0 TABLE ACCESS CLUSTER TAB$
1 INDEX UNIQUE SCAN I_OBJ# (object id 3)
0 TABLE ACCESS CLUSTER TS$
0 INDEX UNIQUE SCAN I_TS# (object id 7)
0 TABLE ACCESS CLUSTER COL$
0 TABLE ACCESS CLUSTER COLTYPE$
0 TABLE ACCESS CLUSTER SEG$
0 INDEX UNIQUE SCAN I_FILE#_BLOCK# (object id 9)
0 TABLE ACCESS BY INDEX ROWID OBJ$
0 INDEX UNIQUE SCAN I_OBJ1 (object id 36)
0 TABLE ACCESS CLUSTER USER$
0 INDEX UNIQUE SCAN I_USER# (object id 11)
0 TABLE ACCESS BY INDEX ROWID OBJ$
0 INDEX UNIQUE SCAN I_OBJ1 (object id 36)
0 TABLE ACCESS CLUSTER USER$
0 INDEX UNIQUE SCAN I_USER# (object id 11)
0 INDEX UNIQUE SCAN I_OBJ1 (object id 36)
0 TABLE ACCESS BY INDEX ROWID OBJ$
0 INDEX RANGE SCAN I_OBJ3 (object id 38)
0 TABLE ACCESS CLUSTER USER$
0 INDEX UNIQUE SCAN I_USER# (object id 11)
0 NESTED LOOPS
0 FIXED TABLE FULL X$KZSRO
0 INDEX RANGE SCAN I_OBJAUTH2 (object id 109)
0 FIXED TABLE FULL X$KZSPR
1 FILTER
1 NESTED LOOPS
1 NESTED LOOPS OUTER
1 NESTED LOOPS
1 TABLE ACCESS BY INDEX ROWID USER$
1 INDEX UNIQUE SCAN I_USER1 (object id 44)
1 TABLE ACCESS BY INDEX ROWID OBJ$
1 INDEX RANGE SCAN I_OBJ2 (object id 37)
0 INDEX UNIQUE SCAN I_TYPED_VIEW1 (object id 105)
1 INDEX UNIQUE SCAN I_VIEW1 (object id 104)
0 NESTED LOOPS
0 FIXED TABLE FULL X$KZSRO
0 INDEX RANGE SCAN I_OBJAUTH2 (object id 109)
0 FIXED TABLE FULL X$KZSPR
2 COLLECTION ITERATOR PICKLER FETCH
ALL_SDO_GEOM_METADATA is a view in the MDSYS schema (generated by Oracle ).
SELECT SDO_OWNER OWNER,
SDO_TABLE_NAME TABLE_NAME,
SDO_COLUMN_NAME COLUMN_NAME,
SDO_DIMINFO DIMINFO,
SDO_SRID SRID
FROM SDO_GEOM_METADATA_TABLE
WHERE
(exists
(select table_name from all_tables
where table_name=sdo_table_name
and owner = sdo_owner
union all
select table_name from all_object_tables
where table_name=sdo_table_name
and owner = sdo_owner
union all
select view_name table_name from all_views
where view_name=sdo_table_name
and owner = sdo_owner))
Statistics have been gathered for the MDSYS user.
If this had not been SYS schema I would have immediately concluded that fresh statistics are required. The SYS objects concerend are valid with all indexes
From my understanding you are not meant to gather stats for the SYS schema in Oracle 9 as Data Dictionary queries still uses RBO?
Any ideas as to why Oracle is doing full table scans when querying SYS tables? The optimizer_mode is set to FIRST_ROWS.
Any ideas greatly recevied.
Thanks

Maybe I'm missing something but this:
INDEX FULL SCAN     SISESTAT     I0_ESTRUTURA_COMERCIALindicates that one of those indexes is being used.
This:
T_ESTRUTURA_COMERCIALIs nowhere to be found in your Explain Plan. It appears that either you have posted the wrong plan
or Oracle is doing a query rewrite to a materialized view.

Similar Messages

  • ORA-00604 ORA-00904 When query partitioned table with partitioned indexes

    Got ORA-00604 ORA-00904 When query partitioned table with partitioned indexes in the data warehouse environment.
    Query runs fine when query the partitioned table without partitioned indexes.
    Here is the query.
    SELECT al2.vdc_name, al7.model_series_name, COUNT (DISTINCT (al1.vin)),
    al27.accessory_code
    FROM vlc.veh_vdc_accessorization_fact al1,
    vlc.vdc_dim al2,
    vlc.model_attribute_dim al7,
    vlc.ppo_list_dim al18,
    vlc.ppo_list_indiv_type_dim al23,
    vlc.accy_type_dim al27
    WHERE ( al2.vdc_id = al1.vdc_location_id
    AND al7.model_attribute_id = al1.model_attribute_id
    AND al18.mydppolist_id = al1.ppo_list_id
    AND al23.mydppolist_id = al18.mydppolist_id
    AND al23.mydaccytyp_id = al27.mydaccytyp_id
    AND ( al7.model_series_name IN ('SCION TC', 'SCION XA', 'SCION XB')
    AND al2.vdc_name IN
    ('PORT OF BALTIMORE',
    'PORT OF JACKSONVILLE - LEXUS',
    'PORT OF LONG BEACH',
    'PORT OF NEWARK',
    'PORT OF PORTLAND'
    AND al27.accessory_code IN ('42', '43', '44', '45')
    GROUP BY al2.vdc_name, al7.model_series_name, al27.accessory_code

    I would recommend that you post this at the following OTN forum:
    Database - General
    General Database Discussions
    and perhaps at:
    Oracle Warehouse Builder
    Warehouse Builder
    The Oracle OLAP forum typically does not cover general data warehousing topics.

  • General queries regarding explain plan and query

    Hello Oracle buddies,
    I have few badly formed queries with plenty of nested loops, merge join cartesian , plenty of sorting and in the query so many sub queries and all.. The cost of the queries are high like anything.
    some even has 130Crore of cost .
    When I got the chance to look into those quries I test them in Non Prod systems and which almost have 90-95% similar data as it was refresh by PROD few weeks back.
    I found few queries are having the same explain plan but cost is less like anything. for example 5000 or 6000.
    When I check for the possibilities of wrong statistics I found they just collect with default setting...
    In Non prod I saw only the auto stat job is ran and most of the tables are having the stats which are of last analyzed on the day of refresh.
    Now what could be so differentiating factor that drives a queries' cost lesser than Prod systems, when the data is almost same. Also if prod ssystem is gather by only gather_schema_stat('SCHEMA_NAME') then it should carry the same stat in non prod while refreshing. I know ppl do not gather stat on test only auto job is running ...
    I need to have clear prove before I can have a clear understanding..
    Please help me to know what factors could be differentiating?
    -Regards,
    J_DBA_Sourav

    j_DBA_sourav wrote:
    Hello Jonathan,
    Thanks for the reply. The team refreshed it, by expdp/impdp method where by default statistics are included. In that case?
    Is this problem probable to happen due to statistics only or anything else is also responsible. Even the explain plan is same.
    Please through some light on it.
    Auto job is on as I stated earlier but in test systems most of the tables are showing refreshed date as last_analyzed
    -Regards
    JDS
    Anything that puts the stats out of sync with each other may be sufficient to cause problems. Any queries that depend on sysdate may cause a problem.
    As a simple check:  select table_name, last_analyzed from user_tables on the two systems, with some order by clause (e.g. table_name), and see how many tables were analysed at different times - anything on either system after the exp/imp could be part of your problem.
    Regards
    Jonathan Lewis
    http://jonathanlewis.wordpress.com
    Now on Twitter: @jloracle

  • Query Regarding Explain Plan on Query

    Hello,
    I have one big query which shows report of 50000 daily records from @ 20,00,000 records.
    I have two databases UAT and PROD.when i do Explain Plan on the query is these different database i get the different plan where everything is same in both database.
    In UAT it is doing Index scan where as in PROD it is doing Full TableScan. Below are the results.
    In production it is not using any of the indexes present but in UAT it is.What could be the reasong behind this?

    Sure.
    UAT Explain Plan (Please copy in Textpad for better View)
    SELECT STATEMENT, GOAL = HINT: ALL_ROWS     Cost=371     Cardinality=238     Optimizer=HINT: ALL_ROWS     Bytes=134470
    VIEW     Object owner=SWNET1          Cost=371     Cardinality=238          Bytes=134470
    COUNT STOPKEY                              
    VIEW     Object owner=SWNET1          Cost=371     Cardinality=238          Bytes=131376
    SORT ORDER BY STOPKEY          Cost=371     Cardinality=238          Bytes=54026
    FILTER                              
    HASH JOIN RIGHT ANTI          Cost=370     Cardinality=238          Bytes=54026
    INLIST ITERATOR                              
    TABLE ACCESS BY INDEX ROWID     Object owner=SWNET1     Object name=IS_TB_END_POINT     Cost=1     Cardinality=1     Optimizer=ANALYZED     Bytes=31
    INDEX RANGE SCAN          Object owner=SWNET1     Object name=IS_UK_EP_NAME     Cost=1     Cardinality=1     Optimizer=ANALYZED     
    TABLE ACCESS BY INDEX ROWID     Object owner=SWNET1     Object name=IS_TB_TRANSACTION     Cost=368     Cardinality=253     Optimizer=ANALYZED     Bytes=49588
    INDEX FULL SCAN          Object owner=SWNET1     Object name=IS_IX_T_DESTINATION_EP     Cost=18     Cardinality=13909     Optimizer=ANALYZED
    PRODUCTION Explain Plan
    SELECT STATEMENT, GOAL = HINT: ALL_ROWS               Cost=65702     Cardinality=1000     Optimizer=HINT: ALL_ROWS     Bytes=565000
    VIEW     Object owner=SWNET1          Cost=65702     Cardinality=1000          Bytes=565000
    COUNT STOPKEY                              
    VIEW     Object owner=SWNET1          Cost=65702     Cardinality=38739          Bytes=21383928
    SORT ORDER BY STOPKEY          Cost=65702     Cardinality=38739          Bytes=9646011
    FILTER                              
    HASH JOIN RIGHT ANTI          Cost=63616     Cardinality=38739          Bytes=9646011
    INLIST ITERATOR                              
    TABLE ACCESS BY INDEX ROWID     Object owner=SWNET1     Object name=IS_TB_END_POINT     Cost=1     Cardinality=2     Optimizer=ANALYZED     Bytes=64
    INDEX UNIQUE SCAN          Object owner=SWNET1     Object name=IS_UK_EP_NAME     Cost=1     Cardinality=2     Optimizer=ANALYZED     
    TABLE ACCESS FULL          Object owner=SWNET1     Object name=IS_TB_TRANSACTION     Cost=63614     Cardinality=44697     Optimizer=ANALYZED     Bytes=9699249
    Index Query (Same on both places)
    create index IS_IX_T_DESTINATION_EP on IS_TB_TRANSACTION (T_DESTINATION_EP)
    tablespace IS_XML_IND
    pctfree 10
    initrans 2
    maxtrans 255
    storage
    initial 128M
    next 128K
    minextents 1
    maxextents unlimited
    pctincrease 0
    );

  • Error when querying a table through the Query Window

    I am running a query on the following table in the ODT Query window - for some reason I get the error below when trying to retrieve the data - I can query the table just fine through SQL Plus - it errors out whether I use grid or text window
    ERROR
    Arithmetic operation resulted in an overflow.
    CREATE TABLE "RF3_PROD_1"."F_EXTRACTMETRICS" ("EXTRACT_NAME" VARCHAR2(50) NOT NULL,"RUN_START_DATE" DATE NOT NULL,"RUN_END_DATE" DATE NOT NULL,"DURATION" NUMBER DEFAULT 0 NOT NULL,"EXTRACT_START_DATE" DATE NULL,"EXTRACT_END_DATE" DATE NULL,"NUM_RECS_ADDED" NUMBER DEFAULT 0 NOT NULL,"NUM_RECS_DELETED" NUMBER DEFAULT 0 NOT NULL,"STATUS" VARCHAR2(50) NOT NULL,"COMMENTS" VARCHAR2(500) NULL) TABLESPACE "EXTRACT_TAB_01_TS" PCTFREE 15 PCTUSED 75 INITRANS 1 MAXTRANS 255 STORAGE ( FREELISTS 1 FREELIST GROUPS 1 INITIAL 8388608 NEXT 516096 MAXEXTENTS 2147483645 MINEXTENTS 1 PCTINCREASE 0 )
    I would have formatted it nicer - but that is the way that ODT created it :)

    Christian,
    I found that this happens when trying to query number fields that are reals with a large decimal value (26 decimal values and above seem to be the magic number). What is strange is that I don't get this problem when I retrieve data from the same table using the Retrieve data option (versus a query for all the data in the Query Window) so they don't seem to be utilizing the same basic code to grab and then display the data interestingly enough (I am sure you knew that). Does this allow you to replicate the issue?
    Thanks,
    Bryan

  • Explain plan for query with variables

    Trying to Explain plan for some sql in sql*plus. The query has a variable in it. How do I do this ?
    I did look into explain plan and dbms_xplan but could not find anything with variables

    use sqlplus bind variables:
    SQL> --define variable
    SQL> var x varchar2
    SQL> -- notice the colon prefixing the variable
    SQL> explain plan for select * from customer where cid = :x;
    Explained.
    SQL> select * from table( dbms_xplan.display );
    PLAN_TABLE_OUTPUT
    Plan hash value: 1709312366
    | Id  | Operation                   | Name     | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT            |          |     1 |    67 |     2   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS BY INDEX ROWID| CUSTOMER |     1 |    67 |     2   (0)| 00:00:01 |
    |*  2 |   INDEX RANGE SCAN          | CID      |     1 |       |     1   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - access("CID"=:X)
    14 rows selected.the variable does not need to be set to explain the query, since explain does not actually execute.
    Edited by: shoblock on Nov 6, 2008 4:51 PM

  • Explain plan for Query performance

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

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

  • Explain plan when have a View

    Hi
    I have a query and trying to use INDEX with hint, but I no use when is a view, is there some way for to use it ?
    SELECT /*+ INDEX(T1 I0_PS_COMPL_ESTRUT_COMERCIAL)
               INDEX(T2 I0_ESTRUTURA_COMERCIAL)  */
            T2.CD_TIPO_ESTRUTURA_COMERCIAL,
            T2.CD_ESTRUTURA_COMERCIAL,
            T2.CD_GERENCIA_VENDA
    FROM  T_PS_COMPL_ESTRUT_COMERCIAL T1,
           T_ESTRUTURA_COMERCIAL       T2
      WHERE  T1.CD_TIPO_ESTRUTURA_COMERCIAL = T2.CD_TIPO_ESTRUTURA_COMERCIAL
      AND   T1.CD_ESTRUTURA_COMERCIAL = T2.CD_ESTRUTURA_COMERCIAL
      AND   T2.ID_ESTRUTURA_ATIVA = 1
      AND   T1.ID_PROXIMIDADE = 2
      ORDER BY 3,2
    SELECT STATEMENT, GOAL = CHOOSE               74     534     27768     71          1
    SORT ORDER BY               74     534     27768     71     SEL$F5BB74E1     1
      HASH JOIN               73     534     27768     71          1
       MAT_VIEW ACCESS BY INDEX ROWID     SISESTAT     M_ESTRUTURA_COMERCIAL_CAD     69     1685     23590     68     SEL$F5BB74E1     1
        INDEX FULL SCAN     SISESTAT     I0_ESTRUTURA_COMERCIAL     10     3370          10     SEL$F5BB74E1     1
       REMOTE          T_PS_COMPL_ESTRUT_COMERCIAL     3     1069     40622     3     SEL$F5BB74E1     1

    Maybe I'm missing something but this:
    INDEX FULL SCAN     SISESTAT     I0_ESTRUTURA_COMERCIALindicates that one of those indexes is being used.
    This:
    T_ESTRUTURA_COMERCIALIs nowhere to be found in your Explain Plan. It appears that either you have posted the wrong plan
    or Oracle is doing a query rewrite to a materialized view.

  • Help needed in EXPLAIN PLAN for a partitioned table

    Oracle Version 9i
    (Paste execution plan in a spreadsheet to make sense out of it)
    I am trying to tune this query -
    select * from comm c ,dates d
    where
    d.active_period = 'Y'
    and c.period = d.period;
    Operation     Object Name     Rows     Bytes     Cost     Object Node     In/Out     PStart     PStop
    SELECT STATEMENT Optimizer Mode=CHOOSE          5 M          278887                     
    HASH JOIN          5 M     5G     278887                     
    TABLE ACCESS FULL     SCHEMA.DATES     24      1 K     8                     
    PARTITION LIST ALL                                   1     8
    TABLE ACCESS FULL     SCHEMA.COMM     6 M     5G     277624                1     8
    However, I know that the dates table will return only one record. So, if I add another condition to the above query, I get this execution plan. The comm table is huge but it is partitioned on period.
    select * from comm c ,dates d
    where
    d.active_period = 'Y'
    and c.period = qd.period
    and c.period = 'OCT-07'
    Operation     Object Name     Rows     Bytes     Cost     Object Node     In/Out     PStart     PStop
    SELECT STATEMENT Optimizer Mode=CHOOSE          1           8                     
    MERGE JOIN CARTESIAN          1      9 K     8                     
    TABLE ACCESS FULL     SCHEMA.DATES     1      69      8                     
    BUFFER SORT          1      9 K                         
    TABLE ACCESS BY LOCAL INDEX ROWID     SCHEMA.COMM     1      9 K                    7     7
    INDEX RANGE SCAN     SCHEMA.COMM_NP9     1                          7     7
    How can I make the query such that the comm table does not have to traverse all of its partitions? The partitioning is based on quarters so it will get its data in one partition only (in the above example - partition no. 7)
    Thanks in advance for writing in your replies :)

    You need to specify period = 'OCT-07', otherwise there is no way the optimizer can know it needs to access only one partition.
    Alternatively, partition the DATES table in exactly the same way on "period", and partition-wise joins should kick in, and effectively accessing only the active partition.

  • Explain plan for query

    HI all
    Please help to evaluate the explian plan for query suppose the following is the plan
    | Id  | Operation                        | Name             | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT                 |                  |     7 |  1260 |   303   (1)| 00:00:04 |
    |   1 |  SORT ORDER BY                   |                  |     7 |  1260 |   303   (1)| 00:00:04 |
    |*  2 |   FILTER                         |                  |       |       |            |          |
    |   3 |    NESTED LOOPS                  |                  |       |       |            |          |
    |   4 |     NESTED LOOPS                 |                  |     7 |  1260 |   302   (1)| 00:00:04 |
    |   5 |      NESTED LOOPS                |                  |     7 |   791 |   281   (1)| 00:00:04 |
    PLAN_TABLE_OUTPUT                                                                                      
    |*  6 |       TABLE ACCESS BY INDEX ROWID| TASKDETAIL       |     7 |   574 |   267   (1)| 00:00:04 |
    |*  7 |        INDEX SKIP SCAN           | IDX_TD_TTS       |  2726 |       |    29   (0)| 00:00:01 |
    |*  8 |       TABLE ACCESS BY INDEX ROWID| ORDERS           |     1 |    31 |     2   (0)| 00:00:01 |
    |*  9 |        INDEX UNIQUE SCAN         | PK_SYS_C004711   |     1 |       |     1   (0)| 00:00:01 |
    |* 10 |      INDEX RANGE SCAN            | TEPS_PICK_INDEX1 |     1 |       |     2   (0)| 00:00:01 |
    |* 11 |     TABLE ACCESS BY INDEX ROWID  | TASK_PICK_EPS    |     1 |    67 |     3   (0)| 00:00:01 |
    -----------------------------------------------------------------------------------------------------1. what are the columns rows ,bytes,cost ,time indicate us

    The current 11.2 version of the documentation (URL below) would be better than the 9.2 version
    http://docs.oracle.com/cd/E11882_01/server.112/e16638/ex_plan.htm#i19260
    "Rows" is the expected number of rows that will be returned by that step of the plan
    "Bytes" is the expected size of the result set returned by that step of the plan
    "Time" is the expected execution time --- this can be grossly off because Oracle uses some assumptions about singe block read time, multiblock read time and CPU speed.
    Hemant K Chitale
    Edited by: Hemant K Chitale on Sep 25, 2012 3:04 PM

  • Write Explain Plan in a new Table

    Hi,
    I Like to execute a Explain plan and write them to a Table to store the Plan.
    Sombody have s skript or somthing else ?
    Thanks

    Hey,
    Try:
    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
    PL/SQL Release 10.2.0.1.0 - Production
    CORE     10.2.0.1.0     Production
    TNS for Linux: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    SQL> CREATE TABLE MY_PLAN_TABLE
    2 (     STATEMENT_ID VARCHAR2(30),
    3      PLAN_ID NUMBER,
    4      TIMESTAMP DATE,
    5      REMARKS VARCHAR2(4000),
    6      OPERATION VARCHAR2(30),
    7      OPTIONS VARCHAR2(255),
    8      OBJECT_NODE VARCHAR2(128),
    9      OBJECT_OWNER VARCHAR2(30),
    10      OBJECT_NAME VARCHAR2(30),
    11      OBJECT_ALIAS VARCHAR2(65),
    12      OBJECT_INSTANCE NUMBER(*,0),
    13      OBJECT_TYPE VARCHAR2(30),
    14      OPTIMIZER VARCHAR2(255),
    15      SEARCH_COLUMNS NUMBER,
    16      ID NUMBER(*,0),
    17      PARENT_ID NUMBER(*,0),
    18      DEPTH NUMBER(*,0),
    19      POSITION NUMBER(*,0),
    20      COST NUMBER(*,0),
    21      CARDINALITY NUMBER(*,0),
    22      BYTES NUMBER(*,0),
    23      OTHER_TAG VARCHAR2(255),
    24      PARTITION_START VARCHAR2(255),
    25      PARTITION_STOP VARCHAR2(255),
    26      PARTITION_ID NUMBER(*,0),
    27      OTHER LONG,
    28      OTHER_XML CLOB,
    29      DISTRIBUTION VARCHAR2(30),
    30      CPU_COST NUMBER(*,0),
    31      IO_COST NUMBER(*,0),
    32      TEMP_SPACE NUMBER(*,0),
    33      ACCESS_PREDICATES VARCHAR2(4000),
    34      FILTER_PREDICATES VARCHAR2(4000),
    35      PROJECTION VARCHAR2(4000),
    36      TIME NUMBER(*,0),
    37      QBLOCK_NAME VARCHAR2(30)
    38 )
    39 /
    Table created
    SQL> EXPLAIN PLAN
    2 SET STATEMENT_ID = 'test'
    3 INTO MY_PLAN_TABLE
    4 FOR
    5 SELECT 1 FROM DUAL;
    Explained
    SQL> select * FROM TABLE(DBMS_XPLAN.display('MY_PLAN_TABLE','test'));
    PLAN_TABLE_OUTPUT
    Plan hash value: 1388734953
    | Id | Operation | Name | Rows | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 1 | 2 (0)| 00:00:01 |
    | 1 | FAST DUAL | | 1 | 2 (0)| 00:00:01 |
    8 rows selected
    SQL>

  • Strange explain plan

    I wrote a SQL in Oracle EBS, please see the following:
    SELECT msi.segment1 item_num, mmt.revision revision,
    msi.description description_en,
    msi_tl.long_description description_cn,
    mmt.transfer_organization_id mfg_org_id,
    xxuts_inv_trh_pkg.get_organization_name(mmt.transfer_organization_id),
    mmt.subinventory_code subinv, mmt.locator_id,
    mtln.lot_number lot_num, mmt.transaction_id txn_id,
    mmt.transfer_subinventory co_subinv, mmt.transfer_locator_id,
    mmt.transaction_date txn_date, fn.user_name user_name,
    mts.transaction_source_type_name txn_source_type,
    wie.wip_entity_name order_num,
    xxuts_inv_trh_pkg.get_qty_before (mmt.organization_id,
    mmt.inventory_item_id,
    mmt.revision,
    mmt.subinventory_code,
    mmt.transaction_id,
    mmt.transaction_date
    DECODE (msi.lot_control_code,
    2, mtln.transaction_quantity,
    mmt.transaction_quantity
    ) txn_qty,
    mtt.transaction_type_name txn_type, mmt.actual_cost item_cost,
    DECODE (msi.lot_control_code,
    2, mtln.transaction_quantity,
    mmt.transaction_quantity
    * mmt.actual_cost amount,
    mtln.primary_quantity primary_qty,
    NVL
    (mtr.reason_name,
    (SELECT mtrh.attribute1 || mtrh.attribute2 || mtrh.attribute3
    FROM mtl_txn_request_headers mtrh
    WHERE EXISTS (
    SELECT 'X'
    FROM mtl_txn_request_lines mtrl
    WHERE mtrh.header_id = mtrl.header_id
    AND mtrl.transaction_header_id =
    mmt.transaction_set_id
    AND mtrl.txn_source_id = mmt.transaction_source_id
    AND mtrl.line_id = mmt.source_line_id))
    ) reason,
    mmt.transaction_reference REFERENCE
    FROM mtl_system_items_b msi --250,
    mtl_system_items_tl msi_tl --500,
    mtl_transaction_lot_numbers mtln -210,
    mtl_material_transactions mmt -333,
    mtl_transaction_types mtt,
    mtl_txn_source_types mts,
    mtl_item_categories mic -800,
    mtl_transaction_reasons mtr,
    fnd_user fn,
    wip_entities wie --5
    WHERE msi.inventory_item_id = mmt.inventory_item_id
    AND msi.inventory_item_id = msi_tl.inventory_item_id
    AND msi.organization_id = msi_tl.organization_id
    AND mtr.reason_id(+) = mmt.reason_id
    AND msi_tl.LANGUAGE = USERENV ('LANG')
    AND mmt.transaction_id = mtln.transaction_id(+)
    AND mic.inventory_item_id = mmt.inventory_item_id
    AND mic.organization_id = mmt.organization_id
    AND mic.category_set_id = :b15
    AND mmt.transaction_type_id = mtt.transaction_type_id
    AND mmt.transaction_source_type_id = mts.transaction_source_type_id
    AND msi.organization_id = mmt.organization_id
    AND mmt.transaction_source_id = wie.wip_entity_id
    AND mmt.transaction_source_type_id IN (5)
    AND fn.user_id = mmt.created_by
    AND mmt.organization_id = :b14
    AND msi.segment1 >= NVL (:b13, msi.segment1)
    AND msi.segment1 <= NVL (:b12, msi.segment1)
    AND NVL (mmt.revision, '-99') = NVL (NVL (:b11, mmt.revision), '-99')
    AND mmt.subinventory_code >= NVL (:b10, mmt.subinventory_code)
    AND mmt.subinventory_code <= NVL (:b9, mmt.subinventory_code)
    AND mmt.transaction_date BETWEEN :b8 AND :b7
    AND mmt.creation_date BETWEEN :b6 AND :b5
    AND mmt.transaction_type_id = NVL (:b4, mmt.transaction_type_id)
    AND mmt.transaction_source_type_id = NVL (:b3, mmt.transaction_source_type_id)
    AND mmt.transaction_id = NVL (:b2, mmt.transaction_id)
    AND fn.user_id = NVL (:b1, fn.user_id)
    It's explain plan is:
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | INSERT STATEMENT | | | | 33 (100)| |
    | 1 | CONCATENATION | | | | | |
    |* 2 | FILTER | | | | | |
    | 3 | NESTED LOOPS | | 1 | 312 | 17 (0)| 00:00:01 |
    | 4 | NESTED LOOPS | | 1 | 297 | 15 (0)| 00:00:01 |
    | 5 | NESTED LOOPS OUTER | | 1 | 282 | 13 (0)| 00:00:01 |
    | 6 | NESTED LOOPS | | 1 | 257 | 10 (0)| 00:00:01 |
    | 7 | NESTED LOOPS | | 1 | 188 | 8 (0)| 00:00:01 |
    | 8 | NESTED LOOPS | | 1 | 174 | 7 (0)| 00:00:01 |
    | 9 | NESTED LOOPS | | 1 | 148 | 6 (0)| 00:00:01 |
    | 10 | NESTED LOOPS OUTER | | 1 | 128 | 5 (0)| 00:00:01 |
    | 11 | NESTED LOOPS | | 1 | 108 | 4 (0)| 00:00:01 |
    | 12 | TABLE ACCESS BY INDEX ROWID| MTL_TXN_SOURCE_TYPES | 1 | 18 | 1 (0)| 00:00:01 |
    |* 13 | INDEX UNIQUE SCAN | MTL_TXN_SOURCE_TYPES_U1 | 1 | | 0 (0)| |
    |* 14 | TABLE ACCESS BY INDEX ROWID| MTL_MATERIAL_TRANSACTIONS | 1 | 90 | 3 (0)| 00:00:01 |
    |* 15 | INDEX RANGE SCAN | MTL_MATERIAL_TRANSACTIONS_N8 | 1 | | 2 (0)| 00:00:01 |
    | 16 | TABLE ACCESS BY INDEX ROWID | MTL_TRANSACTION_REASONS | 1 | 20 | 1 (0)| 00:00:01 |
    |* 17 | INDEX UNIQUE SCAN | MTL_TRANSACTION_REASONS_U1 | 1 | | 0 (0)| |
    | 18 | TABLE ACCESS BY INDEX ROWID | WIP_ENTITIES | 1 | 20 | 1 (0)| 00:00:01 |
    |* 19 | INDEX UNIQUE SCAN | WIP_ENTITIES_U1 | 1 | | 0 (0)| |
    | 20 | TABLE ACCESS BY INDEX ROWID | MTL_TRANSACTION_TYPES | 1 | 26 | 1 (0)| 00:00:01 |
    |* 21 | INDEX UNIQUE SCAN | MTL_TRANSACTION_TYPES_U1 | 1 | | 0 (0)| |
    | 22 | TABLE ACCESS BY INDEX ROWID | FND_USER | 1 | 14 | 1 (0)| 00:00:01 |
    |* 23 | INDEX UNIQUE SCAN | FND_USER_U1 | 1 | | 0 (0)| |
    |* 24 | TABLE ACCESS BY INDEX ROWID | MTL_SYSTEM_ITEMS_B | 1 | 69 | 2 (0)| 00:00:01 |
    |* 25 | INDEX UNIQUE SCAN | MTL_SYSTEM_ITEMS_B_U1 | 1 | | 1 (0)| 00:00:01 |
    | 26 | TABLE ACCESS BY INDEX ROWID | MTL_TRANSACTION_LOT_NUMBERS | 1 | 25 | 3 (0)| 00:00:01 |
    |* 27 | INDEX RANGE SCAN | MTL_TRANSACTION_LOT_NUMBERS_N1 | 1 | | 2 (0)| 00:00:01 |
    |* 28 | INDEX RANGE SCAN | MTL_ITEM_CATEGORIES_U1 | 1 | 15 | 2 (0)| 00:00:01 |
    | 29 | TABLE ACCESS BY INDEX ROWID | MTL_SYSTEM_ITEMS_TL | 1 | 15 | 2 (0)| 00:00:01 |
    |* 30 | INDEX UNIQUE SCAN | MTL_SYSTEM_ITEMS_TL_U1 | 1 | | 1 (0)| 00:00:01 |
    |* 31 | FILTER | | | | | |
    | 32 | NESTED LOOPS OUTER | | 1 | 312 | 16 (0)| 00:00:01 |
    | 33 | NESTED LOOPS | | 1 | 287 | 13 (0)| 00:00:01 |
    | 34 | NESTED LOOPS | | 1 | 272 | 11 (0)| 00:00:01 |
    | 35 | NESTED LOOPS | | 1 | 257 | 9 (0)| 00:00:01 |
    | 36 | NESTED LOOPS | | 1 | 188 | 7 (0)| 00:00:01 |
    | 37 | NESTED LOOPS OUTER | | 1 | 162 | 6 (0)| 00:00:01 |
    | 38 | NESTED LOOPS | | 1 | 142 | 5 (0)| 00:00:01 |
    | 39 | NESTED LOOPS | | 1 | 128 | 4 (0)| 00:00:01 |
    | 40 | NESTED LOOPS | | 1 | 108 | 3 (0)| 00:00:01 |
    | 41 | TABLE ACCESS BY INDEX ROWID| MTL_TXN_SOURCE_TYPES | 1 | 18 | 1 (0)| 00:00:01 |
    |* 42 | INDEX UNIQUE SCAN | MTL_TXN_SOURCE_TYPES_U1 | 1 | | 0 (0)| |
    |* 43 | TABLE ACCESS BY INDEX ROWID| MTL_MATERIAL_TRANSACTIONS | 1 | 90 | 2 (0)| 00:00:01 |
    |* 44 | INDEX UNIQUE SCAN | MTL_MATERIAL_TRANSACTIONS_U1 | 1 | | 1 (0)| 00:00:01 |
    | 45 | TABLE ACCESS BY INDEX ROWID | WIP_ENTITIES | 48143 | 940K| 1 (0)| 00:00:01 |
    |* 46 | INDEX UNIQUE SCAN | WIP_ENTITIES_U1 | 1 | | 0 (0)| |
    | 47 | TABLE ACCESS BY INDEX ROWID | FND_USER | 1 | 14 | 1 (0)| 00:00:01 |
    |* 48 | INDEX UNIQUE SCAN | FND_USER_U1 | 1 | | 0 (0)| |
    | 49 | TABLE ACCESS BY INDEX ROWID | MTL_TRANSACTION_REASONS | 36 | 720 | 1 (0)| 00:00:01 |
    |* 50 | INDEX UNIQUE SCAN | MTL_TRANSACTION_REASONS_U1 | 1 | | 0 (0)| |
    | 51 | TABLE ACCESS BY INDEX ROWID | MTL_TRANSACTION_TYPES | 98 | 2548 | 1 (0)| 00:00:01 |
    |* 52 | INDEX UNIQUE SCAN | MTL_TRANSACTION_TYPES_U1 | 1 | | 0 (0)| |
    |* 53 | TABLE ACCESS BY INDEX ROWID | MTL_SYSTEM_ITEMS_B | 297 | 20493 | 2 (0)| 00:00:01 |
    |* 54 | INDEX UNIQUE SCAN | MTL_SYSTEM_ITEMS_B_U1 | 1 | | 1 (0)| 00:00:01 |
    | 55 | TABLE ACCESS BY INDEX ROWID | MTL_SYSTEM_ITEMS_TL | 96026 | 1406K| 2 (0)| 00:00:01 |
    |* 56 | INDEX UNIQUE SCAN | MTL_SYSTEM_ITEMS_TL_U1 | 1 | | 1 (0)| 00:00:01 |
    |* 57 | INDEX RANGE SCAN | MTL_ITEM_CATEGORIES_U1 | 1 | 15 | 2 (0)| 00:00:01 |
    | 58 | TABLE ACCESS BY INDEX ROWID | MTL_TRANSACTION_LOT_NUMBERS | 1 | 25 | 3 (0)| 00:00:01 |
    |* 59 | INDEX RANGE SCAN | MTL_TRANSACTION_LOT_NUMBERS_N1 | 1 | | 2 (0)| 00:00:01 |
    Predicate Information (identified by operation id):
    2 - filter((:B6<=:B5 AND :B8<=:B7 AND :B2 IS NULL))
    13 - access("MTS"."TRANSACTION_SOURCE_TYPE_ID"=5)
    14 - filter(("MMT"."TRANSACTION_SOURCE_ID" IS NOT NULL AND
    "MMT"."TRANSACTION_TYPE_ID"=NVL(:B4,"MMT"."TRANSACTION_TYPE_ID") AND
    "MMT"."SUBINVENTORY_CODE">=NVL(:B10,"MMT"."SUBINVENTORY_CODE") AND
    "MMT"."SUBINVENTORY_CODE"<=NVL(:B9,"MMT"."SUBINVENTORY_CODE") AND
    NVL("MMT"."REVISION",'-99')=NVL(NVL(:B11,"MMT"."REVISION"),'-99') AND "MMT"."TRANSACTION_ID" IS NOT NULL AND
    "MMT"."CREATION_DATE">=:B6 AND "MMT"."CREATION_DATE"<=:B5))
    15 - access("MMT"."TRANSACTION_SOURCE_TYPE_ID"=5 AND "MMT"."ORGANIZATION_ID"=:B14 AND
    "MMT"."TRANSACTION_DATE">=:B8 AND "MMT"."TRANSACTION_DATE"<=:B7)
    filter(NVL(:B3,"MMT"."TRANSACTION_SOURCE_TYPE_ID")=5)
    17 - access("MTR"."REASON_ID"="MMT"."REASON_ID")
    19 - access("MMT"."TRANSACTION_SOURCE_ID"="WIE"."WIP_ENTITY_ID")
    21 - access("MMT"."TRANSACTION_TYPE_ID"="MTT"."TRANSACTION_TYPE_ID")
    23 - access("FN"."USER_ID"="MMT"."CREATED_BY")
    filter("FN"."USER_ID"=NVL(:B1,"FN"."USER_ID"))
    24 - filter(("MSI"."SEGMENT1">=NVL(:B13,"MSI"."SEGMENT1") AND "MSI"."SEGMENT1"<=NVL(:B12,"MSI"."SEGMENT1")))
    25 - access("MSI"."INVENTORY_ITEM_ID"="MMT"."INVENTORY_ITEM_ID" AND "MSI"."ORGANIZATION_ID"=:B14)
    27 - access("MMT"."TRANSACTION_ID"="MTLN"."TRANSACTION_ID")
    28 - access("MIC"."ORGANIZATION_ID"=:B14 AND "MIC"."INVENTORY_ITEM_ID"="MMT"."INVENTORY_ITEM_ID" AND
    "MIC"."CATEGORY_SET_ID"=:B15)
    30 - access("MSI"."INVENTORY_ITEM_ID"="MSI_TL"."INVENTORY_ITEM_ID" AND "MSI_TL"."ORGANIZATION_ID"=:B14 AND
    "MSI_TL"."LANGUAGE"=USERENV('LANG'))
    31 - filter((:B6<=:B5 AND :B8<=:B7 AND :B2 IS NOT NULL))
    42 - access("MTS"."TRANSACTION_SOURCE_TYPE_ID"=5)
    43 - filter(("MMT"."TRANSACTION_SOURCE_ID" IS NOT NULL AND "MMT"."TRANSACTION_DATE">=:B8 AND
    "MMT"."ORGANIZATION_ID"=:B14 AND "MMT"."TRANSACTION_SOURCE_TYPE_ID"=5 AND
    NVL(:B3,"MMT"."TRANSACTION_SOURCE_TYPE_ID")=5 AND "MMT"."TRANSACTION_TYPE_ID"=NVL(:B4,"MMT"."TRANSACTION_TYPE_ID"
    ) AND "MMT"."SUBINVENTORY_CODE">=NVL(:B10,"MMT"."SUBINVENTORY_CODE") AND
    "MMT"."SUBINVENTORY_CODE"<=NVL(:B9,"MMT"."SUBINVENTORY_CODE") AND
    NVL("MMT"."REVISION",'-99')=NVL(NVL(:B11,"MMT"."REVISION"),'-99') AND "MMT"."TRANSACTION_DATE"<=:B7 AND
    "MMT"."CREATION_DATE">=:B6 AND "MMT"."CREATION_DATE"<=:B5))
    44 - access("MMT"."TRANSACTION_ID"=:B2)
    46 - access("MMT"."TRANSACTION_SOURCE_ID"="WIE"."WIP_ENTITY_ID")
    48 - access("FN"."USER_ID"="MMT"."CREATED_BY")
    filter("FN"."USER_ID"=NVL(:B1,"FN"."USER_ID"))
    50 - access("MTR"."REASON_ID"="MMT"."REASON_ID")
    52 - access("MMT"."TRANSACTION_TYPE_ID"="MTT"."TRANSACTION_TYPE_ID")
    53 - filter(("MSI"."SEGMENT1">=NVL(:B13,"MSI"."SEGMENT1") AND "MSI"."SEGMENT1"<=NVL(:B12,"MSI"."SEGMENT1")))
    54 - access("MSI"."INVENTORY_ITEM_ID"="MMT"."INVENTORY_ITEM_ID" AND "MSI"."ORGANIZATION_ID"=:B14)
    56 - access("MSI"."INVENTORY_ITEM_ID"="MSI_TL"."INVENTORY_ITEM_ID" AND "MSI_TL"."ORGANIZATION_ID"=:B14 AND
    "MSI_TL"."LANGUAGE"=USERENV('LANG'))
    57 - access("MIC"."ORGANIZATION_ID"=:B14 AND "MIC"."INVENTORY_ITEM_ID"="MMT"."INVENTORY_ITEM_ID" AND
    "MIC"."CATEGORY_SET_ID"=:B15)
    59 - access("MMT"."TRANSACTION_ID"="MTLN"."TRANSACTION_ID")
    I am doubt why to perform two times explain plan(Predicate -2 and 31).
    Thanks

    Tom.lai wrote:
    I wrote a SQL in Oracle EBS, please see the following:
    AND msi.segment1 >= NVL (:b13, msi.segment1)
    AND msi.segment1 <= NVL (:b12, msi.segment1)
    AND NVL (mmt.revision, '-99') = NVL (NVL (:b11, mmt.revision), '-99')
    AND mmt.subinventory_code >= NVL (:b10, mmt.subinventory_code)
    AND mmt.subinventory_code <= NVL (:b9, mmt.subinventory_code)
    AND mmt.transaction_date BETWEEN :b8 AND :b7
    AND mmt.creation_date BETWEEN :b6 AND :b5
    AND mmt.transaction_type_id = NVL (:b4, mmt.transaction_type_id)
    AND mmt.transaction_source_type_id = NVL (:b3, mmt.transaction_source_type_id)
    AND mmt.transaction_id = NVL (:b2, mmt.transaction_id)
    AND fn.user_id = NVL (:b1, fn.user_id)I am doubt why to perform two times explain plan(Predicate -2 and 31).Using your NVL expressions above you've hit a special implementation for this particular construct in the Oracle optimizer, for more information, see here:
    http://jonathanlewis.wordpress.com/2007/01/09/conditional-sql/
    http://jonathanlewis.wordpress.com/2007/02/14/conditional-sql-2/
    This splits your plan into two plans for the two cases possible, and depending on if the value passed is NULL or not only one of the branches will actually get executed.
    Regards,
    Randolf
    Oracle related stuff blog:
    http://oracle-randolf.blogspot.com/
    SQLTools++ for Oracle (Open source Oracle GUI for Windows):
    http://www.sqltools-plusplus.org:7676/
    http://sourceforge.net/projects/sqlt-pp/

  • SQLDeveloper can't generate an explain-plan when using "cube"

    If I want to create an explain-plan from the following statement, I get no explain-plan:
    SELECT 1
    FROM   dual
    GROUP BY CUBE( 2, 2, 2, 2, 2, 2, 2, 2, 2 )If I now want to create an explain-plan again, I get the following message (and still no explain-plan):
    http://i.imgur.com/mGO6Z.jpg
    I tried this a few times and of course with a fresh db-session where i didn't run any statements before.
    I get this with:
    SQLDeveloper Version 3.0.04 Build MAIN-04.34 (i.e. production)
    DB 9.2.0.1.0
    Oracle Instant Client 11.1.0.6.0
    In Toad this works btw.
    (Of course it makes no sense to run it on this statement, we encountered this problem with a really big SQL-statement where "cube" was used in an inline-view. SQLDeveloper then wasn't able to generate an explain-plan for the whole-statement)
    Regards
    Markus

    that is correct.  I wanted to keep the login page redirect inside my class method so that I could do the check every time someone came to pages that require authentication. I wanted it in the LoadState method so I can do a check there, redirect
    them to login page or just get a cookie and then pass that cookie to page to build the UI for the page
    I can do what you are suggesting and have actually tried it but then I have to track which page to take the user to after they log in...
    I have multiple clicks in the appbar  and pages from where the user can come to these authentication-bound pages..
    Suggestions?
    Also, what am I doing wrong in my class method that it doesn't navigate to the login page in the LoadState method?
    Thanks 
    mujno

  • ORA -12569 error when querying dba_change_notification_regs table

    Hi,
    I am getting ORA-12569 error when i am trying to execute Select * from dba_change_notification_regs from sys user .we are working on oracle 10.2 version.
    Please help in resoving the issue.
    Thanks In advance.
    Priya

    ORA-12569:     TNS:packet checksum failure
    Cause:      The data received is not the same as the data sent.
    Action:      Attempt the transaction again. If the error is persistent, turn on tracing and reexecute the operation.
    If this doesn't resolve your issue, please see metalink 4933023.8 (problem fixed there)

  • Cursor FOR UPDATE OF when querying multiple tables.

    When I run the below code I am able to update the required table:
    DECLARE
        CURSOR cur_get_recs1 IS
            SELECT *
              FROM ncotestaging os
             WHERE os.ote_status = 1
               AND os.action_type = 'A'
               FOR UPDATE OF ote_status;
    BEGIN
        FOR recOTEstage IN cur_get_recs2
        LOOP
           dbms_output.put_line('Updating Row from ' || recOTEstage.ote_status || ' to: 2');
            UPDATE ncotestaging
               SET ote_status = 2
             WHERE CURRENT OF cur_get_recs2;
        END LOOP;
    END;
    /Results as expected on my 5 rows...
    SQL> @test.sql
    Updating Row from 1 to: 2
    Updating Row from 1 to: 2
    Updating Row from 1 to: 2
    Updating Row from 1 to: 2
    Updating Row from 1 to: 2However, when I update the Cursor to the following....
        CURSOR cur_get_recs1 IS
            SELECT os.*, ces.customer_ref, ces.product_code
              FROM ncotestaging os,
                       custRefSource ces
             WHERE os.ote_status = 1
               AND os.action_type = 'A'
               AND ces.ref_source = os.service_code
               FOR UPDATE OF ncotestaging.ote_status;I get the following error...
    SQL> @test.sql
               FOR UPDATE OF ncotestaging.ote_status;
    ERROR at line 18:
    ORA-06550: line 18, column 26:
    PL/SQL: ORA-00904: "NCOTESTAGING"."OTE_STATUS": invalid identifier
    ORA-06550: line 12, column 9:
    PL/SQL: SQL Statement ignored
    ORA-06550: line 25, column 54:
    PLS-00364: loop index variable 'RECOTESTAGE' use is invalid
    ORA-06550: line 25, column 9:
    PL/SQL: Statement ignoredI don't know why the FOR UPDATE statement reports an invalid identifier. I seem to have the syntax correct according to the PL/SQL documentation. Any pointers gratefully received.

    CURSOR cur_get_recs1 IS> SELECT os.*, ces.customer_ref, ces.product_code
    > FROM ncotestaging os,
    > custRefSource ces
    > WHERE os.ote_status = 1
    > AND os.action_type = 'A'
    >AND ces.ref_source = os.service_code
    >FOR UPDATE OF ncotestaging.ote_status;
    the problem iis u have the alias for the table 'ncotestaging' as os that's y it's throwing the error

Maybe you are looking for

  • Pages, Numbers, Keynote won't launch even after reinstall

    After a new OS (10.5.8) install none of my iLife (09) or iWork (09) apps worked. I reinstalled iLife successfully. But, my iWork apps won't launch even after a reinstall from the original DVD and updating to 4.0.4 My trouble shooting steps so far hav

  • Finding in a Combined PDF file -- which PDF has each find

    I have created a combined file of some 20 PDF files. I now wish to find text across this combined file. I find these as expected and all  I see is the page number within the combined file. This is of no value to me. I would like to know how I display

  • Lots of Kernel panics - Mountain Lion - MBP MID 2011

    I have Installed three times mountain lion, one installation from lion, one from leoppard and now i've installed from scratch. In all of the intallations I'm having lots of Kernel Panics and crashes from Mountain Lion, the crashes aren't the same, so

  • Shuffle does not charge or respond

    I believe my dad has the 2nd generation shuffle. He's had it for a few years now and recently, it stopped responding.  When charging, no light appears on the shuffle, and therefore, the shuffle is no longer charging.  We gave my dad the shuffle as a

  • Marketing to sap bw

    Hi experts I have shifted my career from marketing to sap bw,regarding i left marketing job and joined SAP BW course and now trying for the job. But i am expecting the interview question, why did you shift from marketing career to SAP or what make yo