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>

Similar Messages

  • 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.

  • 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.

  • 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 "explain plan on range-partitioned table"
    Hope this help.

  • Filter(NULL IS NOT NULL) in Explain Plan ??

    Hi All,
    Can someone please explain what this explain plan statement means? I see a filter(NULL IS NOT NULL) as the first statement - could not figure out why it came up so from googling.
    My Query Used:
    EXPLAIN PLAN FOR
    MERGE INTO summary_bysrccd
    USING
    (SELECT LAST_DAY(TRUNC(to_timestamp(os.requestdatetime, 'yyyymmddhh24:mi:ss.ff4'))) AS SUMMARY_DATE,
    os.acctnum,
    ol.sourcecode AS sourcecode,
    ol.sourcename AS sourcename,
    count(1) cnt_articleview
    FROM article_views os , master_sourcecode ol
    where os.sourcecode = ol.sourcecode
    AND os.acctnum IS NOT NULL
    AND ol.sourcecode IS NOT NULL
    AND os.requestdatetime IS NOT NULL
    AND UPPER(os.success_ind) = 'S'
         AND (
              ('INCR'  = 'FULL'
              AND  (get_date_timestamp(os.requestdatetime) BETWEEN TO_DATE('23-AUG-2011 00:00:00','DD-MON-YYYY HH24:MI:SS') AND TO_DATE('27-AUG-2011 23:59:59','DD-MON-YYYY HH24:MI:SS')
              AND   os.entry_CreatedDate BETWEEN TO_DATE('22-AUG-2011 00:00:00','DD-MON-YYYY HH24:MI:SS') AND TO_DATE('28-AUG-2011 00:00:00','DD-MON-YYYY HH24:MI:SS')
              OR ('INCR' = 'FULL'
              AND os.entry_createddate BETWEEN TO_DATE('23-AUG-2011 00:00:00','DD-MON-YYYY HH24:MI:SS') AND TO_DATE('27-AUG-2011 23:59:59','DD-MON-YYYY HH24:MI:SS') )
    group by LAST_DAY(TRUNC(to_timestamp(os.requestdatetime, 'yyyymmddhh24:mi:ss.ff4'))),
    os.acctnum,ol.sourcecode,ol.sourcename) mrg_query
    ON (ods_av_summary_bysrccd.acctnum = mrg_query.acctnum AND
    ods_av_summary_bysrccd.summary_date=mrg_query.summary_date AND
    ods_av_summary_bysrccd.sourcecode=mrg_query.sourcecode)
    WHEN NOT MATCHED THEN
    INSERT (SUMMARY_date,ACCTNUM,SOURCECODE,SOURCENAME,CNT_ARTICLEVIEW,ENTRY_LASTUPDATEDDATE)
    VALUES(mrg_query.summary_date,mrg_query.acctnum,mrg_query.sourcecode,mrg_query.sourcename,
    mrg_query.cnt_articleview,sysdate)
    WHEN MATCHED THEN
    UPDATE SET ods_av_summary_bysrccd.cnt_articleview=
    CASE WHEN NVL('INCR','INCR') = 'FULL' THEN mrg_query.cnt_articleview
    ELSE ods_av_summary_bysrccd.cnt_articleview+mrg_query.cnt_articleview
    END,
    ods_av_summary_bysrccd.entry_lastupdateddate=sysdate;My Explain Plan:
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 268591246
    | Id  | Operation                                 | Name                      | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     | Pstart| Pstop |
    |   0 | MERGE STATEMENT                           |                           |     1 |   456 |       |     3   (0)| 00:00:01 |       |       |
    |   1 |  MERGE                                    | ODS_AV_SUMMARY_BYSRCCD    |       |       |       |            |          |       |       |
    |   2 |   VIEW                                    |                           |       |       |       |            |          |       |       |
    |   3 |    NESTED LOOPS OUTER                     |                           |     1 |   417 |       |     3   (0)| 00:00:01 |       |       |
    |   4 |     VIEW                                  |                           |     1 |   360 |       |     5 (100)| 00:00:01 |       |       |
    |   5 |      SORT GROUP BY                        |                           |     1 |    73 |   595M|            |          |       |       |
    PLAN_TABLE_OUTPUT
    |*  6 |       FILTER                              |                           |       |       |       |            |          |       |       |
    |*  7 |        HASH JOIN                          |                           |  6975K|   485M|  3944K| 17594   (1)| 00:03:32 |       |       |
    |   8 |         TABLE ACCESS FULL                 | ODS_MASTER_SOURCECODE     | 84021 |  2953K|       |   273   (1)| 00:00:04 |       |       |
    |*  9 |         TABLE ACCESS BY GLOBAL INDEX ROWID| ODS_ARTICLE_VIEWS         |  7007K|   247M|       |   826   (0)| 00:00:10 |    33 |    33 |
    |* 10 |          INDEX FULL SCAN                  | IDX_AV_ACCTNUM            |    25M|       |       |    26   (0)| 00:00:01 |       |       |
    |  11 |     TABLE ACCESS BY GLOBAL INDEX ROWID    | ODS_AV_SUMMARY_BYSRCCD    |     1 |    57 |       |     3   (0)| 00:00:01 | ROWID | ROWID |
    |* 12 |      INDEX UNIQUE SCAN                    | ODS_AV_SUMMARY_BYSRCCD_PK |     1 |       |       |     2   (0)| 00:00:01 |       |       |
    Predicate Information (identified by operation id):
    PLAN_TABLE_OUTPUT
       6 - filter(NULL IS NOT NULL)
       7 - access("OS"."SOURCECODE"="OL"."SOURCECODE")
       9 - filter("OS"."REQUESTDATETIME" IS NOT NULL AND "OS"."ENTRY_CREATEDDATE">=TO_DATE(' 2011-08-23 00:00:00', 'syyyy-mm-dd
                  hh24:mi:ss') AND "OS"."ENTRY_CREATEDDATE"<=TO_DATE(' 2011-08-27 23:59:59', 'syyyy-mm-dd hh24:mi:ss') AND UPPER("OS"."SUCCESS_IND")='S')
      10 - filter("OS"."ACCTNUM" IS NOT NULL)
      12 - access("ODS_AV_SUMMARY_BYSRCCD"."SUMMARY_DATE"(+)=INTERNAL_FUNCTION("MRG_QUERY"."SUMMARY_DATE") AND
                  "ODS_AV_SUMMARY_BYSRCCD"."ACCTNUM"(+)="MRG_QUERY"."ACCTNUM" AND "ODS_AV_SUMMARY_BYSRCCD"."SOURCECODE"(+)="MRG_QUERY"."SOURCECODE")
    Note
    PLAN_TABLE_OUTPUT
       - dynamic sampling used for this statement

    Hi Toon,
    Thanks for the quick resolution. I went back and verified the table's colunm details and it has a NOT NULL constraint.
    Regards,
    Chaitanya
    P.S: Is it ok if I ask you for some help regarding a production issue I have been encountering since 15 days but haev no clear resolution yet about what/why is the reason (the said issue is neither uniform nor regular - its affecting some modules and happening on some days - i shall give the full details if you are willing to have a look) - i shall start a new post or email you directly - yur convenience.

  • 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 plans - caching question

    I am trying to get some explain plan information for some queries that we have running poorly. Our application uses some alter session statements to set the optimizer_mode to all_rows. I am trying to determine if we need to include the optimizer_index_cost_adj parameter and possibly the optimizer_index_caching parameter.
    Using SQL Developer I can easily run the different alter session statements needed and then get an explain plan for the query in question. However I am seeing some weird results - for example long query times for queries that have a relatively low cost. On the flip side I am seeing some queries that have a higher cost return quicker.
    I am doing this many times over and am wondering what impact using the same query could have. Is this query being cached in Oracle? To get an accurate explain plan would I need to clear a cache each time?
    Also, in the explain plan is the cost figure the most important? How is it that a query can have a low cost and take longer to complete than the same query with a higher cost and some different parameters?

    There are no fixed road map for what to see in explain plan,but some common observation should be made for explain plan i.e full table scans due to poor use of indexing,inappropriate hints uses for forcing indexing where FTS can be faster.unnecessary sorting,cartesian
    joins, outer joins, and anti-joins.
    At last i would say that every database vary to its different hardware platforms and those hardware have different configuration,these things can effect oracle optimizer.
    So, if my statistics are current, what should I be
    taking out of the explain plan? I always assumed
    cost was the main indicator of the performance of a
    query.As justin already told cost is not something which should be considered for tuning query rather access path, but there is more other then explain plan access path e.g TKPROF tool which will address you plan as well as others stuff which should be considered for tuning query.
    http://download.oracle.com/docs/cd/B10501_01/server.920/a96533/sqltrace.htmKhurram

  • How to create an explain plan with rowsource statistics for a complex query that include multiple table joins ?

    1. How to create an explain plan with rowsource statistics for a complex query that include multiple table joins ?
    When multiple tables are involved , and the actual number of rows returned is more than what the explain plan tells. How can I find out what change is needed  in the stat plan  ?
    2. Does rowsource statistics gives some kind of  understanding of Extended stats ?

    You can get Row Source Statistics only *after* the SQL has been executed.  An Explain Plan midway cannot give you row source statistics.
    To get row source statistics either set STATISTICS_LEVEL='ALL'  in the session that executes theSQL OR use the Hint "gather_plan_statistics"  in the SQL being executed.
    Then use dbms_xplan.display_cursor
    Hemant K Chitale

  • Explain plan different with no stats but with no rows & rows in a table

    Hi All,
    This is in Oracle 8.1.7.4.0 DB.
    1. Query was taking long time to return rows. It was based on a view.
    2. View has multiple tables.
    3. The explain plan was showing one of the Table(e.g. TABLE1) using incorrect INDEX. At the time of explain plan table has no statistics.
    4. truncated Table TABLE1
    5. The explain plan now taking correct INDEX for the table TABLE1.
    How does optimizer choosing the incorrect index when rows in a table & correct index when there are no rows in the table ?
    any insights.
    Thanks
    Sandeep

    I don't know about your particular db version, but CBO in absence of statistics uses some default values (e.g. average row length 100 bytes) and also uses actual number of block for the table. I assume something similar might be for indexes.
    To be sure what has changed you can run 10053 level trace.
    Gints Plivna
    http://www.gplivna.eu

  • Explain Plan Table

    Hi,
    I have created the plan_table using utlxplan.sql but still i am getting the error:
    ORA-02404: specified plan table not found          
    Is there something else to be done to get it fixed?
    please suggest.
    Regards
    Arpit

    As Lukasz suggested check the table privs between the schema where the table was created and the user trying to use it. Also make sure there's a synonym for the user using explain plan to get to the plan table easily; a public synonym might work best

  • SQL Tuning Advisor  Recommends New Explain Plan

    Hi:
    I have to believe this has been asked before but didn't see it in a forum search so I'll ask here. I had SQL Tuning Advisor look at a query and it is recommending a new plan for a 50+% improvement (hazah!). The trouble is, I don't want Oracle to re-write the plan to execute the query better, I want to know how I can re-write the query to generate that more optimal plan in the first place because I have similar systems in the field that I would like to also be optimized. What are my options?
    Thanks.

    Sorry Gaff I know where you are talking about but I don't have your answer, but it may be a good start going over the 19g reference guide for these dictionary views -
    SQL> select view_name from dba_views where view_name like 'DBA%ADVISOR%' ;
    VIEW_NAME
    DBA_ADVISOR_DEFINITIONS
    DBA_ADVISOR_COMMANDS
    DBA_ADVISOR_OBJECT_TYPES
    DBA_ADVISOR_USAGE
    DBA_ADVISOR_TASKS
    DBA_ADVISOR_TEMPLATES
    DBA_ADVISOR_LOG
    ...Best regards.

  • Partition of table n Explain plan

    I am a newbie for oracle partititon. Need help!!!
    I have a created a partition table, range partition by key column datatype is 'timetamp'.
    Stucture would be ::
    CREATE TABLE sales
      ( prod_id       NUMBER(6)
      , cust_id       NUMBER
      , time_id       DATE
      , amount_sold   NUMBER(10,2)
    PARTITION BY RANGE (time_id)
    ( PARTITION sales_q1_2006 VALUES LESS THAN (TO_DATE('01-APR-2006','dd-MON-yyyy'))
    , PARTITION sales_q2_2006 VALUES LESS THAN (TO_DATE('01-JUL-2006','dd-MON-yyyy'))
    , PARTITION sales_q3_2006 VALUES LESS THAN (TO_DATE('01-OCT-2006','dd-MON-yyyy'))
    , PARTITION sales_q4_2006 VALUES LESS THAN (TO_DATE('01-JAN-2007','dd-MON-yyyy'))
    The time i run below query, explain plan shows PStart as #1 and PStop as #4, but this date range access only one partition, explain plan must show particular partition. Also should it show partition name?
    select * from sales where trunc(time_id)=trunc(sysdate-2811);

    Thanks for the reply martin,I have tried below query still it goes for all partitions.Please refer to below Expalin Plan.
    select * from sales where trunc(time_id) between trunc(sysdate-2811) and trunc(sysdate-2810) -1/86400
    <PlanElement id="0" operation="SELECT STATEMENT" optimizer="ALL_ROWS" cost="42" cardinality="1" bytes="48" cpu_cost="1,321,416" io_cost="42" time="1">
    <PlanElements>
    <PlanElement id="1" operation="FILTER" qblock_name="SEL$1" filter_predicates="TRUNC(SYSDATE@!-2811)<=TRUNC(SYSDATE@!-2810)-.00001157407407407407407407407407407407407407">
    <PlanElements>
    <PlanElement id="2" operation="PARTITION RANGE" option="ALL" cost="42" cardinality="1" bytes="48" partition_id="2" partition_start="1" partition_stop="4" cpu_cost="1,321,416" io_cost="42" time="1">
    <PlanElements>
    <PlanElement object_ID="0" id="3" operation="TABLE ACCESS" option="FULL" object_owner="SONARDBO" object_name="SALES" object_type="TABLE" object_instance="1" cost="42" cardinality="1" bytes="48" partition_id="2" partition_start="1" partition_stop="4" cpu_cost="1,321,416" io_cost="42" qblock_name="SEL$1" filter_predicates="TRUNC(INTERNAL_FUNCTION("TIME_ID"))>=TRUNC(SYSDATE@!-2811) AND TRUNC(INTERNAL_FUNCTION("TIME_ID"))<=TRUNC(SYSDATE@!-2810)-.00001157407407407407407407407407407407407407" time="1" />

  • Interpret EXPLAIN PLAN TABLE OUTPUT

    Please point me to some document to understand on how to interpret this data, especially " OUTLINE DATA ".
    ORCL > explain plan for select * from hr.employees e, hr.departments d where e.department_id = d.department_id ;
    Explained.
    Elapsed: 00:00:00.11
    ORCL > select plan_table_output  from table (DBMS_XPLAN.DISPLAY(NULL, NULL, 'ADVANCED')) ;
    PLAN_TABLE_OUTPUT
    Plan hash value: 1343509718
    | Id  | Operation                    | Name        | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT             |             |   106 |  9540 |     6  (17)| 00:00:01 |
    |   1 |  MERGE JOIN                  |             |   106 |  9540 |     6  (17)| 00:00:01 |
    |   2 |   TABLE ACCESS BY INDEX ROWID| DEPARTMENTS |    27 |   567 |     2   (0)| 00:00:01 |
    |   3 |    INDEX FULL SCAN           | DEPT_ID_PK  |    27 |       |     1   (0)| 00:00:01 |
    |*  4 |   SORT JOIN                  |             |   107 |  7383 |     4  (25)| 00:00:01 |
    |   5 |    TABLE ACCESS FULL         | EMPLOYEES   |   107 |  7383 |     3   (0)| 00:00:01 |
    Query Block Name / Object Alias (identified by operation id):
       1 - SEL$1
       2 - SEL$1 / D@SEL$1
       3 - SEL$1 / D@SEL$1
       5 - SEL$1 / E@SEL$1
    Outline Data
      /*+
          BEGIN_OUTLINE_DATA
          USE_MERGE(@"SEL$1" "E"@"SEL$1")
          LEADING(@"SEL$1" "D"@"SEL$1" "E"@"SEL$1")
          FULL(@"SEL$1" "E"@"SEL$1")
          INDEX(@"SEL$1" "D"@"SEL$1" ("DEPARTMENTS"."DEPARTMENT_ID"))
          OUTLINE_LEAF(@"SEL$1")
          ALL_ROWS
          DB_VERSION('11.2.0.1')
          OPTIMIZER_FEATURES_ENABLE('11.2.0.1')
          IGNORE_OPTIM_EMBEDDED_HINTS
          END_OUTLINE_DATA
    Predicate Information (identified by operation id):
       4 - access("E"."DEPARTMENT_ID"="D"."DEPARTMENT_ID")
           filter("E"."DEPARTMENT_ID"="D"."DEPARTMENT_ID")
    Column Projection Information (identified by operation id):
       1 - (#keys=0) "D"."DEPARTMENT_ID"[NUMBER,22], "E"."DEPARTMENT_ID"[NUMBER,22],
           "D"."LOCATION_ID"[NUMBER,22], "D"."DEPARTMENT_NAME"[VARCHAR2,30],
           "D"."MANAGER_ID"[NUMBER,22], "E"."EMPLOYEE_ID"[NUMBER,22],
           "E"."FIRST_NAME"[VARCHAR2,20], "E"."LAST_NAME"[VARCHAR2,25],
           "E"."EMAIL"[VARCHAR2,25], "E"."PHONE_NUMBER"[VARCHAR2,20], "E"."HIRE_DATE"[DATE,7],
           "E"."JOB_ID"[VARCHAR2,10], "E"."SALARY"[NUMBER,22],
           "E"."COMMISSION_PCT"[NUMBER,22], "E"."MANAGER_ID"[NUMBER,22]
       2 - "D"."DEPARTMENT_ID"[NUMBER,22], "D"."DEPARTMENT_NAME"[VARCHAR2,30],
           "D"."MANAGER_ID"[NUMBER,22], "D"."LOCATION_ID"[NUMBER,22]
       3 - "D".ROWID[ROWID,10], "D"."DEPARTMENT_ID"[NUMBER,22]
       4 - (#keys=1) "E"."DEPARTMENT_ID"[NUMBER,22], "E"."EMPLOYEE_ID"[NUMBER,22],
           "E"."FIRST_NAME"[VARCHAR2,20], "E"."LAST_NAME"[VARCHAR2,25],
           "E"."EMAIL"[VARCHAR2,25], "E"."PHONE_NUMBER"[VARCHAR2,20], "E"."HIRE_DATE"[DATE,7],
           "E"."JOB_ID"[VARCHAR2,10], "E"."SALARY"[NUMBER,22],
           "E"."COMMISSION_PCT"[NUMBER,22], "E"."MANAGER_ID"[NUMBER,22]
       5 - "E"."EMPLOYEE_ID"[NUMBER,22], "E"."FIRST_NAME"[VARCHAR2,20],
           "E"."LAST_NAME"[VARCHAR2,25], "E"."EMAIL"[VARCHAR2,25],
           "E"."PHONE_NUMBER"[VARCHAR2,20], "E"."HIRE_DATE"[DATE,7],
           "E"."JOB_ID"[VARCHAR2,10], "E"."SALARY"[NUMBER,22],
           "E"."COMMISSION_PCT"[NUMBER,22], "E"."MANAGER_ID"[NUMBER,22],
           "E"."DEPARTMENT_ID"[NUMBER,22]
    68 rows selected.
    /

    "outline data" are a set of hints that enforce the use of the given plan.
    The best source on interpreting plans (I know) is: http://antognini.ch/papers/InterpretingExecutionPlans_20091017.pdf
    Regards
    Martin

  • About  EXPLAIN PLAN table

    Hi,
    This is just a sample query which I have executed on a recently installed Oracle ..
    SQL> explain plan for
    2 select * from emp
    3 where job = 'CLERK';
    select * from emp
    ERROR at line 2:
    ORA-02402: PLAN_TABLE not found
    When I have requested my DBA, he said, he couldnt find this (PLAN TABLE) utility in oracle .. Please advice me, from where can I get this utility ?? And how to proceed
    Regards

    SQL> explain plan for select sysdate from dual
      2  /
    Explained.
    SQL>  select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    | Id  | Operation            |  Name       | Rows  | Bytes | Cost  |
    |   0 | SELECT STATEMENT     |             |       |       |       |
    |   1 |  TABLE ACCESS FULL   | DUAL        |       |       |       |
    Note: rule based optimization
    9 rows selected.Cheers
    Sarma.

  • 10g Explain Plan ?

    First off I am mostly an end user, just write queries and execute them, I have done very little administration under Oracel databases, besides the 10g Express edition, I have never installed anything else form oracle.
    My company recently upgraded from 9i to 10g, and I am noticing that the cost is almost double vs. the old 9i db, using the same exact query and I am also noticing some new things in the explain plan. I use TOAD for my connection to the database at work and to view Explain plans.
    Here is one of the explain plans: I wanted to learn what some of this new terminology means, like what is: (I've replaced the real schemas with the word schema, and tables with Table).
    What is PX ?
    PX COORDINATOR ?
    Plan
    CREATE TABLE STATEMENT ALL_ROWSCost: 15,471 Bytes: 126,893,988 Cardinality: 2,440,269                                              
         9 LOAD AS SELECT Schema.Table
              8 PX COORDINATOR                                    
                   7 PX SEND QC (RANDOM) SYS.:TQ10001 Cost: 15,339 Bytes: 126,893,988 Cardinality: 2,440,269                               
                        6 SORT GROUP BY Cost: 15,339 Bytes: 126,893,988 Cardinality: 2,440,269                          
                             5 PX RECEIVE Cost: 15,339 Bytes: 126,893,988 Cardinality: 2,440,269                     
                                  4 PX SEND HASH SYS.:TQ10000 Cost: 15,339 Bytes: 126,893,988 Cardinality: 2,440,269                
                                       3 SORT GROUP BY Cost: 15,339 Bytes: 126,893,988 Cardinality: 2,440,269           
                                            2 PX BLOCK ITERATOR Cost: 15,331 Bytes: 126,893,988 Cardinality: 2,440,269 Partition #: 8 Partitions accessed #1 - #16     
                                                 1 TABLE ACCESS FULL TABLE schema.Table2 Cost: 15,331 Bytes: 126,893,988 Cardinality: 2,440,269 Partition #: 8 Partitions accessed #1 - #16

    PX = Parallel eXecution: query is executed on multiple processors. This may result from parameter changes and/or new defaults.
    Using Parallel Execution, one session (your original session) coordinates the various extra processes.
    Sybrand Bakker
    Senior Oracle DBA

Maybe you are looking for

  • After creating successor to a custom IDOC?

    Hello We have a custom IDOC type (for sales orders) in the system. Now business want to pass additional data, as per this requirement am trying to add a new custom segment to this custom IDOC, but am getting the below error, ZORDR03 has already been

  • How to read the param in an URL with an applet???

    I will like to read the in an URL with an applet param (after the ?) I need the equivalent of: String parm1 = request.getParameter("param"); but for applet I think the HttpServletResponse doesn't work in an applet ??? Tell me if I'am right Thanks for

  • Creation of New Custom Development Object in Solar02

    Hi, We are trying to create an object type of Form for a new custom development object in solar02 under tab Development,and for this I get an error that the object doesn't exist in development environment.  Based on my analysis, it looks like Solutio

  • Error: invalid drive E

    i don't know the first thing about computers but when it says i have an invalid drive E what does that mean?

  • How do i convert my music to high res?

    I need to change my music in my library from 128 kpbs AAC encoder to the highest sound quality, can anyone tell what the highest sound quality is and how to covert all my music to that setting?