Statistics_level = ALL

On 10.2.0.3:
I have this delete statement. It takes 40 seconds to execute 1500 times with statistics_level parameter set to ALL.
Compared to 4 seconds with statistics_level parameter set to TYPICAL.
Here is a tkprof report with statistics_level = TYPICAL:
call count cpu elapsed disk query current rows
Parse 0 0.00 0.00 0 0 0 0
Execute 1500 4.33 4.23 20 57852 1570 500
Fetch 0 0.00 0.00 0 0 0 0
total 1500 4.33 4.23 20 57852 1570 500
Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 109 (DBFRONT) (recursive depth: 1)
Rows Execution Plan
0 DELETE STATEMENT MODE: ALL_ROWS
0 DELETE OF 'SONG_LIST_JUK_DETAIL'
0 HASH JOIN (ANTI)
0 INDEX MODE: ANALYZED (RANGE SCAN) OF
'SONG_LIST_JUK_DETAIL_PK' (INDEX (UNIQUE))
0 INDEX MODE: ANALYZED (RANGE SCAN) OF
'IDX_JUK_HD_SONG_HDIDSONID' (INDEX (UNIQUE))
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
db file sequential read 20 0.00 0.00
BWT, how do i edit this thread so my tkprof report be readable to you?
And here is my tkprof report with statistics_level = ALL:
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1500 40.64 40.01 35 41741 2607 1467
Fetch 0 0.00 0.00 0 0 0 0
total 1501 40.64 40.01 35 41741 2607 1467
Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 109 (DBFRONT) (recursive depth: 1)
Rows Execution Plan
0 DELETE STATEMENT MODE: ALL_ROWS
0 DELETE OF 'SONG_LIST_JUK_DETAIL'
0 HASH JOIN (ANTI)
0 INDEX MODE: ANALYZED (RANGE SCAN) OF
'SONG_LIST_JUK_DETAIL_PK' (INDEX (UNIQUE))
0 INDEX MODE: ANALYZED (RANGE SCAN) OF
'IDX_JUK_HD_SONG_HDIDSONID' (INDEX (UNIQUE))
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
db file sequential read 35 0.04 0.08
Same plan is used in both cases. I notice the following:
both have INDEX MODE: ANALYZED (RANGE SCAN) OF.
I cannot find documentation regarding INDEX MODE: ANALYZED (RANGE SCAN) OF.
Does anyone has a link that points to this?
Why does it says "mode:analyzed"
Anyone has an explication? Like the optimizer does more work when statistics_level = ALL , and thats why it took more time to execute. Should i have run something in the dbms_stats package on top of using statistics_level = ALL?
Here is the script for my stats gathering for my table:
execute dbms_stats.gather_table_stats(ownname=> USER, tabname=> 'SONG_LIST_JUK_DETAIL' , estimate_percent=> DBMS_STATS.AUTO_SAMPLE_SIZE, cascade=> DBMS_STATS.AUTO_CASCADE, degree=> null, no_invalidate=> DBMS_STATS.AUTO_INVALIDATE,granularity=> 'AUTO',method_opt=> 'FOR ALL COLUMNS SIZE AUTO');
Should that ive run the stats differently so the query run fast with statistics_level set to ALL?

With statistics_level = ALL, Oracle will have to do a little more, so a slight increase in cpu time is expected, but not like you are showing here.
However, before investigating this myself, I see you have some odd differences. When you take a closer look at the tkprof output, you see the first delete statement had actually deleted 500 rows, while the second was deleting 1467 rows. So it looks like your delete statements cannot be compared.
Also the number of rows is missing from the row source operation. Are you sure you properly disconnected your traced session to make sure all cursors were closed?
> BWT, how do i edit this thread so my tkprof report be readable to you?
Just click the edit icon next to the reply icon and add the tags [pre] and [/pre] around the code and tkprof output.
Regards,
Rob.

Similar Messages

  • HOW TO: Post a SQL statement tuning request - template posting

    This post is not a question, but similar to Rob van Wijk's "When your query takes too long ..." post should help to improve the quality of the requests for SQL statement tuning here on OTN.
    On the OTN forum very often tuning requests about single SQL statements are posted, but the information provided is rather limited, and therefore it's not that simple to provide a meaningful advice. Instead of writing the same requests for additional information over and over again I thought I put together a post that describes how a "useful" post for such a request should look like and what information it should cover.
    I've also prepared very detailed step-by-step instructions how to obtain that information on my blog, which can be used to easily gather the required information. It also covers again the details how to post the information properly here, in particular how to use the \ tag to preserve formatting and get a fixed font output:
    http://oracle-randolf.blogspot.com/2009/02/basic-sql-statement-performance.html
    So again: This post here describes how a "useful" post should look like and what information it ideally covers. The blog post explains in detail how to obtain that information.
    In the future, rather than requesting the same additional information and explaining how to obtain it, I'll simply refer to this HOW TO post and the corresponding blog post which describes in detail how to get that information.
    *Very important:*
    Use the \ tag to enclose any output that should have its formatting preserved as shown below.
    So if you want to use fixed font formatting that preserves the spaces etc., do the following:
    \   This preserves formatting
    \And it will look like this:
       This preserves formatting
       . . .Your post should cover the following information:
    1. The SQL and a short description of its purpose
    2. The version of your database with 4-digits (e.g. 10.2.0.4)
    3. Optimizer related parameters
    4. The TIMING and AUTOTRACE output
    5. The EXPLAIN PLAN output
    6. The TKPROF output snippet that corresponds to your statement
    7. If you're on 10g or later, the DBMS_XPLAN.DISPLAY_CURSOR output
    The above mentioned blog post describes in detail how to obtain that information.
    Your post should have a meaningful subject, e.g. "SQL statement tuning request", and the message body should look similar to the following:
    *-- Start of template body --*
    The following SQL statement has been identified to perform poorly. It currently takes up to 10 seconds to execute, but it's supposed to take a second at most.
    This is the statement:
    select
    from
             t_demo
    where
             type = 'VIEW'
    order by
             id;It should return data from a table in a specific order.
    The version of the database is 11.1.0.7.
    These are the parameters relevant to the optimizer:
    SQL>
    SQL> show parameter optimizer
    NAME                                 TYPE        VALUE
    optimizer_capture_sql_plan_baselines boolean     FALSE
    optimizer_dynamic_sampling           integer     2
    optimizer_features_enable            string      11.1.0.7
    optimizer_index_caching              integer     0
    optimizer_index_cost_adj             integer     100
    optimizer_mode                       string      ALL_ROWS
    optimizer_secure_view_merging        boolean     TRUE
    optimizer_use_invisible_indexes      boolean     FALSE
    optimizer_use_pending_statistics     boolean     FALSE
    optimizer_use_sql_plan_baselines     boolean     TRUE
    SQL>
    SQL> show parameter db_file_multi
    NAME                                 TYPE        VALUE
    db_file_multiblock_read_count        integer     8
    SQL>
    SQL> show parameter db_block_size
    NAME                                 TYPE        VALUE
    db_block_size                        integer     8192
    SQL>
    SQL> show parameter cursor_sharing
    NAME                                 TYPE        VALUE
    cursor_sharing                       string      EXACT
    SQL>
    SQL> column sname format a20
    SQL> column pname format a20
    SQL> column pval2 format a20
    SQL>
    SQL> select
      2             sname
      3           , pname
      4           , pval1
      5           , pval2
      6  from
      7           sys.aux_stats$;
    SNAME                PNAME                     PVAL1 PVAL2
    SYSSTATS_INFO        STATUS                          COMPLETED
    SYSSTATS_INFO        DSTART                          01-30-2009 16:25
    SYSSTATS_INFO        DSTOP                           01-30-2009 16:25
    SYSSTATS_INFO        FLAGS                         0
    SYSSTATS_MAIN        CPUSPEEDNW              494,397
    SYSSTATS_MAIN        IOSEEKTIM                    10
    SYSSTATS_MAIN        IOTFRSPEED                 4096
    SYSSTATS_MAIN        SREADTIM
    SYSSTATS_MAIN        MREADTIM
    SYSSTATS_MAIN        CPUSPEED
    SYSSTATS_MAIN        MBRC
    SYSSTATS_MAIN        MAXTHR
    SYSSTATS_MAIN        SLAVETHR
    13 rows selected.Here is the output of EXPLAIN PLAN:
    SQL> explain plan for
      2  -- put your statement here
      3  select
      4             *
      5  from
      6             t_demo
      7  where
      8             type = 'VIEW'
      9  order by
    10             id;
    Explained.
    Elapsed: 00:00:00.01
    SQL>
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 1390505571
    | Id  | Operation                   | Name     | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT            |          |     1 |    60 |     0   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS BY INDEX ROWID| T_DEMO   |     1 |    60 |     0   (0)| 00:00:01 |
    |*  2 |   INDEX RANGE SCAN          | IDX_DEMO |     1 |       |     0   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - access("TYPE"='VIEW')
    14 rows selected.Here is the output of SQL*Plus AUTOTRACE including the TIMING information:
    SQL> rem Set the ARRAYSIZE according to your application
    SQL> set autotrace traceonly arraysize 100
    SQL> select
      2             *
      3  from
      4             t_demo
      5  where
      6             type = 'VIEW'
      7  order by
      8             id;
    149938 rows selected.
    Elapsed: 00:00:02.21
    Execution Plan
    Plan hash value: 1390505571
    | Id  | Operation                   | Name     | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT            |          |     1 |    60 |     0   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS BY INDEX ROWID| T_DEMO   |     1 |    60 |     0   (0)| 00:00:01 |
    |*  2 |   INDEX RANGE SCAN          | IDX_DEMO |     1 |       |     0   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - access("TYPE"='VIEW')
    Statistics
              0  recursive calls
              0  db block gets
         149101  consistent gets
            800  physical reads
            196  redo size
        1077830  bytes sent via SQL*Net to client
          16905  bytes received via SQL*Net from client
           1501  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
         149938  rows processed
    SQL>
    SQL> disconnect
    Disconnected from Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing optionsThe TKPROF output for this statement looks like the following:
    TKPROF: Release 11.1.0.7.0 - Production on Mo Feb 23 10:23:08 2009
    Copyright (c) 1982, 2007, Oracle.  All rights reserved.
    Trace file: orcl11_ora_3376_mytrace1.trc
    Sort options: default
    count    = number of times OCI procedure was executed
    cpu      = cpu time in seconds executing
    elapsed  = elapsed time in seconds executing
    disk     = number of physical reads of buffers from disk
    query    = number of buffers gotten for consistent read
    current  = number of buffers gotten in current mode (usually for update)
    rows     = number of rows processed by the fetch or execute call
    select
    from
             t_demo
    where
             type = 'VIEW'
    order by
             id
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch     1501      0.53       1.36        800     149101          0      149938
    total     1503      0.53       1.36        800     149101          0      149938
    Misses in library cache during parse: 0
    Optimizer mode: ALL_ROWS
    Parsing user id: 88 
    Rows     Row Source Operation
    149938  TABLE ACCESS BY INDEX ROWID T_DEMO (cr=149101 pr=800 pw=0 time=60042 us cost=0 size=60 card=1)
    149938   INDEX RANGE SCAN IDX_DEMO (cr=1881 pr=1 pw=0 time=0 us cost=0 size=0 card=1)(object id 74895)
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      SQL*Net message to client                    1501        0.00          0.00
      db file sequential read                       800        0.05          0.80
      SQL*Net message from client                  1501        0.00          0.69
    ********************************************************************************The DBMS_XPLAN.DISPLAY_CURSOR output:
    SQL> -- put your statement here
    SQL> -- use the GATHER_PLAN_STATISTICS hint
    SQL> -- if you're not using STATISTICS_LEVEL = ALL
    SQL> select /*+ gather_plan_statistics */
      2  *
      3  from
      4  t_demo
      5  where
      6  type = 'VIEW'
      7  order by
      8  id;
    149938 rows selected.
    Elapsed: 00:00:02.21
    SQL>
    SQL> select * from table(dbms_xplan.display_cursor(null, null, 'ALLSTATS LAST'));
    PLAN_TABLE_OUTPUT
    SQL_ID  d4k5acu783vu8, child number 0
    select   /*+ gather_plan_statistics */          * from          t_demo
    where          type = 'VIEW' order by          id
    Plan hash value: 1390505571
    | Id  | Operation                   | Name     | Starts | E-Rows | A-Rows |   A-Time   | Buffers | Reads  |
    |   0 | SELECT STATEMENT            |          |      1 |        |    149K|00:00:00.02 |     149K|   1183 |
    |   1 |  TABLE ACCESS BY INDEX ROWID| T_DEMO   |      1 |      1 |    149K|00:00:00.02 |     149K|   1183 |
    |*  2 |   INDEX RANGE SCAN          | IDX_DEMO |      1 |      1 |    149K|00:00:00.02 |    1880 |    383 |
    Predicate Information (identified by operation id):
       2 - access("TYPE"='VIEW')
    20 rows selected.I'm looking forward for suggestions how to improve the performance of this statement.
    *-- End of template body --*
    I'm sure that if you follow these instructions and obtain the information described, post them using a proper formatting (don't forget about the \ tag) you'll receive meaningful advice very soon.
    So, just to make sure you didn't miss this point:Use proper formatting!
    If you think I missed something important in this sample post let me know so that I can improve it.
    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/                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Alex Nuijten wrote:
    ...you missed the proper formatting of the Autotrace section ;-)Alex,
    can't reproduce, does it still look unformatted? Or are you simply kidding? :-)
    Randolf
    PS: Just noticed that it actually sometimes doesn't show the proper formatting although the code tags are there. Changing to the \ tag helped in this case, but it seems to be odd.
    Edited by: Randolf Geist on Feb 23, 2009 11:28 AM
    Odd behaviour of forum software                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Two different plans in TEST & Prod

    hi,
    we have a problem in production database where we find some sql statements running very slow.
    but if you run same SQL statement in TEST it runs < 2 secs.
    Production DB Prod.SchemaA  is exported into TEST DB as Test.SchemaA
    When study the explain plan, we find Prod explain plan is different than test. if you create sql profile, by copying TEST explain plan, it would run faster in Production.
    Now our question is why optimizer goes through two different plans when the schema structure same and data almost same in two databases?
    Note that, we have two almost identical schema's in Production. Prod.SchemaA and Prod.SchemaB has same object names but some Prod.SchemaB may have small difference in indexes/constraints.
    Users would run same SQL statement both in Prod.SchemaA & Prod.SchemaB time to time.
    thanks
    neal

    You can have a clear picture about the accuracy of your statistics by getting the execution plan from memory into the TEST and PROD environment. You can proceed as follows
    PROD> alter session set statistics_level=ALL;
    PROD> execute your query;
    PROD> select * from table (dbms_xplan.display_cursor(null,null, 'ALLSTATS LAST'));
    TEST> alter session set statistics_level=ALL;
    TEST> execute your query
    TEST> select * from table (dbms_xplan.display_cursor(null,null, 'ALLSTATS LAST'));
    This will give an execution plan showing the estimations(E-Rows) done by the CBO and the Actual (A-Rows) rows generated allowing you to judge the accuracy of your statistics.
    The predicate part of the execution plan can also show inportant information.
    Best regards
    Mohamed Houri
    www.hourim.wordpress.com

  • How to measure the performance of sql query?

    Hi Experts,
    How to measure the performance, efficiency and cpu cost of a sql query?
    What are all the measures available for an sql query?
    How to identify i am writing optimal query?
    I am using Oracle 9i...
    It ll be useful for me to write efficient query....
    Thanks & Regards

    psram wrote:
    Hi Experts,
    How to measure the performance, efficiency and cpu cost of a sql query?
    What are all the measures available for an sql query?
    How to identify i am writing optimal query?
    I am using Oracle 9i... You might want to start with a feature of SQL*Plus: The AUTOTRACE (TRACEONLY) option which executes your statement, fetches all records (if there is something to fetch) and shows you some basic statistics information, which include the number of logical I/Os performed, number of sorts etc.
    This gives you an indication of the effectiveness of your statement, so that can check how many logical I/Os (and physical reads) had to be performed.
    Note however that there are more things to consider, as you've already mentioned: The CPU bit is not included in these statistics, and the work performed by SQL workareas (e.g. by hash joins) is also credited only very limited (number of sorts), but e.g. it doesn't cover any writes to temporary segments due to sort or hash operations spilling to disk etc.
    You can use the following approach to get a deeper understanding of the operations performed by each row source:
    alter session set statistics_level=all;
    alter session set timed_statistics = true;
    select /* findme */ ... <your query here>
    SELECT
             SUBSTR(LPAD(' ',DEPTH - 1)||OPERATION||' '||OBJECT_NAME,1,40) OPERATION,
             OBJECT_NAME,
             CARDINALITY,
             LAST_OUTPUT_ROWS,
             LAST_CR_BUFFER_GETS,
             LAST_DISK_READS,
             LAST_DISK_WRITES,
    FROM     V$SQL_PLAN_STATISTICS_ALL P,
             (SELECT *
              FROM   (SELECT   *
                      FROM     V$SQL
                      WHERE    SQL_TEXT LIKE '%findme%'
                               AND SQL_TEXT NOT LIKE '%V$SQL%'
                               AND PARSING_USER_ID = SYS_CONTEXT('USERENV','CURRENT_USERID')
                      ORDER BY LAST_LOAD_TIME DESC)
              WHERE  ROWNUM < 2) S
    WHERE    S.HASH_VALUE = P.HASH_VALUE
             AND S.CHILD_NUMBER = P.CHILD_NUMBER
    ORDER BY ID
    /Check the V$SQL_PLAN_STATISTICS_ALL view for more statistics available. In 10g there is a convenient function DBMS_XPLAN.DISPLAY_CURSOR which can show this information with a single call, but in 9i you need to do it yourself.
    Note that "statistics_level=all" adds a significant overhead to the processing, so use with care and only when required:
    http://jonathanlewis.wordpress.com/2007/11/25/gather_plan_statistics/
    http://jonathanlewis.wordpress.com/2007/04/26/heisenberg/
    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/

  • 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

  • Resource consumption details not shown for each row source operation

    Hi Friends,
    I have generated a tracefile for a query as shown below.
    set autotrace traceonly arraysize 100
    ALTER SESSION SET optimizer_mode = ALL_ROWS ;
    alter session set tracefile_identifier = 'trcwithtime_221010_03';
    alter session set events '10046 trace name context forever, level 12';
    spool on
    spool C:\Sree\trcwtime.log
    -- put your statement here
    SELECT e.*,d.dname
    FROM scott.emp e
        ,scott.dept d
    WHERE e.deptno = d.deptno;
    spool off;
    exitBelow is the trace file
    SELECT e.*,d.dname
    FROM scott.emp e
        ,scott.dept d
    WHERE e.deptno = d.deptno
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        2      0.00       0.00          4          7          0          14
    total        4      0.00       0.00          4          7          0          14
    Misses in library cache during parse: 0
    Optimizer goal: ALL_ROWS
    Parsing user id: 173 
    Rows     Row Source Operation
         14  HASH JOIN 
          4   TABLE ACCESS FULL DEPT
         14   TABLE ACCESS FULL EMP
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      SQL*Net message to client                       2        0.00          0.00
      db file sequential read                         4        0.00          0.00
      SQL*Net message from client                     2        0.41          0.77
    ********************************************************************************For each rowsource operation, resource consumption details (cr,pr,pw,time) are not shown in the TKPROF output.
    How can i get these details as well?
    DBVersion: 9.2.0.8
    Regards,
    Sreekanth Munagala

    Sreekanth Munagala wrote:
    For each rowsource operation, resource consumption details (cr,pr,pw,time) are not shown in the TKPROF output.
    How can i get these details as well?
    DBVersion: 9.2.0.8You can get those details by setting values for following parameters (at session level, preferably) before generating the 10046 trace.
    ALTER SESSION SET statistics_level = ALL ;
    ALTER SESSION SET timed_statistics = TRUE ;

  • Oem explain plan produced doesn't correspond to explain plan with tkprof

    Hello all,
    I am running OEM on a 10.2.0.3 database and I have a very slow query with cognos 8 BI on my data warehouse.
    I went to the dbconsole through OEM and connected to target database I went to look at the query execution and then got an explain plan.
    Then I did a trace file and ran it throught tkprof.
    When I look at both produced explain plan, I can see the tree looks the same exept the corresponding values. In OEM, it says I am going throug 18000 rows and in the tkprof result it says more like millions of records.
    As anybody had these kind of results?
    Shall I have more confidence in TKprof then OEM?
    It is very important to me since I am being chalanged by an external DBA.

    I would recommend you to get Christian Antogini´s book "Troublshooting Oracle Performance", (http://www.antognini.ch/top/) which explains everything you need to know when analyzing Oracle SQL Performance and Explain Plans.
    If you properly trace your SQL Statement, you will get "STAT" lines in the trace file. These stat lines show you the actual number of rows processed per row source operation. Explain plan per default does only show you the "estimated" row counts for the row source operations no matter whether you use "explain=" in the tkprof call or OEM to get the explain plan. Tkprof reads the STAT lines from the trace and outputs a section which is similar to an execution plan but contains the "real" number of rows.
    However, if you want to troubleshoot Oracle Performance, I would recommend you to run the statement with the hint /*+ GATHER_PLAN_STATISTICS */ or set statistics_level=ALL in your session (not database-wide!).
    If you do, you can get an excellent execution plan with DBMS_XPLAN.DISPLAY_CURSOR containing both estimated rows as well as actual rows combined with the "number of starts" for e.g. nested loop joins.
    Get the book, read it, and you will be able to discuss this issue with your external dba in a professional way. ;-)
    Regards,
    Martin
    www.ora-solutions.net

  • Ksvcreate: Process(q000) creation failed

    My 10.2.0.3 database is hosted on AIX 5.3 server LPAR.
    suddenly after refreshing the instance with production data i have started receiving the following errors and wornings. some time the database response is real slow.
    some sqls are also getting timed out.
    Please let me know if you have any previous experience with this type of problem.
    Completed checkpoint up to RBA [0x149.2.10], SCN: 9288805
    Mon Jun 16 14:46:14 2008
    WARNING: inbound connection timed out (ORA-3136)
    Mon Jun 16 17:27:58 2008
    ksvcreate: Process(q000) creation failed
    Mon Jun 16 17:29:38 2008
    Starting ORACLE instance (normal)
    Mon Jun 16 17:30:25 2008
    ksvcreate: Process(q000) creation failed
    Mon Jun 16 17:32:54 2008
    ksvcreate: Process(q000) creation failed
    Mon Jun 16 17:34:35 2008
    Starting ORACLE instance (normal)
    Mon Jun 16 17:35:19 2008
    ksvcreate: Process(q000) creation failed
    Mon Jun 16 17:37:46 2008
    ksvcreate: Process(q000) creation failed
    Mon Jun 16 17:40:13 2008
    ksvcreate: Process(q000) creation failed
    Mon Jun 16 17:42:11 2008
    WARNING: inbound connection timed out (ORA-3136)
    Mon Jun 16 17:42:12 2008

    processes     = 400
    number of active sessions were below 50 when i got the error.
    Here are my Init.ora parameters:
    db_name                         = DCFICN89
    control_files                    = ("/defddcg3/oracle/u01/oradata/DCFICN89/control01.ctl", "/defddcg3/oracle/u01/oradata/DCFICN89/control02.ctl", "/defddcg3/oracle/u01/oradata/DCFICN89/control03.ctl")
    db_files                    = 1024
    db_file_multiblock_read_count          = 8
    db_block_size                    = 8192
    sga_target                    = 2048M
    sga_max_size                    = 2048M
    control_file_record_keep_time          = 10
    cursor_space_for_time               = true
    log_checkpoints_to_alert          = true
    log_checkpoint_interval               = 102400
    log_checkpoint_timeout               = 0
    processes                    = 500
    parallel_max_servers               = 40
    log_buffer                    = 786432
    max_dump_file_size               = unlimited
    db_writer_processes               = 3
    job_queue_processes               = 1
    open_cursors                    = 500
    log_archive_dest               = "/defddcg3/oracle/backup/DCFICN89/archive/"
    log_archive_format               = "DCFICN89_%S_%t_%r.log"
    compatible                    = 10.2.0.3
    audit_file_dest                    = /defddcg3/apps/oracle/admin/DCFICN89/adump
    background_dump_dest               = /defddcg3/apps/oracle/admin/DCFICN89/bdump
    core_dump_dest                    = /defddcg3/apps/oracle/admin/DCFICN89/cdump
    user_dump_dest                    = /defddcg3/apps/oracle/admin/DCFICN89/udump
    undo_management                    = AUTO
    undo_tablespace                    = UNDO01
    undo_retention                    = 1800
    remote_login_passwordfile          = exclusive
    backup_tape_io_slaves               = false
    timed_statistics               = true
    # This can be "basic", "typical", or "all"
    statistics_level               = all
    #oracle_trace_enable               = true
    audit_trail                    = false
    session_cached_cursors               = 100
    #utl_file_dir                    = /oracle/backup/logminer
    noor_expansion               = true
    costequality_semi_join          = false
    #hash_join_enabled               = false
    timed_statistics               = true

  • Multiple calls to ad_parallel_updates_pkg.initialize_rowid_range

    Hello,
    Can I call ad_parallel_updates_pkg.initialize_rowid_range with 5 different tables in the same script as in the below script?
    ftp://bugftp.us.oracle.com/upload/bug_12/bug12928204/c1279530_final.sql
    When I'm trying to test the script and extract the trace, I could see the whole script listed as single statement in the trace (refer to trace ftp://bugftp.us.oracle.com/upload/bug_12/bug12928204/pr1yd220_ora_14104_skkoppul1.trc).
    I used following command to enable trace before running the script - where do you think I'm going wrong?
    alter session set tracefile_identifier='skkoppul2';
    alter session set events '10046 trace name context forever, level 8';
    alter session set statistics_level='ALL' ;
    alter session set max_dump_file_size= unlimited ;
    Any pointers are truly appreciated.
    Thanks - Srujan

    Srujan,
    I cannot access those files -- Not sure if it is my connection or the ftp server.
    If possible, upload the files to any free hosting website and post the link here.
    Thanks,
    Hussein

  • Different result comparing AWR to TKPROF

    Hi,
    I runned last night event 10046 on my database using the following commands:
    ALTER SYSTEM SET statistics_level = ALL;
    ALTER SYSTEM SET events '10046 trace name context forever, level 12';
    Today, i compared a single statment from TKPROF result to the AWR and found
    big different results:
    The TKPROF shows:
    Executions is : 1
    elpased time is :51.39 seconds
    cpu time is : 0.23 second
    Gets per Exec is : 72
    SELECT CM_CUST_DIM_INST_PROD.INST_PROD_ID, CM_CUST_DIM_INST_PROD.NAP_PRODUCT_ID, CM_CUST_DIM_INST_PROD.NAP_PACKEAGE, CM_CUST_DIM_INST_PROD.PRODUCT_ID, CM_CUST_DIM_INST_PROD.PRODUCT_DESCR, CM_CUST_DIM_INST_PROD.PRODUCT_GROUP, CM_CUST_DIM_INST_PROD.PRODUCT_GROUP_DESCR, CM_CUST_DIM_INST_PROD.PROD_CATEGORY, CM_CUST_DIM_INST_PROD.PROD_CATEGORY_DESCR, CM_CUST_DIM_INST_PROD.PROD_GRP_TYPE, CM_CUST_DIM_INST_PROD.PROD_GRP_TYPE_DESCR, CM_CUST_DIM_INST_PROD.NAP_AREA2, CM_CUST_DIM_INST_PROD.NAP_PHONE_NUM, CM_CUST_DIM_INST_PROD.NAP_CANCEL_DT, CM_CUST_DIM_INST_PROD.NAP_SERVICE_OPN_DT, CM_CUST_DIM_INST_PROD.NAP_MAKAT_CD, CM_CUST_DIM_INST_PROD.NAP_CRM_STATUS, CM_CUST_DIM_INST_PROD.NAP_CRM_STATUS_DESCR, CM_CUST_DIM_INST_PROD.NAP_RTRV_INSPRD_ID
    FROM CM_CUST_DIM_INST_PROD ,
    cm_ip_service_delta, cm_ip_service_delta cm_ip_service_delta2
    WHERE CM_CUST_DIM_INST_PROD.prod_grp_type in ('INTR', 'HOST') and
    CM_CUST_DIM_INST_PROD.Inst_Prod_Id = cm_ip_service_delta.inst_prod_id(+) and
    CM_CUST_DIM_INST_PROD.Nap_Makat_Cd = cm_ip_service_delta.nap_billing_catnum(+)
    and cm_ip_service_delta.nap_billing_catnum is null and
    cm_ip_service_delta.inst_prod_id is null
    and cm_ip_service_delta2.inst_prod_id = CM_CUST_DIM_INST_PROD.Nap_Packeage
    ORDER BY INST_PROD_ID
    call count cpu elapsed disk query current rows
    Parse 1 0.01 0.03 0 22 0 0
    Execute 1 0.02 1.79 0 32 0 0
    Fetch 13 0.19 49.56 0 18 0 661
    total 15 0.23 51.39 0 72 0 661
    The AWR report shows
    Executions is : 1
    elpased time is :697.91 seconds
    cpu time is :41.89 second
    Gets per Exec is : 351,105.00
    Executions Gets per Exec CPU Time (s) Elapsed Time (s) SQL Id SQL
    1 351,105.00 41.89 697.91 6hh4jdx9dvjzw
    6hh4jdx9dvjzw
    SELECT CM_CUST_DIM_INST_PROD.INST_PROD_ID, CM_CUST_DIM_INST_PROD.NAP_PRODUCT_ID, CM_CUST_DIM_INST_PROD.NAP_PACKEAGE, CM_CUST_DIM_INST_PROD.PRODUCT_ID, CM_CUST_DIM_INST_PROD.PRODUCT_DESCR, CM_CUST_DIM_INST_PROD.PRODUCT_GROUP, CM_CUST_DIM_INST_PROD.PRODUCT_GROUP_DESCR, CM_CUST_DIM_INST_PROD.PROD_CATEGORY, CM_CUST_DIM_INST_PROD.PROD_CATEGORY_DESCR, CM_CUST_DIM_INST_PROD.PROD_GRP_TYPE, CM_CUST_DIM_INST_PROD.PROD_GRP_TYPE_DESCR, CM_CUST_DIM_INST_PROD.NAP_AREA2, CM_CUST_DIM_INST_PROD.NAP_PHONE_NUM, CM_CUST_DIM_INST_PROD.NAP_CANCEL_DT, CM_CUST_DIM_INST_PROD.NAP_SERVICE_OPN_DT, CM_CUST_DIM_INST_PROD.NAP_MAKAT_CD, CM_CUST_DIM_INST_PROD.NAP_CRM_STATUS, CM_CUST_DIM_INST_PROD.NAP_CRM_STATUS_DESCR, CM_CUST_DIM_INST_PROD.NAP_RTRV_INSPRD_ID FROM CM_CUST_DIM_INST_PROD , cm_ip_service_delta, cm_ip_service_delta cm_ip_service_delta2 WHERE CM_CUST_DIM_INST_PROD.prod_grp_type in ('INTR', 'HOST') and CM_CUST_DIM_INST_PROD.Inst_Prod_Id = cm_ip_service_delta.inst_prod_id(+) and CM_CUST_DIM_INST_PROD.Nap_Makat_Cd = cm_ip_service_delta.nap_billing_catnum(+) and cm_ip_service_delta.nap_billing_catnum is null and cm_ip_service_delta.inst_prod_id is null and cm_ip_service_delta2.inst_prod_id = CM_CUST_DIM_INST_PROD.Nap_Packeage ORDER BY INST_PROD_ID
    Does one can explain the different results ?
    Thank You

    Hi Virag,
    I ran the statment from sqlplus and after that i generated an addm report:
    As you can see below TKPROF show that elspaed time was : 50.76 second,
    while ADDM show:
    "was executed 1 times and had an average elapsed time of 751 seconds."
    ALTER SESSION SET max_dump_file_size = unlimited;
    ALTER SESSION SET tracefile_identifier = '10046';
    ALTER SESSION SET statistics_level = ALL;
    ALTER SESSION SET events '10046 trace name context forever, level 12';
    SELECT CM_CUST_DIM_INST_PROD.INST_PROD_ID, CM_CUST_DIM_INST_PROD.NAP_PRODUCT_ID, CM_CUST_DIM_INST_PROD.NAP_PACKEAGE, CM_CUST_DIM_INST_PROD.PRODUCT_ID, CM_CUST_DIM_INST_PROD.PRODUCT_DESCR, CM_CUST_DIM_INST_PROD.PRODUCT_GROUP, CM_CUST_DIM_INST_PROD.PRODUCT_GROUP_DESCR, CM_CUST_DIM_INST_PROD.PROD_CATEGORY, CM_CUST_DIM_INST_PROD.PROD_CATEGORY_DESCR, CM_CUST_DIM_INST_PROD.PROD_GRP_TYPE, CM_CUST_DIM_INST_PROD.PROD_GRP_TYPE_DESCR, CM_CUST_DIM_INST_PROD.NAP_AREA2, CM_CUST_DIM_INST_PROD.NAP_PHONE_NUM, CM_CUST_DIM_INST_PROD.NAP_CANCEL_DT, CM_CUST_DIM_INST_PROD.NAP_SERVICE_OPN_DT, CM_CUST_DIM_INST_PROD.NAP_MAKAT_CD, CM_CUST_DIM_INST_PROD.NAP_CRM_STATUS, CM_CUST_DIM_INST_PROD.NAP_CRM_STATUS_DESCR, CM_CUST_DIM_INST_PROD.NAP_RTRV_INSPRD_ID
    FROM CM_CUST_DIM_INST_PROD ,
    cm_ip_service_delta, cm_ip_service_delta cm_ip_service_delta2
    WHERE CM_CUST_DIM_INST_PROD.prod_grp_type in ('INTR', 'HOST') and
    CM_CUST_DIM_INST_PROD.Inst_Prod_Id = cm_ip_service_delta.inst_prod_id(+) and
    CM_CUST_DIM_INST_PROD.Nap_Makat_Cd = cm_ip_service_delta.nap_billing_catnum(+)
    and cm_ip_service_delta.nap_billing_catnum is null and
    cm_ip_service_delta.inst_prod_id is null
    and cm_ip_service_delta2.inst_prod_id = CM_CUST_DIM_INST_PROD.Nap_Packeage
    ORDER BY INST_PROD_ID
    ALTER SESSION SET EVENTS '10046 trace name context off';
    EXIT
    call count cpu elapsed disk query current rows
    Parse 1 0.05 0.05 0 0 0 0
    Execute 1 0.02 1.96 24 32 0 0
    Fetch 46 0.19 48.74 6 18 0 661
    total 48 0.26 50.76 30 50 0 661
    Rows Row Source Operation
    661 PX COORDINATOR (cr=50 pr=30 pw=0 time=50699289 us)
    0 PX SEND QC (ORDER) :TQ10003 (cr=0 pr=0 pw=0 time=0 us)
    0 SORT ORDER BY (cr=0 pr=0 pw=0 time=0 us)
    0 PX RECEIVE (cr=0 pr=0 pw=0 time=0 us)
    0 PX SEND RANGE :TQ10002 (cr=0 pr=0 pw=0 time=0 us)
    0 FILTER (cr=0 pr=0 pw=0 time=0 us)
    0 HASH JOIN RIGHT OUTER (cr=0 pr=0 pw=0 time=0 us)
    0 BUFFER SORT (cr=0 pr=0 pw=0 time=0 us)
    0 PX RECEIVE (cr=0 pr=0 pw=0 time=0 us)
    0 PX SEND BROADCAST :TQ10000 (cr=0 pr=0 pw=0 time=0 us)
    3366 INDEX FAST FULL SCAN IDX_CM_SERVICE_DELTA (cr=9 pr=6 pw=0 time=47132 us)(object id 1547887)
    0 HASH JOIN (cr=0 pr=0 pw=0 time=0 us)
    0 BUFFER SORT (cr=0 pr=0 pw=0 time=0 us)
    0 PX RECEIVE (cr=0 pr=0 pw=0 time=0 us)
    0 PX SEND BROADCAST :TQ10001 (cr=0 pr=0 pw=0 time=0 us)
    3366 INDEX FAST FULL SCAN IDX_CM_SERVICE_DELTA (cr=9 pr=0 pw=0 time=20340 us)(object id 1547887)
    0 PX BLOCK ITERATOR PARTITION: 1 4 (cr=0 pr=0 pw=0 time=0 us)
    0 TABLE ACCESS FULL CM_CUST_DIM_INST_PROD PARTITION: 1 4 (cr=0 pr=0 pw=0 time=0 us)
    RECOMMENDATION 1: SQL Tuning, 56% benefit (615 seconds)
    ACTION: Run SQL Tuning Advisor on the SQL statement with SQL_ID
    "6wd7sw8adqaxv".
    RELEVANT OBJECT: SQL statement with SQL_ID 6wd7sw8adqaxv and
    PLAN_HASH 2594021963
    SELECT CM_CUST_DIM_INST_PROD.INST_PROD_ID,
    CM_CUST_DIM_INST_PROD.NAP_PRODUCT_ID,
    CM_CUST_DIM_INST_PROD.NAP_PACKEAGE, CM_CUST_DIM_INST_PROD.PRODUCT_ID,
    CM_CUST_DIM_INST_PROD.PRODUCT_DESCR,
    CM_CUST_DIM_INST_PROD.PRODUCT_GROUP,
    CM_CUST_DIM_INST_PROD.PRODUCT_GROUP_DESCR,
    CM_CUST_DIM_INST_PROD.PROD_CATEGORY,
    CM_CUST_DIM_INST_PROD.PROD_CATEGORY_DESCR,
    CM_CUST_DIM_INST_PROD.PROD_GRP_TYPE,
    CM_CUST_DIM_INST_PROD.PROD_GRP_TYPE_DESCR,
    CM_CUST_DIM_INST_PROD.NAP_AREA2, CM_CUST_DIM_INST_PROD.NAP_PHONE_NUM,
    CM_CUST_DIM_INST_PROD.NAP_CANCEL_DT,
    CM_CUST_DIM_INST_PROD.NAP_SERVICE_OPN_DT,
    CM_CUST_DIM_INST_PROD.NAP_MAKAT_CD,
    CM_CUST_DIM_INST_PROD.NAP_CRM_STATUS,
    CM_CUST_DIM_INST_PROD.NAP_CRM_STATUS_DESCR,
    CM_CUST_DIM_INST_PROD.NAP_RTRV_INSPRD_ID
    FROM CM_CUST_DIM_INST_PROD ,
    cm_ip_service_delta, cm_ip_service_delta cm_ip_service_delta2
    WHERE CM_CUST_DIM_INST_PROD.prod_grp_type in ('INTR', 'HOST') and
    CM_CUST_DIM_INST_PROD.Inst_Prod_Id =
    cm_ip_service_delta.inst_prod_id(+) and
    CM_CUST_DIM_INST_PROD.Nap_Makat_Cd =
    cm_ip_service_delta.nap_billing_catnum(+)
    and cm_ip_service_delta.nap_billing_catnum is null and
    cm_ip_service_delta.inst_prod_id is null
    and cm_ip_service_delta2.inst_prod_id =
    CM_CUST_DIM_INST_PROD.Nap_Packeage
    ORDER BY INST_PROD_ID
    RATIONALE: SQL statement with SQL_ID "6wd7sw8adqaxv" was executed 1
    times and had an average elapsed time of 751 seconds.
    RATIONALE: At least one execution of the statement ran in parallel.
    Thanks.

  • Query execution is faster - as SYS user vs. application user in 11.1.07

    In +11.1.0.7+ database, we have noticed execution of an application process as SYS user is faster than the application user. To quantify this execution time was 2 hours as application user and same process when executed as SYS user completed in 1 hour.
    We ran tracing for this process and tkprof output showed follwoing:
    OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS:
    _call          count      cpu       elapsed disk query current rows_
    Execute 3705586 2440.49 *4294.54* 293602 21835223 23300886 3801288 <<< ==== SYS
    Execute 3703285 6356.69 *8576.50* 303175 21785419 23378086 3801291 <<< ==== Application user
    We have SR open with Oracle, but thought if some one knows about this issue would be great.
    Edited by: dhyani on Aug 17, 2010 3:16 PM

    What about the "Predicate Information" section of the execution plans - were those exactly the same? Did you use AUTOTRACE, EXPLAIN PLAN FOR, or the method that I showed to retrieve the execution plans? Where the SQL_ID and CHILD_NUMBERS displayed exactly the same? Is the STATISTIC_LEVEL set to TYPICAL for both sessions? You can check the setting in SQL*Plus like this:
    SQL> SHOW PARAMETER STATISTICS_LEVEL
    NAME                                 TYPE        VALUE
    statistics_level                     string      typicalAs a demonstration, I will change the value at the session level and then change the setting back:
    SQL> ALTER SESSION SET STATISTICS_LEVEL='ALL';
    SQL> SHOW PARAMETER STATISTICS_LEVEL
    NAME                                 TYPE        VALUE
    statistics_level                     string      ALL
    SQL> ALTER SESSION SET STATISTICS_LEVEL='TYPICAL';If the above does not show a difference, you will need to capture a 10046 trace at either level 8 or level 12 for both sessions and compare the wait events and the STAT lines in the 10046 trace to see where the additional time is being spent. Reference these two blog articles for the 10046 trace:
    http://hoopercharles.wordpress.com/2009/12/01/10046-extended-sql-trace-interpretation/
    http://hoopercharles.wordpress.com/2010/01/26/10046-extended-sql-trace-interpretation-2/
    Keep in mind that the goal is to not change anything until we understand the problem better. Maybe, just maybe, someone created a table (or view) or two in the SYS schema (or used a table/view name that matched a SYS owned object), in a normal user's schema, or there are synonyms pointing to different tables. So, it probably would be a good idea to verify that the results are exactly the same when the SYS user executes the SQL statement and a normal user executes the SQL statement.
    Charles Hooper
    Co-author of "Expert Oracle Practices: Oracle Database Administration from the Oak Table"
    http://hoopercharles.wordpress.com/
    IT Manager/Oracle DBA
    K&M Machine-Fabricating, Inc.

  • One database user taking more time to connect

    Hi All,
    I have a question,
    I have a database say 500GB and I have around 50 schemas in this database.But there is one User that takes more than normal time to connect to the database.
    What can be the reason for this and what should be my apprach to look for the problem where it could possibly be.
    Regards,
    Sphinx

    yes, check for online trigger if none there put your own on logon trigger on a normal user and your issue user. do a 10046, examine the trace files, everything the user is doing will be in it.
    CREATE OR REPLACE TRIGGER SYS.set_trace
    AFTER LOGON ON DATABASE
    WHEN (USER in 'GOODUSER','BADUSER')
    DECLARE
    lcommand varchar(200);
    BEGIN
    EXECUTE IMMEDIATE 'alter session set statistics_level=ALL';
    EXECUTE IMMEDIATE 'alter session set max_dump_file_size=UNLIMITED';
    EXECUTE IMMEDIATE 'alter session set events ''10046 trace name context forever, level 12''';
    END set_trace;
    /tkprof the trace files, whats the difference between good and bad.
    moneys on a trigger though.

  • Explain plan is not visible for a Spatial Query

    Hi Everybody
    I'm traying to optimze an spatial query, So for that I'm trying to get the explain plan but its seems I can't get it, Somebady can tell me whay?
    This is my query by the way
    SELECT /*+ ORDERED */ TELEMATICS_PARK_SUMMARY.TELEMATICS_UNIT_ID, TELEMATICS_PARK_SUMMARY.TRIP_START_DATE_TIME,
    TELEMATICS_PARK_SUMMARY.CORP_CODE, TELEMATICS_PARK_SUMMARY.FLEET_NUMBER, TELEMATICS_PARK_SUMMARY.LEVEL2_CODE,
    TELEMATICS_PARK_SUMMARY.LEVEL3_CODE, TELEMATICS_PARK_SUMMARY.LEVEL4_CODE, TELEMATICS_PARK_SUMMARY.LEVEL5_CODE,
    TELEMATICS_PARK_SUMMARY.LEVEL6_CODE, TELEMATICS_PARK_SUMMARY.LEVEL_NUMBER, TELEMATICS_PARK_SUMMARY.PARKING_NUMBER,
    STRUCTURE_POI.STRUCTURE_POI_ID, STRUCTURE_POI.CORP_CODE, STRUCTURE_POI.FLEET_NUMBER, STRUCTURE_POI.LEVEL2_CODE,
    STRUCTURE_POI.LEVEL3_CODE, STRUCTURE_POI.LEVEL4_CODE, STRUCTURE_POI.LEVEL5_CODE, STRUCTURE_POI.LEVEL6_CODE,
    STRUCTURE_POI.LEVEL_NUMBER, STRUCTURE_POI.EFFECTIVE_START_DATE, STRUCTURE_POI.EFFECTIVE_END_DATE, STRUCTURE_POI.IS_FLEET_POI_SW
    FROM
    STRUCTURE_POI, TELEMATICS_PARK_SUMMARY WHERE
    (SDO_WITHIN_DISTANCE(TELEMATICS_PARK_SUMMARY.SHAPE, STRUCTURE_POI.SHAPE, 'distance='||TO_CHAR(180*STRUCTURE_POI.GEO_FENCE_BUFFER_DIST/(6378137*3.14159265)))) = 'TRUE'
    Regards
    Jesus Gutierrez

    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

  • Hash group by improvement

    I see that one of my queries from an application time is spending most of its time in the hash group by. I'm running Oracle 11g with a quarter rack exadata appliance. Is there a better way to run or design this table?
    query:
    SELECT COUNT(*)
    FROM (
            SELECT "DDTMDAY", "MRKTNM", "BSMNM", "BSCNM", "CLNM", "CSCDNM", "BTSID", "SECTSEQID", "BNDID", "FAID", SUM("VATTCNT"), SUM("VMBLORGCNT"), SUM("VMBLTERCNT"), SUM("VSILENTRETRYCNT"), SUM("VCUSTBLKCNT"), SUM("VAXSFCNT"), SUM("VCEBLKCNT"), SUM("VWCDBLKCNT"), SUM("VT1BHLBLKCNT"), SUM("VPWRBLKCNT"), SUM("VNONBTSEQBLKCNT"), SUM("VSFULCALLCNT"), SUM("VDRPCALLCNT"), SUM("DATTCNT"), SUM("DMBLORGCNT"), SUM("DMBLTERCNT"), SUM("DSILENTRETRYCNT"), SUM("DCUSTBLKCNT"), SUM("DAXSFCNT"), SUM("DCEBLKCNT"), SUM("DWCDBLKCNT"), SUM("DT1BHLBLKCNT"), SUM("DPWRBLKCNT"), SUM("DNONBTSEQBLKCNT"), SUM("DSFULCALLCNT"), SUM("DDRPCALLCNT"), SUM("VPRIMCALLERL"), SUM("VMOUTMS"), SUM("DPRIMCALLERL"), SUM("SMSATTCNT"), SUM("SMSSXSCNT"), SUM("VHHIATTCNT"), SUM("VHHIBADFRMCNT"), SUM("VHHICALLSETUPSXSCNT"), SUM("DHHIATTCNT"), SUM("DHHIBADFRMCNT"), SUM("DHHICALLSETUPSXSCNT") FROM (SELECT
       trunc(D1."D_DTM", 'dd') AS "DDTMDAY",
       D2."MRKT_NM" AS "MRKTNM",
       D3."BSC_NM" AS "BSMNM",
       D3."BSC_NM" AS "BSCNM",
       D2."CLUSTER_NM" AS "CLNM",
       D1."CSCD_NM" AS "CSCDNM",
       D1."BTS_ID" AS "BTSID",
       D1."SECT_SEQ_ID" AS "SECTSEQID",
       D1."BND_ID" AS "BNDID",
       D1."FA_ID" AS "FAID",
       D1."V_ATT_CNT" AS "VATTCNT",
       D1."V_MBL_ORG_CNT" AS "VMBLORGCNT",
       D1."V_MBL_TER_CNT" AS "VMBLTERCNT",
       D1."V_SILENT_RETRY_CNT" AS "VSILENTRETRYCNT",
       D1."V_CUST_BLK_CNT" AS "VCUSTBLKCNT",
       D1."V_AXS_F_CNT" AS "VAXSFCNT",
       D1."V_CE_BLK_CNT" AS "VCEBLKCNT",
       D1."V_WCD_BLK_CNT" AS "VWCDBLKCNT",
       D1."V_T1_BHL_BLK_CNT" AS "VT1BHLBLKCNT",
       D1."V_PWR_BLK_CNT" AS "VPWRBLKCNT",
       D1."V_NON_BTS_EQ_BLK_CNT" AS "VNONBTSEQBLKCNT",
       D1."V_SFUL_CALL_CNT" AS "VSFULCALLCNT",
       D1."V_DRP_CALL_CNT" AS "VDRPCALLCNT",
       D1."D_ATT_CNT" AS "DATTCNT",
       D1."D_MBL_ORG_CNT" AS "DMBLORGCNT",
       D1."D_MBL_TER_CNT" AS "DMBLTERCNT",
       D1."D_SILENT_RETRY_CNT" AS "DSILENTRETRYCNT",
       D1."D_CUST_BLK_CNT" AS "DCUSTBLKCNT",
       D1."D_AXS_F_CNT" AS "DAXSFCNT",
       D1."D_CE_BLK_CNT" AS "DCEBLKCNT",
       D1."D_WCD_BLK_CNT" AS "DWCDBLKCNT",
       D1."D_T1_BHL_BLK_CNT" AS "DT1BHLBLKCNT",
       D1."D_PWR_BLK_CNT" AS "DPWRBLKCNT",
       D1."D_NON_BTS_EQ_BLK_CNT" AS "DNONBTSEQBLKCNT",
       D1."D_SFUL_CALL_CNT" AS "DSFULCALLCNT",
       D1."D_DRP_CALL_CNT" AS "DDRPCALLCNT",
       D1."V_PRIM_CALL_ERL" AS "VPRIMCALLERL",
       D1."V_MOU_TMS" AS "VMOUTMS",
       D1."D_PRIM_CALL_ERL" AS "DPRIMCALLERL",
       D1."SMS_ATT_CNT" AS "SMSATTCNT",
       D1."SMS_SXS_CNT" AS "SMSSXSCNT",
       D1."V_HHI_ATT_CNT" AS "VHHIATTCNT",
       D1."V_HHI_BAD_FRM_CNT" AS "VHHIBADFRMCNT",
       D1."V_HHI_CALL_SETUP_SXS_CNT" AS "VHHICALLSETUPSXSCNT",
       D1."D_HHI_ATT_CNT" AS "DHHIATTCNT",
       D1."D_HHI_BAD_FRM_CNT" AS "DHHIBADFRMCNT",
       D1."D_HHI_CALL_SETUP_SXS_CNT" AS "DHHICALLSETUPSXSCNT"
    FROM
       "DMSN"."DS3R_FH_1XRTT_FA_LVL_KPI_TEMP" D1
    LEFT OUTER JOIN "DMSN"."SITES_GEO_HIERARCHY" D2
    ON
    D1."BTS_ID" = D2."BTS_ID"
    AND
    D1."CSCD_NM" = D2."CSCD_NM"
    LEFT OUTER JOIN "DMSN"."SITES_SYS_HIERARCHY" D3
    ON
    D1."BTS_ID" = D3."BTS_ID"
    AND
    D1."CSCD_NM" = D3."CSCD_NM"
    WHERE
    trunc(D1."D_DTM", 'dd') >= SYSDATE - 40 and  trunc(D1."D_DTM", 'dd') < SYSDATE - 1
    ) T GROUP BY "DDTMDAY", "MRKTNM", "BSMNM", "BSCNM", "CLNM", "CSCDNM", "BTSID", "SECTSEQID", "BNDID", "FAID" ORDER BY "DDTMDAY", "MRKTNM", "BSMNM", "BSCNM", "CLNM", "CSCDNM", "BTSID", "SECTSEQID", "BNDID", "FAID"      
    Explain plan
    SQL> alter session set statistics_level = all
      2
    SQL> @C:\TEST.SQL
      COUNT(*)
       1101270
    SQL> SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY_CURSOR);
    PLAN_TABLE_OUTPUT
    SQL_ID  gqj9q831g6s78, child number 0
    SELECT COUNT(*) FROM (         SELECT "DDTMDAY", "MRKTNM", "BSMNM",
    "BSCNM", "CLNM", "CSCDNM", "BTSID", "SECTSEQID", "BNDID", "FAID",
    SUM("VATTCNT"), SUM("VMBLORGCNT"), SUM("VMBLTERCNT"),
    SUM("VSILENTRETRYCNT"), SUM("VCUSTBLKCNT"), SUM("VAXSFCNT"),
    SUM("VCEBLKCNT"), SUM("VWCDBLKCNT"), SUM("VT1BHLBLKCNT"),
    SUM("VPWRBLKCNT"), SUM("VNONBTSEQBLKCNT"), SUM("VSFULCALLCNT"),
    SUM("VDRPCALLCNT"), SUM("DATTCNT"), SUM("DMBLORGCNT"),
    SUM("DMBLTERCNT"), SUM("DSILENTRETRYCNT"), SUM("DCUSTBLKCNT"),
    SUM("DAXSFCNT"), SUM("DCEBLKCNT"), SUM("DWCDBLKCNT"),
    PLAN_TABLE_OUTPUT
    SUM("DT1BHLBLKCNT"), SUM("DPWRBLKCNT"), SUM("DNONBTSEQBLKCNT"),
    SUM("DSFULCALLCNT"), SUM("DDRPCALLCNT"), SUM("VPRIMCALLERL"),
    SUM("VMOUTMS"), SUM("DPRIMCALLERL"), SUM("SMSATTCNT"),
    SUM("SMSSXSCNT"), SUM("VHHIATTCNT"), SUM("VHHIBADFRMCNT"),
    SUM("VHHICALLSETUPSXSCNT"), SUM("DHHIATTCNT"), SUM("DHHIBADFRMCNT"),
    SUM("DHHICALLSETUPSXSCNT") FROM (SELECT    trunc(D1."D_DTM", 'dd') AS
    "DDTMDAY",    D2."MRKT_NM" AS "MRKTNM",    D3."BSC_NM" AS "BSMNM",
    D3."BSC_
    Plan hash value: 1618890056
    PLAN_TABLE_OUTPUT
    | Id  | Operation                               | Name
    | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     | Pstart| Pstop |    TQ  |IN-OUT
    | PQ Distrib |
    PLAN_TABLE_OUTPUT
    |   0 | SELECT STATEMENT                        |
    |       |       |       |   139K(100)|          |       |       |        |
    |            |
    |   1 |  SORT AGGREGATE                         |
    |     1 |       |       |            |          |       |       |        |
    |            |
    |*  2 |   PX COORDINATOR                        |
    |       |       |       |            |          |       |       |        |
    PLAN_TABLE_OUTPUT
    |            |
    |   3 |    PX SEND QC (RANDOM)                  | :TQ10003
    |     1 |       |       |            |          |       |       |  Q1,03 | P->S
    | QC (RAND)  |
    |   4 |     SORT AGGREGATE                      |
    |     1 |       |       |            |          |       |       |  Q1,03 | PCWP
    |            |
    |   5 |      VIEW                               |
    PLAN_TABLE_OUTPUT
    |    44M|       |       |   139K  (1)| 00:27:51 |       |       |  Q1,03 | PCWP
    |            |
    |   6 |       HASH GROUP BY                     |
    |    44M|    10G|    11G|   139K  (1)| 00:27:51 |       |       |  Q1,03 | PCWP
    |            |
    |   7 |        PX RECEIVE                       |
    |    44M|    10G|       | 34102   (1)| 00:06:50 |       |       |  Q1,03 | PCWP
    |            |
    PLAN_TABLE_OUTPUT
    |   8 |         PX SEND HASH                    | :TQ10002
    |    44M|    10G|       | 34102   (1)| 00:06:50 |       |       |  Q1,02 | P->P
    | HASH       |
    |*  9 |          FILTER                         |
    |       |       |       |            |          |       |       |  Q1,02 | PCWC
    |            |
    |* 10 |           HASH JOIN RIGHT OUTER         |
    |    44M|    10G|       | 34102   (1)| 00:06:50 |       |       |  Q1,02 | PCWP
    |            |
    PLAN_TABLE_OUTPUT
    |  11 |            BUFFER SORT                  |
    |       |       |       |            |          |       |       |  Q1,02 | PCWC
    |            |
    |  12 |             PX RECEIVE                  |
    | 13410 |   261K|       |    15   (0)| 00:00:01 |       |       |  Q1,02 | PCWP
    |            |
    |  13 |              PX SEND BROADCAST          | :TQ10000
    | 13410 |   261K|       |    15   (0)| 00:00:01 |       |       |        | S->P
    PLAN_TABLE_OUTPUT
    | BROADCAST  |
    |  14 |               TABLE ACCESS STORAGE FULL | SITES_SYS_HIERARCHY
    | 13410 |   261K|       |    15   (0)| 00:00:01 |       |       |        |
    |            |
    |* 15 |            HASH JOIN RIGHT OUTER        |
    |    44M|    10G|       | 34082   (1)| 00:06:49 |       |       |  Q1,02 | PCWP
    |            |
    |  16 |             BUFFER SORT                 |
    PLAN_TABLE_OUTPUT
    |       |       |       |            |          |       |       |  Q1,02 | PCWC
    |            |
    |  17 |              PX RECEIVE                 |
    | 13410 |   667K|       |    34   (0)| 00:00:01 |       |       |  Q1,02 | PCWP
    |            |
    |  18 |               PX SEND BROADCAST         | :TQ10001
    | 13410 |   667K|       |    34   (0)| 00:00:01 |       |       |        | S->P
    | BROADCAST  |
    PLAN_TABLE_OUTPUT
    |  19 |                TABLE ACCESS STORAGE FULL| SITES_GEO_HIERARCHY
    | 13410 |   667K|       |    34   (0)| 00:00:01 |       |       |        |
    |            |
    |  20 |             PX BLOCK ITERATOR           |
    |    44M|  8193M|       | 34042   (1)| 00:06:49 |     1 |1048575|  Q1,02 | PCWC
    |            |
    |* 21 |              TABLE ACCESS STORAGE FULL  | DS3R_FH_1XRTT_FA_LVL_KPI_TEMP
    |    44M|  8193M|       | 34042   (1)| 00:06:49 |     1 |1048575|  Q1,02 | PCWP
    |            |
    PLAN_TABLE_OUTPUT
    Predicate Information (identified by operation id):
       2 - filter(SYSDATE@!-40<SYSDATE@!-1)
       9 - filter(SYSDATE@!-40<SYSDATE@!-1)
    PLAN_TABLE_OUTPUT
      10 - access("D1"."CSCD_NM"="D3"."CSCD_NM" AND "D1"."BTS_ID"=TO_NUMBER("D3"."BT
    S_ID"))
      15 - access("D1"."CSCD_NM"="D2"."CSCD_NM" AND "D1"."BTS_ID"=TO_NUMBER("D2"."BT
    S_ID"))
      21 - storage(:Z>=:Z AND :Z<=:Z AND (TRUNC(INTERNAL_FUNCTION("D1"."D_DTM"),'fmd
    d')>=SYSDATE@!-40 AND TRUNC(INTERNAL_FUNCTION("D1"."D_DTM"),'fmdd')<SYSDATE@!-1)
           filter((TRUNC(INTERNAL_FUNCTION("D1"."D_DTM"),'fmdd')>=SYSDATE@!-40 AND T
    PLAN_TABLE_OUTPUT
    RUNC(INTERNAL_FUNCTION("D1"."D_DTM"),'fmdd')<SYSDATE@!-1))
    Note
       - dynamic sampling used for this statement (level=6)
    63 rows selected.
    Create table:
    CREATE TABLE DMSN.DS3R_FH_1XRTT_FA_LVL_KPI_TEMP
      D_DTM                     DATE                NOT NULL,
      F_ID                      NUMBER              NOT NULL,
      REG_DTM                   DATE,
      MRKT_ID                   NUMBER              NOT NULL,
      MRKT_NM                   VARCHAR2(150 BYTE),
      CL_ID                     NUMBER              NOT NULL,
      CL_NM                     VARCHAR2(150 BYTE),
      BSM_ID                    NUMBER              NOT NULL,
      BSM_NM                    VARCHAR2(150 BYTE),
      BSC_SEQ_ID                NUMBER              NOT NULL,
      CSCD_ID                   NUMBER              NOT NULL,
      CSCD_NM                   VARCHAR2(150 BYTE),
      BTS_ID                    NUMBER              NOT NULL,
      SECT_SEQ_ID               NUMBER              NOT NULL,
      BND_ID                    NUMBER              NOT NULL,
      FA_ID                     NUMBER              NOT NULL,
      V_ATT_CNT                 NUMBER,
      V_MBL_ORG_CNT             NUMBER,
      V_MBL_TER_CNT             NUMBER,
      V_SILENT_RETRY_CNT        NUMBER,
      V_CUST_BLK_CNT            NUMBER,
      V_AXS_F_CNT               NUMBER,
      V_CE_BLK_CNT              NUMBER,
      V_WCD_BLK_CNT             NUMBER,
      V_T1_BHL_BLK_CNT          NUMBER,
      V_PWR_BLK_CNT             NUMBER,
      V_NON_BTS_EQ_BLK_CNT      NUMBER,
      V_SFUL_CALL_CNT           NUMBER,
      V_DRP_CALL_CNT            NUMBER,
      D_ATT_CNT                 NUMBER,
      D_MBL_ORG_CNT             NUMBER,
      D_MBL_TER_CNT             NUMBER,
      D_SILENT_RETRY_CNT        NUMBER,
      D_CUST_BLK_CNT            NUMBER,
      D_AXS_F_CNT               NUMBER,
      D_CE_BLK_CNT              NUMBER,
      D_WCD_BLK_CNT             NUMBER,
      D_T1_BHL_BLK_CNT          NUMBER,
      D_PWR_BLK_CNT             NUMBER,
      D_NON_BTS_EQ_BLK_CNT      NUMBER,
      D_SFUL_CALL_CNT           NUMBER,
      D_DRP_CALL_CNT            NUMBER,
      V_PRIM_CALL_ERL           NUMBER,
      V_MOU_TMS                 NUMBER,
      D_PRIM_CALL_ERL           NUMBER,
      SMS_ATT_CNT               NUMBER,
      SMS_SXS_CNT               NUMBER,
      V_HHI_BAD_FRM_CNT         NUMBER,
      V_HHI_CALL_SETUP_SXS_CNT  NUMBER,
      V_HHI_ATT_CNT             NUMBER,
      D_HHI_BAD_FRM_CNT         NUMBER,
      D_HHI_CALL_SETUP_SXS_CNT  NUMBER,
      D_HHI_ATT_CNT             NUMBER,
      BSC_ALTR_ID               VARCHAR2(5 BYTE),
      V_BZ_HH_FLAG              NUMBER(1),
      D_BZ_HH_FLAG              NUMBER(1),
      V_BNCN_BZ_HH_FLAG         NUMBER(1),
      D_BNCN_BZ_HH_FLAG         NUMBER(1),
      V_PRIM_CALL_ERL_N         NUMBER,
      V_MOU_TMS_N               NUMBER
    COMPRESS FOR QUERY LOW
    TABLESPACE DMD_SN_01
    RESULT_CACHE (MODE DEFAULT)
    PCTUSED    0
    PCTFREE    0
    INITRANS   1
    MAXTRANS   255
    STORAGE    (
                PCTINCREASE      5
                BUFFER_POOL      DEFAULT
                FLASH_CACHE      DEFAULT
                CELL_FLASH_CACHE DEFAULT
    PARTITION BY RANGE (D_DTM)
    INTERVAL( NUMTODSINTERVAL(1,'DAY'))
      PARTITION P_1 VALUES LESS THAN (TO_DATE(' 2013-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
        LOGGING
        COMPRESS FOR QUERY LOW
        TABLESPACE DMD_SN_01
        PCTFREE    0
        INITRANS   1
        MAXTRANS   255
        STORAGE    (
                    BUFFER_POOL      DEFAULT
                    FLASH_CACHE      DEFAULT
                    CELL_FLASH_CACHE DEFAULT
      PARTITION VALUES LESS THAN (TO_DATE(' 2013-01-28 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
        LOGGING
        COMPRESS FOR QUERY LOW
        TABLESPACE DMD_SN_01
        PCTFREE    0
        INITRANS   1
        MAXTRANS   255
        STORAGE    (
                    INITIAL          8M
                    NEXT             1M
                    MINEXTENTS       1
                    MAXEXTENTS       UNLIMITED
                    BUFFER_POOL      DEFAULT
                    FLASH_CACHE      DEFAULT
                    CELL_FLASH_CACHE DEFAULT
      PARTITION VALUES LESS THAN (TO_DATE(' 2013-01-29 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
        LOGGING
        COMPRESS FOR QUERY LOW
        TABLESPACE DMD_SN_01
        PCTFREE    0
        INITRANS   1
        MAXTRANS   255
        STORAGE    (
                    INITIAL          8M
                    NEXT             1M
                    MINEXTENTS       1
                    MAXEXTENTS       UNLIMITED
                    BUFFER_POOL      DEFAULT
                    FLASH_CACHE      DEFAULT
                    CELL_FLASH_CACHE DEFAULT
    etc...
    NOCACHE
    PARALLEL ( DEGREE DEFAULT INSTANCES DEFAULT )
    MONITORING;
    CREATE INDEX DMSN.XIF1DS3R_FH_1XRTT_FA_LVL_TEMP ON DMSN.DS3R_FH_1XRTT_FA_LVL_KPI_TEMP
    (BTS_ID, CSCD_NM)
      PCTFREE    10
      INITRANS   2
      MAXTRANS   255
      STORAGE    (
                  BUFFER_POOL      DEFAULT
                  FLASH_CACHE      DEFAULT
                  CELL_FLASH_CACHE DEFAULT
    LOCAL (
      PARTITION P_1
        LOGGING
        NOCOMPRESS
        TABLESPACE DMD_SN_01
        PCTFREE    10
        INITRANS   2
        MAXTRANS   255
        STORAGE    (
                    BUFFER_POOL      DEFAULT
      PARTITION
        LOGGING
        NOCOMPRESS
        TABLESPACE DMD_SN_01
        PCTFREE    10
        INITRANS   2
        MAXTRANS   255
        STORAGE    (
                    INITIAL          64K
                    NEXT             1M
                    MINEXTENTS       1
                    MAXEXTENTS       UNLIMITED
                    BUFFER_POOL      DEFAULT
      PARTITION
        LOGGING
        NOCOMPRESS
        TABLESPACE DMD_SN_01
        PCTFREE    10
        INITRANS   2
        MAXTRANS   255
        STORAGE    (
                    INITIAL          64K
                    NEXT             1M
                    MINEXTENTS       1
                    MAXEXTENTS       UNLIMITED
                    BUFFER_POOL      DEFAULT
    etc....
    NOPARALLEL
    Also, in the v$sql_workarea session, the memory stats seem pretty high...
    ADDRESS
    HASH_VALUE
    SQL_ID
    CHILD_NUMBER
    WORKAREA_ADDRESS
    OPERATION_TYPE
    OPERATION_ID
    POLICY
    ESTIMATED_OPTIMAL_SIZE
    ESTIMATED_ONEPASS_SIZE
    LAST_MEMORY_USED
    LAST_EXECUTION
    LAST_DEGREE
    TOTAL_EXECUTIONS
    OPTIMAL_EXECUTIONS
    ONEPASS_EXECUTIONS
    MULTIPASSES_EXECUTIONS
    ACTIVE_TIME
    MAX_TEMPSEG_SIZE
    LAST_TEMPSEG_SIZE
    000000046CC73120
    3270729960
    gqj9q831g6s78
    0
    000000041C6CE108
    GROUP BY (HASH)
    6
    AUTO
    1175704576
    29911040
    50704384
    OPTIMAL
    24
    189
    189
    0
    0
    13324368
    000000046CC73120
    3270729960
    gqj9q831g6s78
    0
    000000041C6CE0A0
    HASH-JOIN
    10
    AUTO
    15517696
    2760704
    1811456
    OPTIMAL
    24
    192
    192
    0
    0
    20231391
    000000046CC73120
    3270729960
    gqj9q831g6s78
    0
    000000041C6CE038
    HASH-JOIN
    15
    AUTO
    26851328
    4585472
    1797120
    OPTIMAL
    24
    192
    192
    0
    0
    20197157
    000000046CC73120
    3270729960
    gqj9q831g6s78
    0
    000000041C6CDFD0
    BUFFER
    16
    AUTO
    1214464
    580608
    1079296
    OPTIMAL
    1
    192
    192
    0
    0
    20358402
    000000046CC73120
    3270729960
    gqj9q831g6s78
    0
    000000041C6CDF68
    BUFFER
    11
    AUTO
    779264
    510976
    692224
    OPTIMAL
    1
    192
    192
    0
    0
    20396407

    So I may have spoken too soon. I ran the test against the partitioned tabled, and then ran it against the original, which is just indexed and the times weren't that different.
    xPlan with Paritioning:
    SQL> SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY_CURSOR);
    PLAN_TABLE_OUTPUT
    SQL_ID  0vtpb0zuf3suj, child number 0
    SELECT COUNT(*) FROM (         SELECT "DDTMDAY", "MRKTNM", "BSMNM",
    "BSCNM", "CLNM", "CSCDNM", "BTSID", "SECTSEQID", "BNDID", "FAID",
    SUM("VATTCNT"), SUM("VMBLORGCNT"), SUM("VMBLTERCNT"),
    SUM("VSILENTRETRYCNT"), SUM("VCUSTBLKCNT"), SUM("VAXSFCNT"),
    SUM("VCEBLKCNT"), SUM("VWCDBLKCNT"), SUM("VT1BHLBLKCNT"),
    SUM("VPWRBLKCNT"), SUM("VNONBTSEQBLKCNT"), SUM("VSFULCALLCNT"),
    SUM("VDRPCALLCNT"), SUM("DATTCNT"), SUM("DMBLORGCNT"),
    SUM("DMBLTERCNT"), SUM("DSILENTRETRYCNT"), SUM("DCUSTBLKCNT"),
    SUM("DAXSFCNT"), SUM("DCEBLKCNT"), SUM("DWCDBLKCNT"),
    PLAN_TABLE_OUTPUT
    SUM("DT1BHLBLKCNT"), SUM("DPWRBLKCNT"), SUM("DNONBTSEQBLKCNT"),
    SUM("DSFULCALLCNT"), SUM("DDRPCALLCNT"), SUM("VPRIMCALLERL"),
    SUM("VMOUTMS"), SUM("DPRIMCALLERL"), SUM("SMSATTCNT"),
    SUM("SMSSXSCNT"), SUM("VHHIATTCNT"), SUM("VHHIBADFRMCNT"),
    SUM("VHHICALLSETUPSXSCNT"), SUM("DHHIATTCNT"), SUM("DHHIBADFRMCNT"),
    SUM("DHHICALLSETUPSXSCNT") FROM (SELECT    trunc(D1."D_DTM", 'dd') AS
    "DDTMDAY",    D2."MRKT_NM" AS "MRKTNM",    D3."BSC_NM" AS "BSMNM",
    D3."BSC_
    Plan hash value: 2810106464
    PLAN_TABLE_OUTPUT
    | Id  | Operation                               | Name
    | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     | Pstart| Pstop |    TQ  |IN-OUT
    | PQ Distrib |
    PLAN_TABLE_OUTPUT
    |   0 | SELECT STATEMENT                        |
    |       |       |       | 75444 (100)|          |       |       |        |
    |            |
    |   1 |  SORT AGGREGATE                         |
    |     1 |       |       |            |          |       |       |        |
    |            |
    |*  2 |   PX COORDINATOR                        |
    |       |       |       |            |          |       |       |        |
    PLAN_TABLE_OUTPUT
    |            |
    |   3 |    PX SEND QC (RANDOM)                  | :TQ10003
    |     1 |       |       |            |          |       |       |  Q1,03 | P->S
    | QC (RAND)  |
    |   4 |     SORT AGGREGATE                      |
    |     1 |       |       |            |          |       |       |  Q1,03 | PCWP
    |            |
    |   5 |      VIEW                               |
    PLAN_TABLE_OUTPUT
    |    17M|       |       | 75444   (1)| 00:15:06 |       |       |  Q1,03 | PCWP
    |            |
    |   6 |       HASH GROUP BY                     |
    |    17M|  4409M|  4682M| 75444   (1)| 00:15:06 |       |       |  Q1,03 | PCWP
    |            |
    |   7 |        PX RECEIVE                       |
    |    17M|  4409M|       | 33988   (1)| 00:06:48 |       |       |  Q1,03 | PCWP
    |            |
    PLAN_TABLE_OUTPUT
    |   8 |         PX SEND HASH                    | :TQ10002
    |    17M|  4409M|       | 33988   (1)| 00:06:48 |       |       |  Q1,02 | P->P
    | HASH       |
    |*  9 |          FILTER                         |
    |       |       |       |            |          |       |       |  Q1,02 | PCWC
    |            |
    |* 10 |           HASH JOIN RIGHT OUTER         |
    |    17M|  4409M|       | 33988   (1)| 00:06:48 |       |       |  Q1,02 | PCWP
    |            |
    PLAN_TABLE_OUTPUT
    |  11 |            BUFFER SORT                  |
    |       |       |       |            |          |       |       |  Q1,02 | PCWC
    |            |
    |  12 |             PX RECEIVE                  |
    | 13410 |   261K|       |    15   (0)| 00:00:01 |       |       |  Q1,02 | PCWP
    |            |
    |  13 |              PX SEND BROADCAST          | :TQ10000
    | 13410 |   261K|       |    15   (0)| 00:00:01 |       |       |        | S->P
    PLAN_TABLE_OUTPUT
    | BROADCAST  |
    |  14 |               TABLE ACCESS STORAGE FULL | SITES_SYS_HIERARCHY
    | 13410 |   261K|       |    15   (0)| 00:00:01 |       |       |        |
    |            |
    |* 15 |            HASH JOIN RIGHT OUTER        |
    |    17M|  4077M|       | 33971   (1)| 00:06:48 |       |       |  Q1,02 | PCWP
    |            |
    |  16 |             BUFFER SORT                 |
    PLAN_TABLE_OUTPUT
    |       |       |       |            |          |       |       |  Q1,02 | PCWC
    |            |
    |  17 |              PX RECEIVE                 |
    | 13410 |   667K|       |    34   (0)| 00:00:01 |       |       |  Q1,02 | PCWP
    |            |
    |  18 |               PX SEND BROADCAST         | :TQ10001
    | 13410 |   667K|       |    34   (0)| 00:00:01 |       |       |        | S->P
    | BROADCAST  |
    PLAN_TABLE_OUTPUT
    |  19 |                TABLE ACCESS STORAGE FULL| SITES_GEO_HIERARCHY
    | 13410 |   667K|       |    34   (0)| 00:00:01 |       |       |        |
    |            |
    |  20 |             PX BLOCK ITERATOR           |
    |    17M|  3232M|       | 33934   (1)| 00:06:48 |   KEY |   KEY |  Q1,02 | PCWC
    |            |
    |* 21 |              TABLE ACCESS STORAGE FULL  | DS3R_FH_1XRTT_FA_LVL_KPI_TEMP
    |    17M|  3232M|       | 33934   (1)| 00:06:48 |   KEY |   KEY |  Q1,02 | PCWP
    |            |
    PLAN_TABLE_OUTPUT
    Predicate Information (identified by operation id):
       2 - filter(SYSDATE@!-40<SYSDATE@!)
       9 - filter(SYSDATE@!-40<SYSDATE@!)
    PLAN_TABLE_OUTPUT
      10 - access("D1"."CSCD_NM"="D3"."CSCD_NM" AND "D1"."BTS_ID"=TO_NUMBER("D3"."BT
    S_ID"))
      15 - access("D1"."CSCD_NM"="D2"."CSCD_NM" AND "D1"."BTS_ID"=TO_NUMBER("D2"."BT
    S_ID"))
      21 - storage(:Z>=:Z AND :Z<=:Z AND ("D1"."D_DTM">=SYSDATE@!-40 AND "D1"."D_DTM
    "<SYSDATE@!))
           filter(("D1"."D_DTM">=SYSDATE@!-40 AND "D1"."D_DTM"<SYSDATE@!))
    59 rows selected.
    XPLAN NON PARTIONED BUT INDEXED TABLE
    SQL> @C:\TEST.SQL
      COUNT(*)
       1158056
    SQL> SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY_CURSOR);
    PLAN_TABLE_OUTPUT
    SQL_ID  5527bmds6pfmq, child number 0
    SELECT COUNT(*) FROM (         SELECT "DDTMDAY", "MRKTNM", "BSMNM",
    "BSCNM", "CLNM", "CSCDNM", "BTSID", "SECTSEQID", "BNDID", "FAID",
    SUM("VATTCNT"), SUM("VMBLORGCNT"), SUM("VMBLTERCNT"),
    SUM("VSILENTRETRYCNT"), SUM("VCUSTBLKCNT"), SUM("VAXSFCNT"),
    SUM("VCEBLKCNT"), SUM("VWCDBLKCNT"), SUM("VT1BHLBLKCNT"),
    SUM("VPWRBLKCNT"), SUM("VNONBTSEQBLKCNT"), SUM("VSFULCALLCNT"),
    SUM("VDRPCALLCNT"), SUM("DATTCNT"), SUM("DMBLORGCNT"),
    SUM("DMBLTERCNT"), SUM("DSILENTRETRYCNT"), SUM("DCUSTBLKCNT"),
    SUM("DAXSFCNT"), SUM("DCEBLKCNT"), SUM("DWCDBLKCNT"),
    PLAN_TABLE_OUTPUT
    SUM("DT1BHLBLKCNT"), SUM("DPWRBLKCNT"), SUM("DNONBTSEQBLKCNT"),
    SUM("DSFULCALLCNT"), SUM("DDRPCALLCNT"), SUM("VPRIMCALLERL"),
    SUM("VMOUTMS"), SUM("DPRIMCALLERL"), SUM("SMSATTCNT"),
    SUM("SMSSXSCNT"), SUM("VHHIATTCNT"), SUM("VHHIBADFRMCNT"),
    SUM("VHHICALLSETUPSXSCNT"), SUM("DHHIATTCNT"), SUM("DHHIBADFRMCNT"),
    SUM("DHHICALLSETUPSXSCNT") FROM (SELECT    trunc(D1."D_DTM", 'dd') AS
    "DDTMDAY",    D2."MRKT_NM" AS "MRKTNM",    D3."BSC_NM" AS "BSMNM",
    D3."BSC_
    Plan hash value: 3388800334
    PLAN_TABLE_OUTPUT
    | Id  | Operation                               | Name                     | Row
    s  | Bytes |TempSpc| Cost (%CPU)| Time     |    TQ  |IN-OUT| PQ Distrib |
    |   0 | SELECT STATEMENT                        |                          |
       |       |       | 77843 (100)|          |        |      |            |
    PLAN_TABLE_OUTPUT
    |   1 |  SORT AGGREGATE                         |                          |
    1 |       |       |            |          |        |      |            |
    |*  2 |   PX COORDINATOR                        |                          |
       |       |       |            |          |        |      |            |
    |   3 |    PX SEND QC (RANDOM)                  | :TQ10003                 |
    1 |       |       |            |          |  Q1,03 | P->S | QC (RAND)  |
    |   4 |     SORT AGGREGATE                      |                          |
    PLAN_TABLE_OUTPUT
    1 |       |       |            |          |  Q1,03 | PCWP |            |
    |   5 |      VIEW                               |                          |
    13M|       |       | 77843   (1)| 00:15:35 |  Q1,03 | PCWP |            |
    |   6 |       HASH GROUP BY                     |                          |
    13M|  3523M|  3762M| 77843   (1)| 00:15:35 |  Q1,03 | PCWP |            |
    |   7 |        PX RECEIVE                       |                          |
    13M|  3523M|       | 28163   (1)| 00:05:38 |  Q1,03 | PCWP |            |
    PLAN_TABLE_OUTPUT
    |   8 |         PX SEND HASH                    | :TQ10002                 |
    13M|  3523M|       | 28163   (1)| 00:05:38 |  Q1,02 | P->P | HASH       |
    |*  9 |          FILTER                         |                          |
       |       |       |            |          |  Q1,02 | PCWC |            |
    |* 10 |           HASH JOIN RIGHT OUTER         |                          |
    13M|  3523M|       | 28163   (1)| 00:05:38 |  Q1,02 | PCWP |            |
    |  11 |            BUFFER SORT                  |                          |
       |       |       |            |          |  Q1,02 | PCWC |            |
    PLAN_TABLE_OUTPUT
    |  12 |             PX RECEIVE                  |                          | 134
    10 |   261K|       |    15   (0)| 00:00:01 |  Q1,02 | PCWP |            |
    |  13 |              PX SEND BROADCAST          | :TQ10000                 | 134
    10 |   261K|       |    15   (0)| 00:00:01 |        | S->P | BROADCAST  |
    |  14 |               TABLE ACCESS STORAGE FULL | SITES_SYS_HIERARCHY      | 134
    10 |   261K|       |    15   (0)| 00:00:01 |        |      |            |
    |* 15 |            HASH JOIN RIGHT OUTER        |                          |
    PLAN_TABLE_OUTPUT
    13M|  3266M|       | 28145   (1)| 00:05:38 |  Q1,02 | PCWP |            |
    |  16 |             BUFFER SORT                 |                          |
       |       |       |            |          |  Q1,02 | PCWC |            |
    |  17 |              PX RECEIVE                 |                          | 134
    10 |   667K|       |    34   (0)| 00:00:01 |  Q1,02 | PCWP |            |
    |  18 |               PX SEND BROADCAST         | :TQ10001                 | 134
    10 |   667K|       |    34   (0)| 00:00:01 |        | S->P | BROADCAST  |
    PLAN_TABLE_OUTPUT
    |  19 |                TABLE ACCESS STORAGE FULL| SITES_GEO_HIERARCHY      | 134
    10 |   667K|       |    34   (0)| 00:00:01 |        |      |            |
    |  20 |             PX BLOCK ITERATOR           |                          |
    13M|  2610M|       | 28109   (1)| 00:05:38 |  Q1,02 | PCWC |            |
    |* 21 |              TABLE ACCESS STORAGE FULL  | DS3R_FH_1XRTT_FA_LVL_KPI |
    13M|  2610M|       | 28109   (1)| 00:05:38 |  Q1,02 | PCWP |            |
    PLAN_TABLE_OUTPUT
    Predicate Information (identified by operation id):
       2 - filter(SYSDATE@!-40<SYSDATE@!)
       9 - filter(SYSDATE@!-40<SYSDATE@!)
      10 - access("D1"."CSCD_NM"="D3"."CSCD_NM" AND "D1"."BTS_ID"=TO_NUMBER("D3"."BT
    S_ID"))
      15 - access("D1"."CSCD_NM"="D2"."CSCD_NM" AND "D1"."BTS_ID"=TO_NUMBER("D2"."BT
    PLAN_TABLE_OUTPUT
    S_ID"))
      21 - storage(:Z>=:Z AND :Z<=:Z AND ("D1"."D_DTM">=SYSDATE@!-40 AND "D1"."D_DTM
    "<SYSDATE@!))
           filter(("D1"."D_DTM">=SYSDATE@!-40 AND "D1"."D_DTM"<SYSDATE@!))
    59 rows selected.
    SQL>

  • "Rows" statistics from STAT in trace event 10046, Oracle 11g.

    Hi, all!
    Why "Rows" statistics in STAT are different for 10g and 11g?
    I have two database with version 10g and 11g, with the same data.
    I executed some pl/sql code with tracing 10046 level 8.
    And I have different result when obtain raw trace.
    In 10g I obtain rows statistics for all executions - Rows= 7.
    In 11g I obtain rows statistics for first executions - Rows= 1. Why?
    See my example:
    declare
         type t_name_tbl is table of varchar2(30) index by binary_integer;
         v_name_tbl t_name_tbl;
         v_len      number := 10;
    begin
         execute immediate 'alter session set timed_statistics = true ';
         execute immediate 'alter session set statistics_level=all ';
         execute immediate 'alter session set max_dump_file_size = unlimited ';
         execute immediate 'alter session set events ''10046 trace name context forever,level 8'' ';
         loop
           select cour_name bulk collect
                into v_name_tbl
               from country t
              where length(t.cour_name) = v_len;
           exit when v_len = 0;
           v_len := v_len - 1;
           for i in 1 .. v_name_tbl.count loop
             dbms_output.put_line(v_name_tbl(i));
           end loop;
         end loop;
    end;Result Tkprof for Oracle 10g:
    SELECT COUR_NAME
    FROM
    COUNTRY T WHERE LENGTH(T.COUR_NAME) = :B1
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute     11      0.00       0.00          0          0          0           0
    Fetch       11      0.01       0.00          0         44          0           7
    total       23      0.01       0.00          0         44          0           7
    Misses in library cache during parse: 0
    Optimizer mode: ALL_ROWS
    Parsing user id: 649     (recursive depth: 1)
    Rows     Row Source Operation
          7  TABLE ACCESS FULL COUNTRY (cr=44 pr=0 pw=0 time=1576 us)Result Tkprof for Oracle 11g:
    SQL ID: 3kqmkg8jp5nwk
    Plan Hash: 1371235632
    SELECT COUR_NAME
    FROM
    COUNTRY T WHERE LENGTH(T.COUR_NAME) = :B1
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.01       0.00          0          0          0           0
    Execute     11      0.02       0.01          0          0          0           0
    Fetch       11      0.00       0.01          3         44          0           7
    total       23      0.03       0.02          3         44          0           7
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 82     (recursive depth: 1)
    Rows     Row Source Operation
          1  TABLE ACCESS FULL COUNTRY (cr=4 pr=3 pw=0 time=0 us cost=2 size=44 card=2)Were can I read about it?

    Oracle 11g by default writes the execution plan (the STAT lines in the raw trace file) after the first execution of the SQL statement, while prior to 11g the execution plan is written only when the cursor is closed.
    The behavior in 11g can be controlled by changing the PLAN_STAT parameter of the call that enables the trace from the default value of FIRST_EXECUTION to ALL_EXECUTIONS:
    http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28419/d_sessio.htm#i1010518
    Charles Hooper
    Co-author of "Expert Oracle Practices: Oracle Database Administration from the Oak Table"
    http://hoopercharles.wordpress.com/
    IT Manager/Oracle DBA
    K&M Machine-Fabricating, Inc.
    Edited by: Charles Hooper on Aug 9, 2010 3:33 PM
    Default value on 11g is FIRST_EXECUTION, while the behavior prior to 11g is ALL_EXECUTIONS - corrected the incomplete sentence.

Maybe you are looking for