How to Collect Statistics

4 05 2011

May 4, 2011

In a previous article I shared a couple of the slides that I put together for an Oracle Database presentation for a specific ERP group - a presentation that as designed was far too long to fit into the permitted time slot.  I thought that in today’s blog article I would share a couple of “light-weight” slides from the presentation on the topic of statistics collection.

The notes that go along with the above slide are as follows:

Starting with Oracle Database 10.1 the query optimizer uses system statistics by default.  These statistics tell the optimizer characteristics about the server’s performance.  If you do not collect system statistics, Oracle will automatically use standardized system statistics, which are called NOWORKLOAD statistics.  When your server is under a typical to heavy load, you should gather the system statistics, which may be accomplished using a SQL*Plus command similar to the command at the top of this slide – this command will collect the statistics for a 60 minute time period and then set the statistic values. You can check the current system statistics using the SQL statement at the left.  If you see statistics like those at the right, that means your database is still using NOWORKLOAD statistics.

There is a bug in Oracle Database 11.2.0.1 and 11.2.0.2 related to the calculation of the SREADTIM – the average single-block read time expressed in milliseconds, and the MREADTIM – the average multi-block read time expressed in milliseconds.

The notes that go along with the above slide are as follows:

This slide shows an example of the statistics collection bug in Oracle Database 11.2.0.1 and Oracle Database 11.2.0.2.  Notice the large values for SREADTIM and MREADTIM.  These values are typically in the range of 4 to 12 milliseconds, and would normally appear as one or two digit values.  Watch out for cases where the SREADTIM value is greater than the MREADTIM value – that is almost certainly an error in the statistics collecting process and could be due to SAN read-ahead caching.

The calculated value of 78 for the MBRC, which is the average number of blocks read from disk during multi-block reads, might be a little high.  A high value for this parameter could cause the optimizer to use full table scans a little too frequently, and could lead to excessive CPU consumption problems – an example of this problem appears when Visual no longer uses the index on the PART_ID column when querying the INVENTORY_TRANS table when the PART_ID column is specified in the WHERE clause of a SQL statement.

The notes that go along with the above slide are as follows:

If you find that the System statistics were collected incorrectly, or if you need to set the system statistics of a test server to match the collected statistics of the production server, you can manually set the statistic values as shown at the top of this slide.

The notes that go along with the above slide are as follows:

It is important to make certain that the fixed object statistics are collected.  If the statistics are not collected, there is a strong chance that some queries of Oracle Database views will be slow, or even result in the crashing of the user’s session – see the link at the bottom of this slide for an example that shows what might happen if these statistics are not collected.  You can verify that the statistics were collected by executing the SQL statement at the left – if the SQL statement returns no rows, then the statistics have not been collected.

The notes that go along with the above slide are as follows:

Once you have collected the fixed object statistics, the query at the left will return output like you see on the right side of this slide.

The notes that go along with the above slide are as follows:

You should collect statistics weekly for the objects in the SYSADM schema (where the ERP data is located), typically when the database experiences little activity.  You can collect those statistics using the SQL*Plus command shown at the top of this slide.  Starting with Oracle Database 10.1 it is also a good idea to collect statistics for the objects in the SYS schema, and that can be done using the second command. 

Starting with Oracle Database 10.1 a stale statistics collecting process collects missing and out of date statistics for objects, typically starting around 10PM.  Even though the statistics collection is now partially automated in recent Oracle Database releases, it is still a good practice to collect statistics weekly.  You can verify that statistics were recently collected using the SQL statements at the bottom of this slide.

The notes that go along with the above slide are as follows:

I have been mentioning this warning for the last couple of years in the ERP mailing list – do not use the Update Database Statistics menu item in Visual to collect statistics.  Even in Visual 7.0, this menu command issues ANALYZE commands to collect the statistics, rather than the DBMS_STATS package which became the correct approach when Oracle 8i was introduced a decade ago.  The ANALYZE command does not collect all of the statistics needed by the Oracle query optimizer, and collects some statistics that potentially cause problems for the query optimizer.  You can execute the SQL statement shown on this slide to see if any tables in the SYSADM schema contain remnants from ANALYZE that need to be fixed.  If the query returns any rows, execute the SQL statements that are returned.

—–

Any comments about the above?  How would you do things differently?





What to Do When Performance Problems Appear

23 04 2011

April 23, 2011

I have a bit of a performance problem.  To be more specific, I am preparing to give a presentation on the topic of Oracle Database performance tuning for a specific ERP product, and I have encountered a performance problem.  Tuning the performance problem will requiring dropping too many slides – 59 slides for a 60 minute presentation with live demos taking up probably 20 minutes.  I think that my performance problem stems from spending too much time in PowerPoint – in the screen capture below a person watching the presentation can click the smiley face in the purple box to have the computer read my notes to the viewer.

The notes that go along with the above slide are as follows:

So, what do you do when you encounter a performance problem… contacting (the vendor’s) support probably is not the best approach.

You must be specific – stating that the database is slow does not offer a suitable starting point for performance improvement.  Pick one person who is encountering performance problems, and ask the person to describe what is happening – has this feature always been slow?  Gather metrics that measure the current performance, otherwise you will not know if the changes that are made will help or hurt performance. 

Work your way out from the database instance to the server, the network, and then the client.  If the database instance reports that the vast majority of the time is spent waiting for the next request from the client, then you need to move on to checking the network and client computer.  If the database instance reports that a lot of CPU time is being consumed, but not by the instance, then you need to look at the other processes that are running on the server.  If the database instance reports significant amounts of CPU time or wait events, then you need to take a closer look at the server configuration, database instance configuration, and execution plans.

Once you implement a change you should again measure the performance to verify that it improved – you might then identify another issue that should be addressed.  Avoid compulsive tuning disorder.

Just to make certain that that the above is clear, I put together this additional bit of information:

Of course, there are notes to go along with the slide:

Breaking it down again – when a performance problem is identified you will ideally take it down to the report or SQL statement level for analysis.  That level very often utilizes 10046 extended SQL traces for analysis.  The other suggestions provided on this slide will hopefully help you determine if the performance problem is in the database instance, or somewhere else.

If you had this performance tuning problem, what would you do (remember, there is only 60 to 120 seconds to convey the message of the slides)?  The second of the above slides was originally intended to appear as a decision tree, but that organization never quite materialized.

On a related topic, I was reviewing the data captured by one of my tools and found an old friend of a SQL statement:

This is the SQL statement that is highlighted, second from the bottom:

(SELECT /*+ RULE */ '', T.owner, T.table_name, TO_NUMBER(NULL), '', '', 0, TO_NUMBER(NULL), '', '', num_rows, blocks, NULL FROM ALL_TABLES T
WHERE table_name='PART' UNION SELECT /*+ RULE */ '', a.table_owner, a.table_name, decode(a.uniqueness, 'UNIQUE', 0, 1), a.owner, a.index_name,
 3, b.column_position, b.column_name, 'A', a.distinct_keys, a.leaf_blocks, NULL FROM ALL_INDEXES a, ALL_IND_COLUMNS b
WHERE a.owner = b.index_owner AND a.index_name = b.index_name AND a.table_owner='TESTUSER' AND a.table_name='PART'
UNION SELECT /*+ RULE */ '', c.owner, c.synonym_name, decode(a.uniqueness, 'UNIQUE', 0, 1), a.owner, a.index_name, 3, b.column_position,
 b.column_name, 'A', a.distinct_keys, a.leaf_blocks, NULL FROM ALL_INDEXES a, ALL_IND_COLUMNS b, ALL_SYNONYMS c
WHERE c.synonym_name='PART' AND c.owner='TESTUSER' AND c.table_name = a.table_name AND c.table_name = b.table_name
AND c.table_owner= a.table_owner AND c.table_owner= b.table_owner AND a.owner = b.index_owner AND a.index_name = b.index_name )
ORDER BY 4, 5, 6, 8 

The SQL statement directly below it is child 1 of the same SQL ID.  I know that you just can’t wait to see the execution plan for this SQL statement (take a close look at the above picture to see the CPU and consistent gets for a 70 second capture period):

SQL_ID  6wyvp7mhhmv91, child number 0
-------------------------------------
(SELECT /*+ RULE */ '', T.owner, T.table_name, TO_NUMBER(NULL), '', '', 0, TO_NUMBER(NULL),
'', '', num_rows, blocks, NULL FROM ALL_TABLES T WHERE table_name='PART' UNION SELECT /*+
RULE */ '', a.table_owner, a.table_name, decode(a.uniqueness, 'UNIQUE', 0, 1), a.owner,
a.index_name, 3, b.column_position, b.column_name, 'A', a.distinct_keys, a.leaf_blocks,
NULL FROM ALL_INDEXES a, ALL_IND_COLUMNS b WHERE a.owner = b.index_owner AND a.index_name =
b.index_name AND a.table_owner='TESTUSER' AND a.table_name='PART' UNION SELECT /*+ RULE */
'', c.owner, c.synonym_name, decode(a.uniqueness, 'UNIQUE', 0, 1), a.owner, a.index_name,
3, b.column_position, b.column_name, 'A', a.distinct_keys, a.leaf_blocks, NULL FROM
ALL_INDEXES a, ALL_IND_COLUMNS b, ALL_SYNONYMS c WHERE c.synonym_name='PART' AND
c.owner='TESTUSER' AND c.table_name = a.table_name AND c.table_name = b.table_name AND
c.table_owner= a.table_owner AND c.table_owner= b.table_owner AND a.owner = b.index_owner
AND a.index_name = b.index_na

Plan hash value: 80321140

----------------------------------------------------------------------------------------------------
| Id  | Operation                                                    | Name               | Inst   |
----------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT                                             |                    |        |
|   1 |  SORT UNIQUE                                                 |                    |        |
|   2 |   UNION-ALL                                                  |                    |        |
|*  3 |    FILTER                                                    |                    |        |
|   4 |     NESTED LOOPS                                             |                    |        |
|   5 |      NESTED LOOPS                                            |                    |        |
|   6 |       NESTED LOOPS OUTER                                     |                    |        |
|   7 |        NESTED LOOPS OUTER                                    |                    |        |
|   8 |         NESTED LOOPS OUTER                                   |                    |        |
|   9 |          NESTED LOOPS OUTER                                  |                    |        |
|  10 |           NESTED LOOPS                                       |                    |        |
|  11 |            NESTED LOOPS                                      |                    |        |
|  12 |             MERGE JOIN                                       |                    |        |
|* 13 |              FIXED TABLE FULL                                | X$KSPPI            |   TEST |
|* 14 |              SORT JOIN                                       |                    |        |
|  15 |               FIXED TABLE FULL                               | X$KSPPCV           |   TEST |
|* 16 |             TABLE ACCESS FULL                                | OBJ$               |   TEST |
|* 17 |            TABLE ACCESS CLUSTER                              | TAB$               |   TEST |
|* 18 |             INDEX UNIQUE SCAN                                | I_OBJ#             |   TEST |
|  19 |           TABLE ACCESS BY INDEX ROWID                        | OBJ$               |   TEST |
|* 20 |            INDEX UNIQUE SCAN                                 | I_OBJ1             |   TEST |
|* 21 |          INDEX UNIQUE SCAN                                   | I_OBJ1             |   TEST |
|  22 |         TABLE ACCESS CLUSTER                                 | USER$              |   TEST |
|* 23 |          INDEX UNIQUE SCAN                                   | I_USER#            |   TEST |
|  24 |        TABLE ACCESS CLUSTER                                  | SEG$               |   TEST |
|* 25 |         INDEX UNIQUE SCAN                                    | I_FILE#_BLOCK#     |   TEST |
|  26 |       TABLE ACCESS CLUSTER                                   | TS$                |   TEST |
|* 27 |        INDEX UNIQUE SCAN                                     | I_TS#              |   TEST |
|  28 |      TABLE ACCESS CLUSTER                                    | USER$              |   TEST |
|* 29 |       INDEX UNIQUE SCAN                                      | I_USER#            |   TEST |
|  30 |     NESTED LOOPS                                             |                    |        |
|  31 |      FIXED TABLE FULL                                        | X$KZSRO            |   TEST |
|* 32 |      INDEX RANGE SCAN                                        | I_OBJAUTH2         |   TEST |
|* 33 |       FIXED TABLE FULL                                       | X$KZSPR            |   TEST |
|* 34 |    FILTER                                                    |                    |        |
|  35 |     NESTED LOOPS                                             |                    |        |
|  36 |      NESTED LOOPS                                            |                    |        |
|  37 |       NESTED LOOPS OUTER                                     |                    |        |
|  38 |        NESTED LOOPS                                          |                    |        |
|  39 |         NESTED LOOPS                                         |                    |        |
|  40 |          NESTED LOOPS                                        |                    |        |
|  41 |           NESTED LOOPS                                       |                    |        |
|  42 |            NESTED LOOPS OUTER                                |                    |        |
|  43 |             NESTED LOOPS OUTER                               |                    |        |
|  44 |              NESTED LOOPS                                    |                    |        |
|  45 |               NESTED LOOPS                                   |                    |        |
|  46 |                NESTED LOOPS OUTER                            |                    |        |
|  47 |                 NESTED LOOPS                                 |                    |        |
|  48 |                  NESTED LOOPS OUTER                          |                    |        |
|  49 |                   NESTED LOOPS                               |                    |        |
|  50 |                    NESTED LOOPS                              |                    |        |
|  51 |                     TABLE ACCESS BY INDEX ROWID              | USER$              |   TEST |
|* 52 |                      INDEX UNIQUE SCAN                       | I_USER1            |   TEST |
|* 53 |                     TABLE ACCESS BY INDEX ROWID              | OBJ$               |   TEST |
|* 54 |                      INDEX RANGE SCAN                        | I_OBJ2             |   TEST |
|* 55 |                    TABLE ACCESS CLUSTER                      | IND$               |   TEST |
|* 56 |                     INDEX UNIQUE SCAN                        | I_OBJ#             |   TEST |
|  57 |                   TABLE ACCESS BY INDEX ROWID                | OBJ$               |   TEST |
|* 58 |                    INDEX UNIQUE SCAN                         | I_OBJ1             |   TEST |
|* 59 |                  TABLE ACCESS BY INDEX ROWID                 | OBJ$               |   TEST |
|* 60 |                   INDEX UNIQUE SCAN                          | I_OBJ1             |   TEST |
|  61 |                 TABLE ACCESS CLUSTER                         | USER$              |   TEST |
|* 62 |                  INDEX UNIQUE SCAN                           | I_USER#            |   TEST |
|  63 |                TABLE ACCESS CLUSTER                          | USER$              |   TEST |
|* 64 |                 INDEX UNIQUE SCAN                            | I_USER#            |   TEST |
|  65 |               TABLE ACCESS BY INDEX ROWID                    | USER$              |   TEST |
|* 66 |                INDEX UNIQUE SCAN                             | I_USER1            |   TEST |
|  67 |              TABLE ACCESS CLUSTER                            | SEG$               |   TEST |
|* 68 |               INDEX UNIQUE SCAN                              | I_FILE#_BLOCK#     |   TEST |
|  69 |             TABLE ACCESS CLUSTER                             | TS$                |   TEST |
|* 70 |              INDEX UNIQUE SCAN                               | I_TS#              |   TEST |
|  71 |            TABLE ACCESS BY INDEX ROWID                       | OBJ$               |   TEST |
|* 72 |             INDEX RANGE SCAN                                 | I_OBJ2             |   TEST |
|* 73 |           TABLE ACCESS BY INDEX ROWID                        | IND$               |   TEST |
|* 74 |            INDEX UNIQUE SCAN                                 | I_IND1             |   TEST |
|  75 |          TABLE ACCESS BY INDEX ROWID                         | ICOL$              |   TEST |
|* 76 |           INDEX RANGE SCAN                                   | I_ICOL1            |   TEST |
|* 77 |         TABLE ACCESS CLUSTER                                 | COL$               |   TEST |
|* 78 |        TABLE ACCESS CLUSTER                                  | ATTRCOL$           |   TEST |
|  79 |       TABLE ACCESS BY INDEX ROWID                            | OBJ$               |   TEST |
|* 80 |        INDEX UNIQUE SCAN                                     | I_OBJ1             |   TEST |
|  81 |      TABLE ACCESS CLUSTER                                    | USER$              |   TEST |
|* 82 |       INDEX UNIQUE SCAN                                      | I_USER#            |   TEST |
|  83 |     NESTED LOOPS                                             |                    |        |
|  84 |      FIXED TABLE FULL                                        | X$KZSRO            |   TEST |
|* 85 |      INDEX RANGE SCAN                                        | I_OBJAUTH2         |   TEST |
|* 86 |       FIXED TABLE FULL                                       | X$KZSPR            |   TEST |
|  87 |        NESTED LOOPS                                          |                    |        |
|  88 |         FIXED TABLE FULL                                     | X$KZSRO            |   TEST |
|* 89 |         INDEX RANGE SCAN                                     | I_OBJAUTH2         |   TEST |
|* 90 |          FIXED TABLE FULL                                    | X$KZSPR            |   TEST |
|* 91 |    FILTER                                                    |                    |        |
|  92 |     NESTED LOOPS OUTER                                       |                    |        |
|  93 |      NESTED LOOPS OUTER                                      |                    |        |
|  94 |       NESTED LOOPS OUTER                                     |                    |        |
|  95 |        NESTED LOOPS                                          |                    |        |
|  96 |         NESTED LOOPS OUTER                                   |                    |        |
|  97 |          NESTED LOOPS                                        |                    |        |
|  98 |           NESTED LOOPS                                       |                    |        |
|  99 |            NESTED LOOPS                                      |                    |        |
| 100 |             NESTED LOOPS                                     |                    |        |
| 101 |              NESTED LOOPS OUTER                              |                    |        |
| 102 |               NESTED LOOPS                                   |                    |        |
| 103 |                NESTED LOOPS                                  |                    |        |
| 104 |                 NESTED LOOPS                                 |                    |        |
| 105 |                  NESTED LOOPS                                |                    |        |
| 106 |                   NESTED LOOPS                               |                    |        |
| 107 |                    NESTED LOOPS                              |                    |        |
| 108 |                     NESTED LOOPS                             |                    |        |
| 109 |                      VIEW                                    | ALL_SYNONYMS       |   TEST |
| 110 |                       SORT UNIQUE                            |                    |        |
| 111 |                        UNION-ALL                             |                    |        |
|*112 |                         FILTER                               |                    |        |
| 113 |                          NESTED LOOPS                        |                    |        |
| 114 |                           NESTED LOOPS                       |                    |        |
| 115 |                            TABLE ACCESS BY INDEX ROWID       | USER$              |   TEST |
|*116 |                             INDEX UNIQUE SCAN                | I_USER1            |   TEST |
|*117 |                            TABLE ACCESS BY INDEX ROWID       | OBJ$               |   TEST |
|*118 |                             INDEX RANGE SCAN                 | I_OBJ2             |   TEST |
| 119 |                           TABLE ACCESS BY INDEX ROWID        | SYN$               |   TEST |
|*120 |                            INDEX UNIQUE SCAN                 | I_SYN1             |   TEST |
|*121 |                          FILTER                              |                    |        |
|*122 |                           FILTER                             |                    |        |
| 123 |                            NESTED LOOPS                      |                    |        |
| 124 |                             NESTED LOOPS                     |                    |        |
| 125 |                              TABLE ACCESS BY INDEX ROWID     | USER$              |   TEST |
|*126 |                               INDEX UNIQUE SCAN              | I_USER1            |   TEST |
| 127 |                              TABLE ACCESS BY INDEX ROWID     | OBJ$               |   TEST |
|*128 |                               INDEX RANGE SCAN               | I_OBJ2             |   TEST |
|*129 |                             INDEX RANGE SCAN                 | I_OBJAUTH1         |   TEST |
|*130 |                           FIXED TABLE FULL                   | X$KZSRO            |   TEST |
|*131 |                            FIXED TABLE FULL                  | X$KZSPR            |   TEST |
| 132 |                         NESTED LOOPS                         |                    |        |
| 133 |                          NESTED LOOPS                        |                    |        |
| 134 |                           NESTED LOOPS                       |                    |        |
| 135 |                            TABLE ACCESS BY INDEX ROWID       | USER$              |   TEST |
|*136 |                             INDEX UNIQUE SCAN                | I_USER1            |   TEST |
| 137 |                            VIEW                              | _ALL_SYNONYMS_TREE |   TEST |
|*138 |                             CONNECT BY WITHOUT FILTERING     |                    |        |
|*139 |                              FILTER                          |                    |        |
| 140 |                               COUNT                          |                    |        |
| 141 |                                NESTED LOOPS                  |                    |        |
| 142 |                                 NESTED LOOPS                 |                    |        |
| 143 |                                  NESTED LOOPS                |                    |        |
| 144 |                                   NESTED LOOPS               |                    |        |
| 145 |                                    TABLE ACCESS FULL         | USER$              |   TEST |
| 146 |                                    TABLE ACCESS BY INDEX ROWI| OBJ$               |   TEST |
|*147 |                                     INDEX RANGE SCAN         | I_OBJ2             |   TEST |
| 148 |                                   TABLE ACCESS BY INDEX ROWID| SYN$               |   TEST |
|*149 |                                    INDEX UNIQUE SCAN         | I_SYN1             |   TEST |
| 150 |                                  TABLE ACCESS BY INDEX ROWID | USER$              |   TEST |
|*151 |                                   INDEX UNIQUE SCAN          | I_USER1            |   TEST |
|*152 |                                 TABLE ACCESS BY INDEX ROWID  | OBJ$               |   TEST |
|*153 |                                  INDEX RANGE SCAN            | I_OBJ2             |   TEST |
|*154 |                               FILTER                         |                    |        |
| 155 |                                NESTED LOOPS                  |                    |        |
| 156 |                                 NESTED LOOPS                 |                    |        |
| 157 |                                  NESTED LOOPS                |                    |        |
|*158 |                                   TABLE ACCESS BY INDEX ROWID| SYN$               |   TEST |
|*159 |                                    INDEX UNIQUE SCAN         | I_SYN1             |   TEST |
| 160 |                                   TABLE ACCESS BY INDEX ROWID| USER$              |   TEST |
|*161 |                                    INDEX UNIQUE SCAN         | I_USER1            |   TEST |
| 162 |                                  TABLE ACCESS BY INDEX ROWID | OBJ$               |   TEST |
|*163 |                                   INDEX RANGE SCAN           | I_OBJ2             |   TEST |
|*164 |                                 INDEX RANGE SCAN             | I_OBJAUTH1         |   TEST |
|*165 |                                FIXED TABLE FULL              | X$KZSRO            |   TEST |
| 166 |                              COUNT                           |                    |        |
| 167 |                               NESTED LOOPS                   |                    |        |
| 168 |                                NESTED LOOPS                  |                    |        |
| 169 |                                 NESTED LOOPS                 |                    |        |
| 170 |                                  NESTED LOOPS                |                    |        |
| 171 |                                   TABLE ACCESS FULL          | USER$              |   TEST |
| 172 |                                   TABLE ACCESS BY INDEX ROWID| OBJ$               |   TEST |
|*173 |                                    INDEX RANGE SCAN          | I_OBJ2             |   TEST |
| 174 |                                  TABLE ACCESS BY INDEX ROWID | SYN$               |   TEST |
|*175 |                                   INDEX UNIQUE SCAN          | I_SYN1             |   TEST |
| 176 |                                 TABLE ACCESS BY INDEX ROWID  | USER$              |   TEST |
|*177 |                                  INDEX UNIQUE SCAN           | I_USER1            |   TEST |
|*178 |                                TABLE ACCESS BY INDEX ROWID   | OBJ$               |   TEST |
|*179 |                                 INDEX RANGE SCAN             | I_OBJ2             |   TEST |
|*180 |                           TABLE ACCESS BY INDEX ROWID        | OBJ$               |   TEST |
|*181 |                            INDEX UNIQUE SCAN                 | I_OBJ1             |   TEST |
| 182 |                          TABLE ACCESS BY INDEX ROWID         | SYN$               |   TEST |
|*183 |                           INDEX UNIQUE SCAN                  | I_SYN1             |   TEST |
| 184 |                      TABLE ACCESS BY INDEX ROWID             | USER$              |   TEST |
|*185 |                       INDEX UNIQUE SCAN                      | I_USER1            |   TEST |
| 186 |                     TABLE ACCESS BY INDEX ROWID              | USER$              |   TEST |
|*187 |                      INDEX UNIQUE SCAN                       | I_USER1            |   TEST |
| 188 |                    TABLE ACCESS BY INDEX ROWID               | OBJ$               |   TEST |
|*189 |                     INDEX RANGE SCAN                         | I_OBJ2             |   TEST |
| 190 |                   TABLE ACCESS CLUSTER                       | ICOL$              |   TEST |
|*191 |                    INDEX UNIQUE SCAN                         | I_OBJ#             |   TEST |
| 192 |                  TABLE ACCESS BY INDEX ROWID                 | OBJ$               |   TEST |
|*193 |                   INDEX UNIQUE SCAN                          | I_OBJ1             |   TEST |
|*194 |                 TABLE ACCESS BY INDEX ROWID                  | IND$               |   TEST |
|*195 |                  INDEX UNIQUE SCAN                           | I_IND1             |   TEST |
|*196 |                TABLE ACCESS CLUSTER                          | COL$               |   TEST |
|*197 |               TABLE ACCESS CLUSTER                           | ATTRCOL$           |   TEST |
| 198 |              TABLE ACCESS CLUSTER                            | USER$              |   TEST |
|*199 |               INDEX UNIQUE SCAN                              | I_USER#            |   TEST |
| 200 |             TABLE ACCESS BY INDEX ROWID                      | USER$              |   TEST |
|*201 |              INDEX UNIQUE SCAN                               | I_USER1            |   TEST |
|*202 |            TABLE ACCESS BY INDEX ROWID                       | OBJ$               |   TEST |
|*203 |             INDEX RANGE SCAN                                 | I_OBJ2             |   TEST |
|*204 |           TABLE ACCESS BY INDEX ROWID                        | IND$               |   TEST |
|*205 |            INDEX UNIQUE SCAN                                 | I_IND1             |   TEST |
| 206 |          TABLE ACCESS BY INDEX ROWID                         | OBJ$               |   TEST |
|*207 |           INDEX UNIQUE SCAN                                  | I_OBJ1             |   TEST |
|*208 |         TABLE ACCESS BY INDEX ROWID                          | OBJ$               |   TEST |
|*209 |          INDEX UNIQUE SCAN                                   | I_OBJ1             |   TEST |
| 210 |        TABLE ACCESS CLUSTER                                  | USER$              |   TEST |
|*211 |         INDEX UNIQUE SCAN                                    | I_USER#            |   TEST |
| 212 |       TABLE ACCESS CLUSTER                                   | SEG$               |   TEST |
|*213 |        INDEX UNIQUE SCAN                                     | I_FILE#_BLOCK#     |   TEST |
| 214 |      TABLE ACCESS CLUSTER                                    | TS$                |   TEST |
|*215 |       INDEX UNIQUE SCAN                                      | I_TS#              |   TEST |
| 216 |     NESTED LOOPS                                             |                    |        |
| 217 |      FIXED TABLE FULL                                        | X$KZSRO            |   TEST |
|*218 |      INDEX RANGE SCAN                                        | I_OBJAUTH2         |   TEST |
|*219 |       FIXED TABLE FULL                                       | X$KZSPR            |   TEST |
| 220 |        NESTED LOOPS                                          |                    |        |
| 221 |         FIXED TABLE FULL                                     | X$KZSRO            |   TEST |
|*222 |         INDEX RANGE SCAN                                     | I_OBJAUTH2         |   TEST |
|*223 |          FIXED TABLE FULL                                    | X$KZSPR            |   TEST |
----------------------------------------------------------------------------------------------------

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

   3 - filter(("O"."OWNER#"=USERENV('SCHEMAID') OR  IS NOT NULL OR  IS NOT NULL))
  13 - filter("KSPPI"."KSPPINM"='_dml_monitoring_enabled')
  14 - access("KSPPI"."INDX"="KSPPCV"."INDX")
       filter("KSPPI"."INDX"="KSPPCV"."INDX")
  16 - filter((BITAND("O"."FLAGS",128)=0 AND "O"."NAME"='PART'))
  17 - filter(BITAND("T"."PROPERTY",1)=0)
  18 - access("O"."OBJ#"="T"."OBJ#")
  20 - access("T"."DATAOBJ#"="CX"."OBJ#")
  21 - access("T"."BOBJ#"="CO"."OBJ#")
  23 - access("CX"."OWNER#"="CU"."USER#")
  25 - access("T"."TS#"="S"."TS#" AND "T"."FILE#"="S"."FILE#" AND "T"."BLOCK#"="S"."BLOCK#")
  27 - access("T"."TS#"="TS"."TS#")
  29 - access("O"."OWNER#"="U"."USER#")
  32 - access("GRANTEE#"="KZSROROL" AND "OA"."OBJ#"=:B1)
  33 - filter(("INST_ID"=USERENV('INSTANCE') AND ((-"KZSPRPRV")=(-45) OR
              (-"KZSPRPRV")=(-47) OR (-"KZSPRPRV")=(-48) OR (-"KZSPRPRV")=(-49) OR (-"KZSPRPRV")=(-50))))
  34 - filter((("IDX"."OWNER#"=USERENV('SCHEMAID') OR "BASE"."OWNER#"=USERENV('SCHEMAID')
              OR  IS NOT NULL OR  IS NOT NULL) AND ("IO"."OWNER#"=USERENV('SCHEMAID') OR  IS NOT NULL OR 
              IS NOT NULL)))
  52 - access("IU"."NAME"='TESTUSER')
  53 - filter("IO"."TYPE#"=2)
  54 - access("IO"."OWNER#"="IU"."USER#" AND "IO"."NAME"='PART')
  55 - filter((("I"."TYPE#"=1 OR "I"."TYPE#"=2 OR "I"."TYPE#"=3 OR "I"."TYPE#"=4 OR
              "I"."TYPE#"=6 OR "I"."TYPE#"=7 OR "I"."TYPE#"=9) AND BITAND("I"."FLAGS",4096)=0))
  56 - access("I"."BO#"="IO"."OBJ#")
  58 - access("I"."INDMETHOD#"="ITO"."OBJ#")
  59 - filter(BITAND("O"."FLAGS",128)=0)
  60 - access("O"."OBJ#"="I"."OBJ#")
  62 - access("ITO"."OWNER#"="ITU"."USER#")
  64 - access("U"."USER#"="O"."OWNER#")
  66 - access("U"."NAME"="IO"."NAME")
  68 - access("I"."TS#"="S"."TS#" AND "I"."FILE#"="S"."FILE#" AND "I"."BLOCK#"="S"."BLOCK#")
  70 - access("I"."TS#"="TS"."TS#")
  72 - access("IO"."USER#"="IDX"."OWNER#" AND "O"."NAME"="IDX"."NAME")
  73 - filter(("I"."TYPE#"=1 OR "I"."TYPE#"=2 OR "I"."TYPE#"=3 OR "I"."TYPE#"=4 OR
              "I"."TYPE#"=6 OR "I"."TYPE#"=7 OR "I"."TYPE#"=9))
  74 - access("IDX"."OBJ#"="I"."OBJ#")
  76 - access("IC"."OBJ#"="IDX"."OBJ#")
  77 - filter("C"."INTCOL#"=DECODE(BITAND("I"."PROPERTY",1024),0,"IC"."INTCOL#","IC"."SPARE2
              "))
  78 - filter("C"."INTCOL#"="AC"."INTCOL#")
  80 - access("IC"."BO#"="BASE"."OBJ#")
  82 - access("BO"."USER#"="BASE"."OWNER#")
  85 - access("GRANTEE#"="KZSROROL" AND "OBJ#"=:B1)
  86 - filter(("INST_ID"=USERENV('INSTANCE') AND ((-"KZSPRPRV")=(-45) OR
              (-"KZSPRPRV")=(-47) OR (-"KZSPRPRV")=(-48) OR (-"KZSPRPRV")=(-49) OR (-"KZSPRPRV")=(-50))))
  89 - access("GRANTEE#"="KZSROROL" AND "OBJ#"=:B1)
  90 - filter(("INST_ID"=USERENV('INSTANCE') AND ((-"KZSPRPRV")=(-45) OR
              (-"KZSPRPRV")=(-47) OR (-"KZSPRPRV")=(-48) OR (-"KZSPRPRV")=(-49) OR (-"KZSPRPRV")=(-50))))
  91 - filter((("IDX"."OWNER#"=USERENV('SCHEMAID') OR "BASE"."OWNER#"=USERENV('SCHEMAID')
              OR  IS NOT NULL OR  IS NOT NULL) AND ("IO"."OWNER#"=USERENV('SCHEMAID') OR  IS NOT NULL OR 
              IS NOT NULL)))
 112 - filter(("O"."OWNER#"=USERENV('SCHEMAID') OR "O"."OWNER#"=1 OR  IS NOT NULL OR
              ("S"."NODE" IS NULL AND  IS NOT NULL)))
 116 - access("U"."NAME"='TESTUSER')
 117 - filter("O"."TYPE#"=5)
 118 - access("O"."OWNER#"="U"."USER#" AND "O"."NAME"='PART')
 120 - access("O"."OBJ#"="S"."OBJ#")
 121 - filter(( IS NOT NULL OR "BA"."GRANTOR#"=USERENV('SCHEMAID')))
 122 - filter(:B1 IS NULL)
 126 - access("BU"."NAME"=:B1)
 128 - access("BU"."USER#"="BO"."OWNER#" AND "BO"."NAME"=:B1)
 129 - access("BA"."OBJ#"="BO"."OBJ#")
 130 - filter("KZSROROL"=:B1)
 131 - filter(("INST_ID"=USERENV('INSTANCE') AND ((-"KZSPRPRV")=(-45) OR
              (-"KZSPRPRV")=(-47) OR (-"KZSPRPRV")=(-48) OR (-"KZSPRPRV")=(-49) OR (-"KZSPRPRV")=(-50))))
 136 - access("U"."NAME"='TESTUSER')
 138 - access("BO"."OBJ#"=PRIOR NULL)
 139 - filter( IS NOT NULL)
 147 - access("O"."OWNER#"="U"."USER#")
 149 - access("S"."OBJ#"="O"."OBJ#")
 151 - access("S"."OWNER"="BU"."NAME")
 152 - filter("BO"."TYPE#"=5)
 153 - access("BU"."USER#"="BO"."OWNER#" AND "S"."NAME"="BO"."NAME")
 154 - filter(( IS NOT NULL OR "OA"."GRANTOR#"=USERENV('SCHEMAID')))
 158 - filter("S"."NODE" IS NULL)
 159 - access("S"."OBJ#"=:B1)
 161 - access("S"."OWNER"="BU"."NAME")
 163 - access("BU"."USER#"="BO"."OWNER#" AND "S"."NAME"="BO"."NAME")
 164 - access("BO"."OBJ#"="OA"."OBJ#")
 165 - filter("KZSROROL"=:B1)
 173 - access("O"."OWNER#"="U"."USER#")
 175 - access("S"."OBJ#"="O"."OBJ#")
 177 - access("S"."OWNER"="BU"."NAME")
 178 - filter("BO"."TYPE#"=5)
 179 - access("BU"."USER#"="BO"."OWNER#" AND "S"."NAME"="BO"."NAME")
 180 - filter(("O"."NAME"='PART' AND "O"."OWNER#"="U"."USER#" AND "O"."TYPE#"=5))
 181 - access("O"."OBJ#"="ST"."SYN_ID")
 183 - access("O"."OBJ#"="S"."OBJ#")
       filter("S"."OBJ#"="ST"."SYN_ID")
 185 - access("C"."TABLE_OWNER"="BO"."NAME")
 187 - access("C"."TABLE_OWNER"="IU"."NAME")
 189 - access("BO"."USER#"="BASE"."OWNER#" AND "C"."TABLE_NAME"="BASE"."NAME")
 191 - access("IC"."BO#"="BASE"."OBJ#")
 193 - access("IC"."OBJ#"="IDX"."OBJ#")
 194 - filter(("I"."TYPE#"=1 OR "I"."TYPE#"=2 OR "I"."TYPE#"=3 OR "I"."TYPE#"=4 OR
              "I"."TYPE#"=6 OR "I"."TYPE#"=7 OR "I"."TYPE#"=9))
 195 - access("IDX"."OBJ#"="I"."OBJ#")
 196 - filter("C"."INTCOL#"=DECODE(BITAND("I"."PROPERTY",1024),0,"IC"."INTCOL#","IC"."SPARE2
              "))
 197 - filter("C"."INTCOL#"="AC"."INTCOL#")
 199 - access("IO"."USER#"="IDX"."OWNER#")
 201 - access("U"."NAME"="IO"."NAME")
 202 - filter(BITAND("O"."FLAGS",128)=0)
 203 - access("U"."USER#"="O"."OWNER#" AND "O"."NAME"="IDX"."NAME")
 204 - filter((("I"."TYPE#"=1 OR "I"."TYPE#"=2 OR "I"."TYPE#"=3 OR "I"."TYPE#"=4 OR
              "I"."TYPE#"=6 OR "I"."TYPE#"=7 OR "I"."TYPE#"=9) AND BITAND("I"."FLAGS",4096)=0))
 205 - access("O"."OBJ#"="I"."OBJ#")
 207 - access("I"."INDMETHOD#"="ITO"."OBJ#")
 208 - filter(("IO"."TYPE#"=2 AND "IO"."OWNER#"="IU"."USER#" AND
              "C"."TABLE_NAME"="IO"."NAME"))
 209 - access("I"."BO#"="IO"."OBJ#")
 211 - access("ITO"."OWNER#"="ITU"."USER#")
 213 - access("I"."TS#"="S"."TS#" AND "I"."FILE#"="S"."FILE#" AND "I"."BLOCK#"="S"."BLOCK#")
 215 - access("I"."TS#"="TS"."TS#")
 218 - access("GRANTEE#"="KZSROROL" AND "OBJ#"=:B1)
 219 - filter(("INST_ID"=USERENV('INSTANCE') AND ((-"KZSPRPRV")=(-45) OR
              (-"KZSPRPRV")=(-47) OR (-"KZSPRPRV")=(-48) OR (-"KZSPRPRV")=(-49) OR (-"KZSPRPRV")=(-50))))
 222 - access("GRANTEE#"="KZSROROL" AND "OBJ#"=:B1)
 223 - filter(("INST_ID"=USERENV('INSTANCE') AND ((-"KZSPRPRV")=(-45) OR
              (-"KZSPRPRV")=(-47) OR (-"KZSPRPRV")=(-48) OR (-"KZSPRPRV")=(-49) OR (-"KZSPRPRV")=(-50))))

Note
-----
   - rule based optimizer used (consider using cbo) 

So, where does this SQL statement come from?  If memory serves correctly, this SQL statement is submitted by the Oracle 10.2 ODBC connector.  Oracle Database 11.2 comes up with a slightly different execution plan for the same SQL statement, but I do not know if the 11.2 ODBC connector ever submits the same SQL statement.  The execution plan from Oracle Database 11.2.0.2 for the above SQL statement (STATISTICS_LEVEL = ALL):

Plan hash value: 558250693

-------------------------------------------------------------------------------------------------------------------------------------------------------------
| Id  | Operation                                                  | Name               | Starts | A-Rows |   A-Time   | Buffers |  OMem |  1Mem | Used-Mem |
-------------------------------------------------------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT                                           |                    |      1 |      1 |00:00:00.15 |   29866 |       |       |          |
|   1 |  SORT UNIQUE                                               |                    |      1 |      1 |00:00:00.15 |   29866 |  2048 |  2048 | 2048  (0)|
|   2 |   UNION-ALL                                                |                    |      1 |      1 |00:00:00.15 |   29866 |       |       |          |
|*  3 |    FILTER                                                  |                    |      1 |      1 |00:00:00.02 |     943 |       |       |          |
|   4 |     NESTED LOOPS OUTER                                     |                    |      1 |      1 |00:00:00.02 |     943 |       |       |          |
|   5 |      NESTED LOOPS OUTER                                    |                    |      1 |      1 |00:00:00.02 |     943 |       |       |          |
|   6 |       NESTED LOOPS OUTER                                   |                    |      1 |      1 |00:00:00.02 |     941 |       |       |          |
|   7 |        NESTED LOOPS                                        |                    |      1 |      1 |00:00:00.02 |     939 |       |       |          |
|   8 |         NESTED LOOPS                                       |                    |      1 |      1 |00:00:00.02 |     937 |       |       |          |
|   9 |          NESTED LOOPS OUTER                                |                    |      1 |      1 |00:00:00.02 |     935 |       |       |          |
|  10 |           NESTED LOOPS                                     |                    |      1 |      1 |00:00:00.02 |     932 |       |       |          |
|  11 |            NESTED LOOPS                                    |                    |      1 |      2 |00:00:00.02 |     925 |       |       |          |
|  12 |             MERGE JOIN                                     |                    |      1 |      1 |00:00:00.01 |       0 |       |       |          |
|* 13 |              FIXED TABLE FULL                              | X$KSPPI            |      1 |      1 |00:00:00.01 |       0 |       |       |          |
|* 14 |              SORT JOIN                                     |                    |      1 |      1 |00:00:00.01 |       0 | 59392 | 59392 |53248  (0)|
|  15 |               FIXED TABLE FULL                             | X$KSPPCV           |      1 |   2649 |00:00:00.01 |       0 |       |       |          |
|* 16 |             TABLE ACCESS FULL                              | OBJ$               |      1 |      2 |00:00:00.01 |     925 |       |       |          |
|* 17 |            TABLE ACCESS CLUSTER                            | TAB$               |      2 |      1 |00:00:00.01 |       7 |       |       |          |
|* 18 |             INDEX UNIQUE SCAN                              | I_OBJ#             |      2 |      1 |00:00:00.01 |       4 |       |       |          |
|  19 |           TABLE ACCESS CLUSTER                             | SEG$               |      1 |      1 |00:00:00.01 |       3 |       |       |          |
|* 20 |            INDEX UNIQUE SCAN                               | I_FILE#_BLOCK#     |      1 |      1 |00:00:00.01 |       2 |       |       |          |
|  21 |          TABLE ACCESS CLUSTER                              | TS$                |      1 |      1 |00:00:00.01 |       2 |       |       |          |
|* 22 |           INDEX UNIQUE SCAN                                | I_TS#              |      1 |      1 |00:00:00.01 |       1 |       |       |          |
|  23 |         TABLE ACCESS CLUSTER                               | USER$              |      1 |      1 |00:00:00.01 |       2 |       |       |          |
|* 24 |          INDEX UNIQUE SCAN                                 | I_USER#            |      1 |      1 |00:00:00.01 |       1 |       |       |          |
|* 25 |        INDEX RANGE SCAN                                    | I_OBJ1             |      1 |      1 |00:00:00.01 |       2 |       |       |          |
|  26 |       TABLE ACCESS CLUSTER                                 | USER$              |      1 |      1 |00:00:00.01 |       2 |       |       |          |
|* 27 |        INDEX UNIQUE SCAN                                   | I_USER#            |      1 |      1 |00:00:00.01 |       1 |       |       |          |
|* 28 |      INDEX RANGE SCAN                                      | I_OBJ1             |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|  29 |     NESTED LOOPS                                           |                    |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|  30 |      FIXED TABLE FULL                                      | X$KZSRO            |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|* 31 |      INDEX RANGE SCAN                                      | I_OBJAUTH2         |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|* 32 |     FIXED TABLE FULL                                       | X$KZSPR            |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|  33 |    NESTED LOOPS OUTER                                      |                    |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|  34 |     TABLE ACCESS BY INDEX ROWID                            | COL$               |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|* 35 |      INDEX UNIQUE SCAN                                     | I_COL3             |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|* 36 |     TABLE ACCESS CLUSTER                                   | ATTRCOL$           |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|* 37 |    FILTER                                                  |                    |      1 |      0 |00:00:00.01 |       5 |       |       |          |
|  38 |     NESTED LOOPS                                           |                    |      1 |      0 |00:00:00.01 |       5 |       |       |          |
|  39 |      NESTED LOOPS                                          |                    |      1 |      0 |00:00:00.01 |       5 |       |       |          |
|  40 |       NESTED LOOPS OUTER                                   |                    |      1 |      0 |00:00:00.01 |       5 |       |       |          |
|  41 |        NESTED LOOPS                                        |                    |      1 |      0 |00:00:00.01 |       5 |       |       |          |
|  42 |         NESTED LOOPS                                       |                    |      1 |      0 |00:00:00.01 |       5 |       |       |          |
|  43 |          NESTED LOOPS                                      |                    |      1 |      0 |00:00:00.01 |       5 |       |       |          |
|  44 |           NESTED LOOPS                                     |                    |      1 |      0 |00:00:00.01 |       5 |       |       |          |
|  45 |            NESTED LOOPS                                    |                    |      1 |      0 |00:00:00.01 |       5 |       |       |          |
|  46 |             NESTED LOOPS                                   |                    |      1 |      0 |00:00:00.01 |       5 |       |       |          |
|  47 |              NESTED LOOPS OUTER                            |                    |      1 |      0 |00:00:00.01 |       5 |       |       |          |
|  48 |               NESTED LOOPS OUTER                           |                    |      1 |      0 |00:00:00.01 |       5 |       |       |          |
|  49 |                NESTED LOOPS OUTER                          |                    |      1 |      0 |00:00:00.01 |       5 |       |       |          |
|  50 |                 NESTED LOOPS OUTER                         |                    |      1 |      0 |00:00:00.01 |       5 |       |       |          |
|  51 |                  NESTED LOOPS                              |                    |      1 |      0 |00:00:00.01 |       5 |       |       |          |
|  52 |                   NESTED LOOPS                             |                    |      1 |      0 |00:00:00.01 |       5 |       |       |          |
|  53 |                    TABLE ACCESS BY INDEX ROWID             | USER$              |      1 |      1 |00:00:00.01 |       2 |       |       |          |
|* 54 |                     INDEX UNIQUE SCAN                      | I_USER1            |      1 |      1 |00:00:00.01 |       1 |       |       |          |
|* 55 |                    INDEX RANGE SCAN                        | I_OBJ2             |      1 |      0 |00:00:00.01 |       3 |       |       |          |
|* 56 |                   TABLE ACCESS CLUSTER                     | IND$               |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|* 57 |                    INDEX UNIQUE SCAN                       | I_OBJ#             |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|  58 |                  TABLE ACCESS CLUSTER                      | SEG$               |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|* 59 |                   INDEX UNIQUE SCAN                        | I_FILE#_BLOCK#     |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|  60 |                 TABLE ACCESS CLUSTER                       | TS$                |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|* 61 |                  INDEX UNIQUE SCAN                         | I_TS#              |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|* 62 |                INDEX RANGE SCAN                            | I_OBJ1             |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|  63 |               TABLE ACCESS CLUSTER                         | USER$              |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|* 64 |                INDEX UNIQUE SCAN                           | I_USER#            |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|* 65 |              TABLE ACCESS BY INDEX ROWID                   | OBJ$               |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|* 66 |               INDEX RANGE SCAN                             | I_OBJ1             |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|  67 |             TABLE ACCESS CLUSTER                           | USER$              |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|* 68 |              INDEX UNIQUE SCAN                             | I_USER#            |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|* 69 |            INDEX RANGE SCAN                                | I_OBJ2             |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|* 70 |           TABLE ACCESS BY INDEX ROWID                      | IND$               |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|* 71 |            INDEX UNIQUE SCAN                               | I_IND1             |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|  72 |          TABLE ACCESS BY INDEX ROWID                       | ICOL$              |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|* 73 |           INDEX RANGE SCAN                                 | I_ICOL1            |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|* 74 |         TABLE ACCESS CLUSTER                               | COL$               |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|* 75 |        TABLE ACCESS CLUSTER                                | ATTRCOL$           |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|* 76 |       INDEX RANGE SCAN                                     | I_OBJ1             |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|  77 |      TABLE ACCESS CLUSTER                                  | USER$              |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|* 78 |       INDEX UNIQUE SCAN                                    | I_USER#            |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|  79 |     NESTED LOOPS                                           |                    |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|  80 |      FIXED TABLE FULL                                      | X$KZSRO            |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|* 81 |      INDEX RANGE SCAN                                      | I_OBJAUTH2         |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|* 82 |     FIXED TABLE FULL                                       | X$KZSPR            |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|  83 |     NESTED LOOPS                                           |                    |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|  84 |      FIXED TABLE FULL                                      | X$KZSRO            |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|* 85 |      INDEX RANGE SCAN                                      | I_OBJAUTH2         |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|* 86 |     FIXED TABLE FULL                                       | X$KZSPR            |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|  87 |    NESTED LOOPS OUTER                                      |                    |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|  88 |     TABLE ACCESS BY INDEX ROWID                            | COL$               |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|* 89 |      INDEX UNIQUE SCAN                                     | I_COL3             |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|* 90 |     TABLE ACCESS CLUSTER                                   | ATTRCOL$           |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|* 91 |    FILTER                                                  |                    |      1 |      0 |00:00:00.13 |   28918 |       |       |          |
|  92 |     NESTED LOOPS OUTER                                     |                    |      1 |      0 |00:00:00.13 |   28918 |       |       |          |
|  93 |      NESTED LOOPS OUTER                                    |                    |      1 |      0 |00:00:00.13 |   28918 |       |       |          |
|  94 |       NESTED LOOPS                                         |                    |      1 |      0 |00:00:00.13 |   28918 |       |       |          |
|  95 |        NESTED LOOPS                                        |                    |      1 |      0 |00:00:00.13 |   28918 |       |       |          |
|  96 |         NESTED LOOPS                                       |                    |      1 |      0 |00:00:00.13 |   28918 |       |       |          |
|  97 |          NESTED LOOPS                                      |                    |      1 |      0 |00:00:00.13 |   28918 |       |       |          |
|  98 |           NESTED LOOPS OUTER                               |                    |      1 |      0 |00:00:00.13 |   28918 |       |       |          |
|  99 |            NESTED LOOPS OUTER                              |                    |      1 |      0 |00:00:00.13 |   28918 |       |       |          |
| 100 |             NESTED LOOPS                                   |                    |      1 |      0 |00:00:00.13 |   28918 |       |       |          |
| 101 |              NESTED LOOPS                                  |                    |      1 |      0 |00:00:00.13 |   28918 |       |       |          |
| 102 |               NESTED LOOPS OUTER                           |                    |      1 |      0 |00:00:00.13 |   28918 |       |       |          |
| 103 |                NESTED LOOPS                                |                    |      1 |      0 |00:00:00.13 |   28918 |       |       |          |
| 104 |                 NESTED LOOPS                               |                    |      1 |      0 |00:00:00.13 |   28918 |       |       |          |
| 105 |                  NESTED LOOPS                              |                    |      1 |      0 |00:00:00.13 |   28918 |       |       |          |
| 106 |                   NESTED LOOPS                             |                    |      1 |      0 |00:00:00.13 |   28918 |       |       |          |
| 107 |                    VIEW                                    | ALL_SYNONYMS       |      1 |      0 |00:00:00.13 |   28918 |       |       |          |
| 108 |                     SORT UNIQUE                            |                    |      1 |      0 |00:00:00.13 |   28918 |  1024 |  1024 |          |
| 109 |                      UNION-ALL                             |                    |      1 |      0 |00:00:00.13 |   28918 |       |       |          |
|*110 |                       FILTER                               |                    |      1 |      0 |00:00:00.01 |       5 |       |       |          |
| 111 |                        NESTED LOOPS                        |                    |      1 |      0 |00:00:00.01 |       5 |       |       |          |
| 112 |                         NESTED LOOPS                       |                    |      1 |      0 |00:00:00.01 |       5 |       |       |          |
| 113 |                          NESTED LOOPS                      |                    |      1 |      0 |00:00:00.01 |       5 |       |       |          |
| 114 |                           TABLE ACCESS BY INDEX ROWID      | USER$              |      1 |      1 |00:00:00.01 |       2 |       |       |          |
|*115 |                            INDEX UNIQUE SCAN               | I_USER1            |      1 |      1 |00:00:00.01 |       1 |       |       |          |
|*116 |                           INDEX RANGE SCAN                 | I_OBJ5             |      1 |      0 |00:00:00.01 |       3 |       |       |          |
| 117 |                          TABLE ACCESS BY INDEX ROWID       | SYN$               |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*118 |                           INDEX UNIQUE SCAN                | I_SYN1             |      0 |      0 |00:00:00.01 |       0 |       |       |          |
| 119 |                         TABLE ACCESS CLUSTER               | USER$              |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*120 |                          INDEX UNIQUE SCAN                 | I_USER#            |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*121 |                        FIXED TABLE FULL                    | X$KZSPR            |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*122 |                        FILTER                              |                    |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*123 |                         FILTER                             |                    |      0 |      0 |00:00:00.01 |       0 |       |       |          |
| 124 |                          NESTED LOOPS                      |                    |      0 |      0 |00:00:00.01 |       0 |       |       |          |
| 125 |                           NESTED LOOPS                     |                    |      0 |      0 |00:00:00.01 |       0 |       |       |          |
| 126 |                            NESTED LOOPS                    |                    |      0 |      0 |00:00:00.01 |       0 |       |       |          |
| 127 |                             TABLE ACCESS BY INDEX ROWID    | USER$              |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*128 |                              INDEX UNIQUE SCAN             | I_USER1            |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*129 |                             INDEX RANGE SCAN               | I_OBJ5             |      0 |      0 |00:00:00.01 |       0 |       |       |          |
| 130 |                            TABLE ACCESS CLUSTER            | USER$              |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*131 |                             INDEX UNIQUE SCAN              | I_USER#            |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*132 |                           INDEX RANGE SCAN                 | I_OBJAUTH1         |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*133 |                         FIXED TABLE FULL                   | X$KZSRO            |      0 |      0 |00:00:00.01 |       0 |       |       |          |
| 134 |                         NESTED LOOPS                       |                    |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*135 |                          INDEX RANGE SCAN                  | I_OBJ4             |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*136 |                          TABLE ACCESS CLUSTER              | USER$              |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*137 |                           INDEX UNIQUE SCAN                | I_USER#            |      0 |      0 |00:00:00.01 |       0 |       |       |          |
| 138 |                        NESTED LOOPS                        |                    |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*139 |                         INDEX RANGE SCAN                   | I_OBJ4             |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*140 |                         TABLE ACCESS CLUSTER               | USER$              |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*141 |                          INDEX UNIQUE SCAN                 | I_USER#            |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*142 |                       VIEW                                 | _ALL_SYNONYMS_TREE |      1 |      0 |00:00:00.13 |   28913 |       |       |          |
|*143 |                        CONNECT BY WITH FILTERING           |                    |      1 |     34 |00:00:00.13 |   28913 |  6144 |  6144 | 6144  (0)|
|*144 |                         FILTER                             |                    |      1 |     34 |00:00:00.13 |   28820 |       |       |          |
| 145 |                          NESTED LOOPS                      |                    |      1 |     34 |00:00:00.13 |   28747 |       |       |          |
| 146 |                           NESTED LOOPS                     |                    |      1 |     34 |00:00:00.13 |   28709 |       |       |          |
| 147 |                            NESTED LOOPS                    |                    |      1 |     34 |00:00:00.13 |   28671 |       |       |          |
| 148 |                             NESTED LOOPS                   |                    |      1 |     34 |00:00:00.13 |   28662 |       |       |          |
| 149 |                              NESTED LOOPS                  |                    |      1 |  27736 |00:00:00.09 |   28611 |       |       |          |
| 150 |                               NESTED LOOPS                 |                    |      1 |  27736 |00:00:00.02 |     871 |       |       |          |
| 151 |                                TABLE ACCESS FULL           | USER$              |      1 |     72 |00:00:00.01 |       6 |       |       |          |
|*152 |                                INDEX RANGE SCAN            | I_OBJ5             |     72 |  27736 |00:00:00.01 |     865 |       |       |          |
| 153 |                               TABLE ACCESS CLUSTER         | USER$              |  27736 |  27736 |00:00:00.07 |   27740 |       |       |          |
|*154 |                                INDEX UNIQUE SCAN           | I_USER#            |  27736 |  27736 |00:00:00.02 |       4 |       |       |          |
| 155 |                              TABLE ACCESS BY INDEX ROWID   | SYN$               |  27736 |     34 |00:00:00.03 |      51 |       |       |          |
|*156 |                               INDEX RANGE SCAN             | I_SYN2             |  27736 |     34 |00:00:00.02 |      50 |       |       |          |
| 157 |                             TABLE ACCESS BY INDEX ROWID    | OBJ$               |     34 |     34 |00:00:00.01 |       9 |       |       |          |
|*158 |                              INDEX RANGE SCAN              | I_OBJ1             |     34 |     34 |00:00:00.01 |       8 |       |       |          |
| 159 |                            TABLE ACCESS CLUSTER            | USER$              |     34 |     34 |00:00:00.01 |      38 |       |       |          |
|*160 |                             INDEX UNIQUE SCAN              | I_USER#            |     34 |     34 |00:00:00.01 |       4 |       |       |          |
| 161 |                           TABLE ACCESS CLUSTER             | USER$              |     34 |     34 |00:00:00.01 |      38 |       |       |          |
|*162 |                            INDEX UNIQUE SCAN               | I_USER#            |     34 |     34 |00:00:00.01 |       4 |       |       |          |
|*163 |                          FILTER                            |                    |     34 |     34 |00:00:00.01 |      73 |       |       |          |
| 164 |                           TABLE ACCESS BY INDEX ROWID      | SYN$               |     34 |     34 |00:00:00.01 |      73 |       |       |          |
|*165 |                            INDEX UNIQUE SCAN               | I_SYN1             |     34 |     34 |00:00:00.01 |      39 |       |       |          |
|*166 |                           FIXED TABLE FULL                 | X$KZSPR            |      1 |      1 |00:00:00.01 |       0 |       |       |          |
|*167 |                           FILTER                           |                    |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*168 |                            FILTER                          |                    |      0 |      0 |00:00:00.01 |       0 |       |       |          |
| 169 |                             NESTED LOOPS                   |                    |      0 |      0 |00:00:00.01 |       0 |       |       |          |
| 170 |                              NESTED LOOPS                  |                    |      0 |      0 |00:00:00.01 |       0 |       |       |          |
| 171 |                               NESTED LOOPS                 |                    |      0 |      0 |00:00:00.01 |       0 |       |       |          |
| 172 |                                TABLE ACCESS BY INDEX ROWID | USER$              |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*173 |                                 INDEX UNIQUE SCAN          | I_USER1            |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*174 |                                INDEX RANGE SCAN            | I_OBJ5             |      0 |      0 |00:00:00.01 |       0 |       |       |          |
| 175 |                               TABLE ACCESS CLUSTER         | USER$              |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*176 |                                INDEX UNIQUE SCAN           | I_USER#            |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*177 |                              INDEX RANGE SCAN              | I_OBJAUTH1         |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*178 |                            FIXED TABLE FULL                | X$KZSRO            |      0 |      0 |00:00:00.01 |       0 |       |       |          |
| 179 |                            NESTED LOOPS                    |                    |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*180 |                             INDEX RANGE SCAN               | I_OBJ4             |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*181 |                             TABLE ACCESS CLUSTER           | USER$              |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*182 |                              INDEX UNIQUE SCAN             | I_USER#            |      0 |      0 |00:00:00.01 |       0 |       |       |          |
| 183 |                          NESTED LOOPS                      |                    |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*184 |                           INDEX RANGE SCAN                 | I_OBJ4             |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*185 |                           TABLE ACCESS CLUSTER             | USER$              |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*186 |                            INDEX UNIQUE SCAN               | I_USER#            |      0 |      0 |00:00:00.01 |       0 |       |       |          |
| 187 |                          NESTED LOOPS                      |                    |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*188 |                           INDEX RANGE SCAN                 | I_OBJ4             |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*189 |                           TABLE ACCESS CLUSTER             | USER$              |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*190 |                            INDEX UNIQUE SCAN               | I_USER#            |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*191 |                         FILTER                             |                    |      1 |      0 |00:00:00.01 |      93 |       |       |          |
| 192 |                          NESTED LOOPS                      |                    |      1 |      0 |00:00:00.01 |      93 |       |       |          |
| 193 |                           NESTED LOOPS                     |                    |      1 |      0 |00:00:00.01 |      93 |       |       |          |
| 194 |                            NESTED LOOPS                    |                    |      1 |      0 |00:00:00.01 |      93 |       |       |          |
| 195 |                             NESTED LOOPS                   |                    |      1 |      0 |00:00:00.01 |      93 |       |       |          |
| 196 |                              NESTED LOOPS                  |                    |      1 |     34 |00:00:00.01 |      85 |       |       |          |
| 197 |                               NESTED LOOPS                 |                    |      1 |     34 |00:00:00.01 |      47 |       |       |          |
| 198 |                                NESTED LOOPS                |                    |      1 |     34 |00:00:00.01 |       9 |       |       |          |
| 199 |                                 CONNECT BY PUMP            |                    |      1 |     34 |00:00:00.01 |       0 |       |       |          |
| 200 |                                 TABLE ACCESS BY INDEX ROWID| OBJ$               |     34 |     34 |00:00:00.01 |       9 |       |       |          |
|*201 |                                  INDEX RANGE SCAN          | I_OBJ1             |     34 |     34 |00:00:00.01 |       8 |       |       |          |
| 202 |                                TABLE ACCESS CLUSTER        | USER$              |     34 |     34 |00:00:00.01 |      38 |       |       |          |
|*203 |                                 INDEX UNIQUE SCAN          | I_USER#            |     34 |     34 |00:00:00.01 |       4 |       |       |          |
| 204 |                               TABLE ACCESS CLUSTER         | USER$              |     34 |     34 |00:00:00.01 |      38 |       |       |          |
|*205 |                                INDEX UNIQUE SCAN           | I_USER#            |     34 |     34 |00:00:00.01 |       4 |       |       |          |
| 206 |                              TABLE ACCESS BY INDEX ROWID   | SYN$               |     34 |      0 |00:00:00.01 |       8 |       |       |          |
|*207 |                               INDEX RANGE SCAN             | I_SYN2             |     34 |      0 |00:00:00.01 |       8 |       |       |          |
| 208 |                             TABLE ACCESS BY INDEX ROWID    | OBJ$               |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*209 |                              INDEX RANGE SCAN              | I_OBJ1             |      0 |      0 |00:00:00.01 |       0 |       |       |          |
| 210 |                            TABLE ACCESS CLUSTER            | USER$              |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*211 |                             INDEX UNIQUE SCAN              | I_USER#            |      0 |      0 |00:00:00.01 |       0 |       |       |          |
| 212 |                           TABLE ACCESS CLUSTER             | USER$              |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*213 |                            INDEX UNIQUE SCAN               | I_USER#            |      0 |      0 |00:00:00.01 |       0 |       |       |          |
| 214 |                          NESTED LOOPS                      |                    |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*215 |                           INDEX RANGE SCAN                 | I_OBJ4             |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*216 |                           TABLE ACCESS CLUSTER             | USER$              |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*217 |                            INDEX UNIQUE SCAN               | I_USER#            |      0 |      0 |00:00:00.01 |       0 |       |       |          |
| 218 |                          NESTED LOOPS                      |                    |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*219 |                           INDEX RANGE SCAN                 | I_OBJ4             |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*220 |                           TABLE ACCESS CLUSTER             | USER$              |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*221 |                            INDEX UNIQUE SCAN               | I_USER#            |      0 |      0 |00:00:00.01 |       0 |       |       |          |
| 222 |                    TABLE ACCESS BY INDEX ROWID             | USER$              |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*223 |                     INDEX UNIQUE SCAN                      | I_USER1            |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*224 |                   INDEX RANGE SCAN                         | I_OBJ2             |      0 |      0 |00:00:00.01 |       0 |       |       |          |
| 225 |                  TABLE ACCESS CLUSTER                      | ICOL$              |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*226 |                   INDEX UNIQUE SCAN                        | I_OBJ#             |      0 |      0 |00:00:00.01 |       0 |       |       |          |
| 227 |                 TABLE ACCESS CLUSTER                       | COL$               |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*228 |                TABLE ACCESS CLUSTER                        | ATTRCOL$           |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*229 |               INDEX RANGE SCAN                             | I_OBJ2             |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*230 |              TABLE ACCESS CLUSTER                          | IND$               |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*231 |               INDEX UNIQUE SCAN                            | I_OBJ#             |      0 |      0 |00:00:00.01 |       0 |       |       |          |
| 232 |             TABLE ACCESS CLUSTER                           | SEG$               |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*233 |              INDEX UNIQUE SCAN                             | I_FILE#_BLOCK#     |      0 |      0 |00:00:00.01 |       0 |       |       |          |
| 234 |            TABLE ACCESS CLUSTER                            | TS$                |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*235 |             INDEX UNIQUE SCAN                              | I_TS#              |      0 |      0 |00:00:00.01 |       0 |       |       |          |
| 236 |           TABLE ACCESS BY INDEX ROWID                      | OBJ$               |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*237 |            INDEX RANGE SCAN                                | I_OBJ1             |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*238 |          TABLE ACCESS BY INDEX ROWID                       | IND$               |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*239 |           INDEX UNIQUE SCAN                                | I_IND1             |      0 |      0 |00:00:00.01 |       0 |       |       |          |
| 240 |         TABLE ACCESS CLUSTER                               | USER$              |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*241 |          INDEX UNIQUE SCAN                                 | I_USER#            |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*242 |        TABLE ACCESS BY INDEX ROWID                         | OBJ$               |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*243 |         INDEX RANGE SCAN                                   | I_OBJ2             |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*244 |       INDEX RANGE SCAN                                     | I_OBJ1             |      0 |      0 |00:00:00.01 |       0 |       |       |          |
| 245 |      TABLE ACCESS CLUSTER                                  | USER$              |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*246 |       INDEX UNIQUE SCAN                                    | I_USER#            |      0 |      0 |00:00:00.01 |       0 |       |       |          |
| 247 |     NESTED LOOPS                                           |                    |      0 |      0 |00:00:00.01 |       0 |       |       |          |
| 248 |      FIXED TABLE FULL                                      | X$KZSRO            |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*249 |      INDEX RANGE SCAN                                      | I_OBJAUTH2         |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*250 |     FIXED TABLE FULL                                       | X$KZSPR            |      0 |      0 |00:00:00.01 |       0 |       |       |          |
| 251 |     NESTED LOOPS                                           |                    |      0 |      0 |00:00:00.01 |       0 |       |       |          |
| 252 |      FIXED TABLE FULL                                      | X$KZSRO            |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*253 |      INDEX RANGE SCAN                                      | I_OBJAUTH2         |      0 |      0 |00:00:00.01 |       0 |       |       |          |
|*254 |     FIXED TABLE FULL                                       | X$KZSPR            |      0 |      0 |00:00:00.01 |       0 |       |       |          |
-------------------------------------------------------------------------------------------------------------------------------------------------------------

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

   3 - filter(("O"."OWNER#"=USERENV('SCHEMAID') OR  IS NOT NULL OR  IS NOT NULL))
  13 - filter("KSPPI"."KSPPINM"='_dml_monitoring_enabled')
  14 - access("KSPPI"."INDX"="KSPPCV"."INDX")
       filter("KSPPI"."INDX"="KSPPCV"."INDX")
  16 - filter((BITAND("O"."FLAGS",128)=0 AND "O"."NAME"='PART'))
  17 - filter(BITAND("T"."PROPERTY",1)=0)
  18 - access("O"."OBJ#"="T"."OBJ#")
  20 - access("T"."TS#"="S"."TS#" AND "T"."FILE#"="S"."FILE#" AND "T"."BLOCK#"="S"."BLOCK#")
  22 - access("T"."TS#"="TS"."TS#")
  24 - access("O"."OWNER#"="U"."USER#")
  25 - access("T"."DATAOBJ#"="CX"."OBJ#")
  27 - access("CX"."OWNER#"="CU"."USER#")
  28 - access("T"."BOBJ#"="CO"."OBJ#")
  31 - access("GRANTEE#"="KZSROROL" AND "OA"."OBJ#"=:B1)
  32 - filter(("INST_ID"=USERENV('INSTANCE') AND ((-"KZSPRPRV")=(-45) OR (-"KZSPRPRV")=(-47) OR (-"KZSPRPRV")=(-48) OR (-"KZSPRPRV")=(-49) OR
              (-"KZSPRPRV")=(-50))))
  35 - access("TC"."OBJ#"=:B1 AND "TC"."INTCOL#"=:B2-1)
  36 - filter("TC"."INTCOL#"="AC"."INTCOL#")
  37 - filter((("IDX"."OWNER#"=USERENV('SCHEMAID') OR "BASE"."OWNER#"=USERENV('SCHEMAID') OR  IS NOT NULL OR  IS NOT NULL) AND
              ("IO"."OWNER#"=USERENV('SCHEMAID') OR  IS NOT NULL OR  IS NOT NULL)))
  54 - access("IU"."NAME"='CUSTAPP')
  55 - access("IO"."OWNER#"="IU"."USER#" AND "IO"."NAME"='PART' AND "IO"."TYPE#"=2)
       filter("IO"."TYPE#"=2)
  56 - filter((("I"."TYPE#"=1 OR "I"."TYPE#"=2 OR "I"."TYPE#"=3 OR "I"."TYPE#"=4 OR "I"."TYPE#"=6 OR "I"."TYPE#"=7 OR "I"."TYPE#"=9) AND
              BITAND("I"."FLAGS",4096)=0))
  57 - access("I"."BO#"="IO"."OBJ#")
  59 - access("I"."TS#"="S"."TS#" AND "I"."FILE#"="S"."FILE#" AND "I"."BLOCK#"="S"."BLOCK#")
  61 - access("I"."TS#"="TS"."TS#")
  62 - access("I"."INDMETHOD#"="ITO"."OBJ#")
  64 - access("ITO"."OWNER#"="ITU"."USER#")
  65 - filter(BITAND("O"."FLAGS",128)=0)
  66 - access("O"."OBJ#"="I"."OBJ#")
  68 - access("U"."USER#"="O"."OWNER#")
  69 - access("USER#"="IDX"."OWNER#" AND "O"."NAME"="IDX"."NAME")
  70 - filter(("I"."TYPE#"=1 OR "I"."TYPE#"=2 OR "I"."TYPE#"=3 OR "I"."TYPE#"=4 OR "I"."TYPE#"=6 OR "I"."TYPE#"=7 OR "I"."TYPE#"=9))
  71 - access("IDX"."OBJ#"="I"."OBJ#")
  73 - access("IC"."OBJ#"="IDX"."OBJ#")
  74 - filter("C"."INTCOL#"=DECODE(BITAND("I"."PROPERTY",1024),0,"IC"."INTCOL#","IC"."SPARE2"))
  75 - filter("C"."INTCOL#"="AC"."INTCOL#")
  76 - access("IC"."BO#"="BASE"."OBJ#")
  78 - access("BO"."USER#"="BASE"."OWNER#")
  81 - access("GRANTEE#"="KZSROROL" AND "OBJ#"=:B1)
  82 - filter(("INST_ID"=USERENV('INSTANCE') AND ((-"KZSPRPRV")=(-45) OR (-"KZSPRPRV")=(-47) OR (-"KZSPRPRV")=(-48) OR (-"KZSPRPRV")=(-49) OR
              (-"KZSPRPRV")=(-50))))
  85 - access("GRANTEE#"="KZSROROL" AND "OBJ#"=:B1)
  86 - filter(("INST_ID"=USERENV('INSTANCE') AND ((-"KZSPRPRV")=(-45) OR (-"KZSPRPRV")=(-47) OR (-"KZSPRPRV")=(-48) OR (-"KZSPRPRV")=(-49) OR
              (-"KZSPRPRV")=(-50))))
  89 - access("TC"."OBJ#"=:B1 AND "TC"."INTCOL#"=:B2-1)
  90 - filter("TC"."INTCOL#"="AC"."INTCOL#")
  91 - filter((("IDX"."OWNER#"=USERENV('SCHEMAID') OR "BASE"."OWNER#"=USERENV('SCHEMAID') OR  IS NOT NULL OR  IS NOT NULL) AND
              ("IO"."OWNER#"=USERENV('SCHEMAID') OR  IS NOT NULL OR  IS NOT NULL)))
 110 - filter((("O"."SPARE3"=USERENV('SCHEMAID') OR "O"."SPARE3"=1 OR ("S"."NODE" IS NULL AND  IS NOT NULL) OR  IS NOT NULL) AND (("O"."TYPE#"<>4
              AND "O"."TYPE#"<>5 AND "O"."TYPE#"<>7 AND "O"."TYPE#"<>8 AND "O"."TYPE#"<>9 AND "O"."TYPE#"<>10 AND "O"."TYPE#"<>11 AND "O"."TYPE#"<>12 AND
              "O"."TYPE#"<>13 AND "O"."TYPE#"<>14 AND "O"."TYPE#"<>22 AND "O"."TYPE#"<>87 AND "O"."TYPE#"<>88) OR BITAND("U"."SPARE1",16)=0 OR (("O"."TYPE#"=4 OR
              "O"."TYPE#"=5 OR "O"."TYPE#"=7 OR "O"."TYPE#"=8 OR "O"."TYPE#"=9 OR "O"."TYPE#"=10 OR "O"."TYPE#"=11 OR "O"."TYPE#"=12 OR "O"."TYPE#"=13 OR
              "O"."TYPE#"=14 OR "O"."TYPE#"=22 OR "O"."TYPE#"=87) AND (("U"."TYPE#"<>2 AND SYS_CONTEXT('userenv','current_edition_name')='ORA$BASE') OR
              ("U"."TYPE#"=2 AND "U"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition_id'))) OR  IS NOT NULL)))))
 115 - access("U"."NAME"='CUSTAPP')
 116 - access("O"."SPARE3"="U"."USER#" AND "O"."NAME"='PART' AND "O"."TYPE#"=5)
       filter("O"."TYPE#"=5)
 118 - access("O"."OBJ#"="S"."OBJ#")
 120 - access("O"."OWNER#"="U"."USER#")
 121 - filter(("INST_ID"=USERENV('INSTANCE') AND ((-"KZSPRPRV")=(-45) OR (-"KZSPRPRV")=(-47) OR (-"KZSPRPRV")=(-48) OR (-"KZSPRPRV")=(-49) OR
              (-"KZSPRPRV")=(-50))))
 122 - filter((( IS NOT NULL OR "BA"."GRANTOR#"=USERENV('SCHEMAID')) AND (("O"."TYPE#"<>4 AND "O"."TYPE#"<>5 AND "O"."TYPE#"<>7 AND "O"."TYPE#"<>8
              AND "O"."TYPE#"<>9 AND "O"."TYPE#"<>10 AND "O"."TYPE#"<>11 AND "O"."TYPE#"<>12 AND "O"."TYPE#"<>13 AND "O"."TYPE#"<>14 AND "O"."TYPE#"<>22 AND
              "O"."TYPE#"<>87 AND "O"."TYPE#"<>88) OR BITAND("U"."SPARE1",16)=0 OR (("O"."TYPE#"=4 OR "O"."TYPE#"=5 OR "O"."TYPE#"=7 OR "O"."TYPE#"=8 OR
              "O"."TYPE#"=9 OR "O"."TYPE#"=10 OR "O"."TYPE#"=11 OR "O"."TYPE#"=12 OR "O"."TYPE#"=13 OR "O"."TYPE#"=14 OR "O"."TYPE#"=22 OR "O"."TYPE#"=87) AND
              (("U"."TYPE#"<>2 AND SYS_CONTEXT('userenv','current_edition_name')='ORA$BASE') OR ("U"."TYPE#"=2 AND
              "U"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition_id'))) OR  IS NOT NULL)))))
 123 - filter(:B1 IS NULL)
 128 - access("BU"."NAME"=:B1)
 129 - access("BU"."USER#"="O"."SPARE3" AND "O"."NAME"=:B1)
 131 - access("O"."OWNER#"="U"."USER#")
 132 - access("BA"."OBJ#"="O"."OBJ#")
 133 - filter("KZSROROL"=:B1)
 135 - access("O2"."DATAOBJ#"=:B1 AND "O2"."TYPE#"=88)
 136 - filter(("U2"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition_id')) AND "U2"."TYPE#"=2))
 137 - access("O2"."OWNER#"="U2"."USER#")
 139 - access("O2"."DATAOBJ#"=:B1 AND "O2"."TYPE#"=88)
 140 - filter(("U2"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition_id')) AND "U2"."TYPE#"=2))
 141 - access("O2"."OWNER#"="U2"."USER#")
 142 - filter(("ST"."SYN_OWNER"='CUSTAPP' AND "ST"."SYN_NAME"='PART'))
 143 - access("S"."BASE_SYN_ID"=PRIOR NULL)
 144 - filter(( IS NOT NULL AND (("O"."TYPE#"<>4 AND "O"."TYPE#"<>5 AND "O"."TYPE#"<>7 AND "O"."TYPE#"<>8 AND "O"."TYPE#"<>9 AND "O"."TYPE#"<>10 AND
              "O"."TYPE#"<>11 AND "O"."TYPE#"<>12 AND "O"."TYPE#"<>13 AND "O"."TYPE#"<>14 AND "O"."TYPE#"<>22 AND "O"."TYPE#"<>87 AND "O"."TYPE#"<>88) OR
              BITAND("U"."SPARE1",16)=0 OR (("O"."TYPE#"=4 OR "O"."TYPE#"=5 OR "O"."TYPE#"=7 OR "O"."TYPE#"=8 OR "O"."TYPE#"=9 OR "O"."TYPE#"=10 OR "O"."TYPE#"=11
              OR "O"."TYPE#"=12 OR "O"."TYPE#"=13 OR "O"."TYPE#"=14 OR "O"."TYPE#"=22 OR "O"."TYPE#"=87) AND (("U"."TYPE#"<>2 AND
              SYS_CONTEXT('userenv','current_edition_name')='ORA$BASE') OR ("U"."TYPE#"=2 AND "U"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition_id')))
              OR  IS NOT NULL))) AND (("O"."TYPE#"<>4 AND "O"."TYPE#"<>5 AND "O"."TYPE#"<>7 AND "O"."TYPE#"<>8 AND "O"."TYPE#"<>9 AND "O"."TYPE#"<>10 AND
              "O"."TYPE#"<>11 AND "O"."TYPE#"<>12 AND "O"."TYPE#"<>13 AND "O"."TYPE#"<>14 AND "O"."TYPE#"<>22 AND "O"."TYPE#"<>87 AND "O"."TYPE#"<>88) OR
              BITAND("U"."SPARE1",16)=0 OR (("O"."TYPE#"=4 OR "O"."TYPE#"=5 OR "O"."TYPE#"=7 OR "O"."TYPE#"=8 OR "O"."TYPE#"=9 OR "O"."TYPE#"=10 OR "O"."TYPE#"=11
              OR "O"."TYPE#"=12 OR "O"."TYPE#"=13 OR "O"."TYPE#"=14 OR "O"."TYPE#"=22 OR "O"."TYPE#"=87) AND (("U"."TYPE#"<>2 AND
              SYS_CONTEXT('userenv','current_edition_name')='ORA$BASE') OR ("U"."TYPE#"=2 AND "U"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition_id')))
              OR  IS NOT NULL)))))
 152 - access("BU"."USER#"="O"."SPARE3" AND "O"."TYPE#"=5)
       filter("O"."TYPE#"=5)
 154 - access("O"."OWNER#"="U"."USER#")
 156 - access("S"."OWNER"="BU"."NAME" AND "S"."NAME"="O"."NAME")
 158 - access("S"."OBJ#"="O"."OBJ#")
 160 - access("O"."SPARE3"="U"."USER#")
 162 - access("O"."OWNER#"="U"."USER#")
 163 - filter((("S"."NODE" IS NULL AND  IS NOT NULL) OR  IS NOT NULL))
 165 - access("S"."OBJ#"=:B1)
 166 - filter(("INST_ID"=USERENV('INSTANCE') AND ((-"KZSPRPRV")=(-45) OR (-"KZSPRPRV")=(-47) OR (-"KZSPRPRV")=(-48) OR (-"KZSPRPRV")=(-49) OR
              (-"KZSPRPRV")=(-50))))
 167 - filter((( IS NOT NULL OR "BA"."GRANTOR#"=USERENV('SCHEMAID')) AND (("O"."TYPE#"<>4 AND "O"."TYPE#"<>5 AND "O"."TYPE#"<>7 AND "O"."TYPE#"<>8
              AND "O"."TYPE#"<>9 AND "O"."TYPE#"<>10 AND "O"."TYPE#"<>11 AND "O"."TYPE#"<>12 AND "O"."TYPE#"<>13 AND "O"."TYPE#"<>14 AND "O"."TYPE#"<>22 AND
              "O"."TYPE#"<>87 AND "O"."TYPE#"<>88) OR BITAND("U"."SPARE1",16)=0 OR (("O"."TYPE#"=4 OR "O"."TYPE#"=5 OR "O"."TYPE#"=7 OR "O"."TYPE#"=8 OR
              "O"."TYPE#"=9 OR "O"."TYPE#"=10 OR "O"."TYPE#"=11 OR "O"."TYPE#"=12 OR "O"."TYPE#"=13 OR "O"."TYPE#"=14 OR "O"."TYPE#"=22 OR "O"."TYPE#"=87) AND
              (("U"."TYPE#"<>2 AND SYS_CONTEXT('userenv','current_edition_name')='ORA$BASE') OR ("U"."TYPE#"=2 AND
              "U"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition_id'))) OR  IS NOT NULL)))))
 168 - filter(:B1 IS NULL)
 173 - access("BU"."NAME"=:B1)
 174 - access("BU"."USER#"="O"."SPARE3" AND "O"."NAME"=:B1)
 176 - access("O"."OWNER#"="U"."USER#")
 177 - access("BA"."OBJ#"="O"."OBJ#")
 178 - filter("KZSROROL"=:B1)
 180 - access("O2"."DATAOBJ#"=:B1 AND "O2"."TYPE#"=88)
 181 - filter(("U2"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition_id')) AND "U2"."TYPE#"=2))
 182 - access("O2"."OWNER#"="U2"."USER#")
 184 - access("O2"."DATAOBJ#"=:B1 AND "O2"."TYPE#"=88)
 185 - filter(("U2"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition_id')) AND "U2"."TYPE#"=2))
 186 - access("O2"."OWNER#"="U2"."USER#")
 188 - access("O2"."DATAOBJ#"=:B1 AND "O2"."TYPE#"=88)
 189 - filter(("U2"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition_id')) AND "U2"."TYPE#"=2))
 190 - access("O2"."OWNER#"="U2"."USER#")
 191 - filter(((("O"."TYPE#"<>4 AND "O"."TYPE#"<>5 AND "O"."TYPE#"<>7 AND "O"."TYPE#"<>8 AND "O"."TYPE#"<>9 AND "O"."TYPE#"<>10 AND "O"."TYPE#"<>11
              AND "O"."TYPE#"<>12 AND "O"."TYPE#"<>13 AND "O"."TYPE#"<>14 AND "O"."TYPE#"<>22 AND "O"."TYPE#"<>87 AND "O"."TYPE#"<>88) OR
              BITAND("U"."SPARE1",16)=0 OR (("O"."TYPE#"=4 OR "O"."TYPE#"=5 OR "O"."TYPE#"=7 OR "O"."TYPE#"=8 OR "O"."TYPE#"=9 OR "O"."TYPE#"=10 OR "O"."TYPE#"=11
              OR "O"."TYPE#"=12 OR "O"."TYPE#"=13 OR "O"."TYPE#"=14 OR "O"."TYPE#"=22 OR "O"."TYPE#"=87) AND (("U"."TYPE#"<>2 AND
              SYS_CONTEXT('userenv','current_edition_name')='ORA$BASE') OR ("U"."TYPE#"=2 AND "U"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition_id')))
              OR  IS NOT NULL))) AND (("O"."TYPE#"<>4 AND "O"."TYPE#"<>5 AND "O"."TYPE#"<>7 AND "O"."TYPE#"<>8 AND "O"."TYPE#"<>9 AND "O"."TYPE#"<>10 AND
              "O"."TYPE#"<>11 AND "O"."TYPE#"<>12 AND "O"."TYPE#"<>13 AND "O"."TYPE#"<>14 AND "O"."TYPE#"<>22 AND "O"."TYPE#"<>87 AND "O"."TYPE#"<>88) OR
              BITAND("U"."SPARE1",16)=0 OR (("O"."TYPE#"=4 OR "O"."TYPE#"=5 OR "O"."TYPE#"=7 OR "O"."TYPE#"=8 OR "O"."TYPE#"=9 OR "O"."TYPE#"=10 OR "O"."TYPE#"=11
              OR "O"."TYPE#"=12 OR "O"."TYPE#"=13 OR "O"."TYPE#"=14 OR "O"."TYPE#"=22 OR "O"."TYPE#"=87) AND (("U"."TYPE#"<>2 AND
              SYS_CONTEXT('userenv','current_edition_name')='ORA$BASE') OR ("U"."TYPE#"=2 AND "U"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition_id')))
              OR  IS NOT NULL)))))
 201 - access("connect$_by$_pump$_076"."prior s.syn_id "="O"."OBJ#" AND "O"."TYPE#"=5)
       filter("O"."TYPE#"=5)
 203 - access("BU"."USER#"="O"."SPARE3")
 205 - access("O"."OWNER#"="U"."USER#")
 207 - access("S"."OWNER"="BU"."NAME" AND "S"."NAME"="O"."NAME")
 209 - access("S"."OBJ#"="O"."OBJ#")
 211 - access("O"."SPARE3"="U"."USER#")
 213 - access("O"."OWNER#"="U"."USER#")
 215 - access("O2"."DATAOBJ#"=:B1 AND "O2"."TYPE#"=88)
 216 - filter(("U2"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition_id')) AND "U2"."TYPE#"=2))
 217 - access("O2"."OWNER#"="U2"."USER#")
 219 - access("O2"."DATAOBJ#"=:B1 AND "O2"."TYPE#"=88)
 220 - filter(("U2"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition_id')) AND "U2"."TYPE#"=2))
 221 - access("O2"."OWNER#"="U2"."USER#")
 223 - access("C"."TABLE_OWNER"="BO"."NAME")
 224 - access("BO"."USER#"="BASE"."OWNER#" AND "C"."TABLE_NAME"="BASE"."NAME")
 226 - access("IC"."BO#"="BASE"."OBJ#")
 228 - filter("C"."INTCOL#"="AC"."INTCOL#")
 229 - access("IO"."OWNER#"="USER#" AND "C"."TABLE_NAME"="IO"."NAME" AND "IO"."TYPE#"=2)
       filter("IO"."TYPE#"=2)
 230 - filter((("I"."TYPE#"=1 OR "I"."TYPE#"=2 OR "I"."TYPE#"=3 OR "I"."TYPE#"=4 OR "I"."TYPE#"=6 OR "I"."TYPE#"=7 OR "I"."TYPE#"=9) AND
              BITAND("I"."FLAGS",4096)=0))
 231 - access("I"."BO#"="IO"."OBJ#")
 233 - access("I"."TS#"="S"."TS#" AND "I"."FILE#"="S"."FILE#" AND "I"."BLOCK#"="S"."BLOCK#")
 235 - access("I"."TS#"="TS"."TS#")
 237 - access("IC"."OBJ#"="IDX"."OBJ#")
 238 - filter((("I"."TYPE#"=1 OR "I"."TYPE#"=2 OR "I"."TYPE#"=3 OR "I"."TYPE#"=4 OR "I"."TYPE#"=6 OR "I"."TYPE#"=7 OR "I"."TYPE#"=9) AND
              "C"."INTCOL#"=DECODE(BITAND("I"."PROPERTY",1024),0,"IC"."INTCOL#","IC"."SPARE2")))
 239 - access("IDX"."OBJ#"="I"."OBJ#")
 241 - access("USER#"="IDX"."OWNER#")
 242 - filter(BITAND("O"."FLAGS",128)=0)
 243 - access("U"."USER#"="O"."OWNER#" AND "O"."NAME"="IDX"."NAME" AND "O"."OBJ#"="I"."OBJ#")
       filter("O"."OBJ#"="I"."OBJ#")
 244 - access("I"."INDMETHOD#"="ITO"."OBJ#")
 246 - access("ITO"."OWNER#"="ITU"."USER#")
 249 - access("GRANTEE#"="KZSROROL" AND "OBJ#"=:B1)
 250 - filter(("INST_ID"=USERENV('INSTANCE') AND ((-"KZSPRPRV")=(-45) OR (-"KZSPRPRV")=(-47) OR (-"KZSPRPRV")=(-48) OR (-"KZSPRPRV")=(-49) OR
              (-"KZSPRPRV")=(-50))))
 253 - access("GRANTEE#"="KZSROROL" AND "OBJ#"=:B1)
 254 - filter(("INST_ID"=USERENV('INSTANCE') AND ((-"KZSPRPRV")=(-45) OR (-"KZSPRPRV")=(-47) OR (-"KZSPRPRV")=(-48) OR (-"KZSPRPRV")=(-49) OR
              (-"KZSPRPRV")=(-50))))

Note
-----
   - rule based optimizer used (consider using cbo) 

I seem to have forgotten the message of this blog article, was it about rules based optimization?  :-)





Brain Teaser: 10046 Extended SQL Trace Shows “EXEC #435118472:c=15600,e=510″, How is that Possible?

14 04 2011

April 14, 2011

I find interesting details from time to time about Oracle Database.  I am in the process of organizing material for a presentation, and I encountered something interesting when testing Oracle Database 11.2.0.2 with patch 3 applied.  I traced the execution of an application and then processed the 660MB  trace file using a trace file profiler that I created.  A portion of my trace file profiler’s output looks like this:

Statement Depth 0 (Application Code)
Cursor 27   Ver 1   Parse at 170.113677 SQL_ID='aw9mpsx4pyta2'  (TD Prev 25.179488)  Similar Cnt 1
|PARSEs       1|CPU S    0.000000|CLOCK S    0.000491|ROWs        0|PHY RD BLKs         0|CON RD BLKs (Mem)         0|CUR RD BLKs (Mem)         0|SHARED POOL MISs      1|
|EXECs    82848|CPU S   25.849376|CLOCK S   26.046921|ROWs    82848|PHY RD BLKs       560|CON RD BLKs (Mem)    248703|CUR RD BLKs (Mem)     84702|SHARED POOL MISs      1|
|FETCHs       0|CPU S    0.000000|CLOCK S    0.000000|ROWs        0|PHY RD BLKs         0|CON RD BLKs (Mem)         0|CUR RD BLKs (Mem)         0|SHARED POOL MISs      0|
  CPU S 20.68%  CLOCK S 20.47%
|                ++++||                ++++|
UPDATE REQUIREMENT SET REQUIRED_DATE = :1 WHERE WORKORDER_TYPE = :2 AND WORKORDER_BASE_ID = :3 AND WORKORDER_SUB_ID = :4
 AND WORKORDER_LOT_ID = :5 AND WORKORDER_SPLIT_ID = :6 AND OPERATION_SEQ_NO = :7 AND PIECE_NO = :8

       (Rows 0)   UPDATE  REQUIREMENT (cr=3 pr=2 pw=0 time=861 us)
       (Rows 1)    INDEX UNIQUE SCAN SYS_C0025561 (cr=3 pr=2 pw=0 time=754 us cost=2 size=33 card=1

The above output shows that this SQL statement, which was executed 82,848 times, consumed a total of 25.85 seconds of CPU time and 26.05 second for the elapsed time.  This SQL statement accounted for 20.68% of the total CPU consumption found in the trace file, and 20.47% of the total elapsed time found in the trace file.  The execution plan displayed is from the first execution of the SQL statement, which is output by default after the first execution starting with Oracle Database 11.1.  Since this SQL statement consumed twice as much CPU and elapsed time as the second highest consumer, I thought that I would take a look in the raw 10046 trace file to see what is happening.  Among other things, I was attempting to determine if there is a time consuming row-level trigger that is firing on each execution, which then caused another row-level trigger to fire.

Here is a portion of that trace file which shows two executions of the SQL statement:

PARSING IN CURSOR #435118472 len=219 dep=0 uid=70 oct=6 lid=70 tim=150927664059 hv=1230988610 ad='466efdfb8' sqlid='aw9mpsx4pyta2'
UPDATE REQUIREMENT SET REQUIRED_DATE = :1 WHERE WORKORDER_TYPE = :2 AND WORKORDER_BASE_ID = :3 AND WORKORDER_SUB_ID = :4
 AND WORKORDER_LOT_ID = :5 AND WORKORDER_SPLIT_ID = :6 AND OPERATION_SEQ_NO = :7 AND PIECE_NO = :8
END OF STMT
PARSE #435118472:c=0,e=491,p=0,cr=0,cu=0,mis=1,r=0,dep=0,og=1,plh=0,tim=150927664059
WAIT #435118472: nam='SQL*Net message to client' ela= 2 driver id=1413697536 #bytes=1 p3=0 obj#=-1 tim=150927664110
WAIT #435118472: nam='SQL*Net message from client' ela= 364 driver id=1413697536 #bytes=1 p3=0 obj#=-1 tim=150927664488
...
WAIT #435118472: nam='SQL*Net message to client' ela= 1 driver id=1413697536 #bytes=1 p3=0 obj#=81989 tim=150927704272
WAIT #435118472: nam='SQL*Net message from client' ela= 284 driver id=1413697536 #bytes=1 p3=0 obj#=81989 tim=150927704573
BINDS #435118472:
 Bind#0
  oacdty=96 mxl=32(16) mxlc=00 mal=00 scl=00 pre=00
  oacflg=01 fl2=1000000 frm=01 csi=178 siz=256 off=0
  kxsbbbfp=0532a410  bln=32  avl=16  flg=05
  value="2011-04-20-0:0:0"
 Bind#1
  oacdty=96 mxl=32(01) mxlc=00 mal=00 scl=00 pre=00
  oacflg=01 fl2=1000000 frm=01 csi=178 siz=0 off=32
  kxsbbbfp=0532a430  bln=32  avl=01  flg=01
  value="W"
 Bind#2
  oacdty=96 mxl=32(05) mxlc=00 mal=00 scl=00 pre=00
  oacflg=01 fl2=1000000 frm=01 csi=178 siz=0 off=64
  kxsbbbfp=0532a450  bln=32  avl=05  flg=01
  value="16750"
 Bind#3
  oacdty=96 mxl=32(03) mxlc=00 mal=00 scl=00 pre=00
  oacflg=01 fl2=1000000 frm=01 csi=178 siz=0 off=96
  kxsbbbfp=0532a470  bln=32  avl=03  flg=01
  value="200"
 Bind#4
  oacdty=96 mxl=32(01) mxlc=00 mal=00 scl=00 pre=00
  oacflg=01 fl2=1000000 frm=01 csi=178 siz=0 off=128
  kxsbbbfp=0532a490  bln=32  avl=01  flg=01
  value="1"
 Bind#5
  oacdty=96 mxl=32(01) mxlc=00 mal=00 scl=00 pre=00
  oacflg=01 fl2=1000000 frm=01 csi=178 siz=0 off=160
  kxsbbbfp=0532a4b0  bln=32  avl=01  flg=01
  value="0"
 Bind#6
  oacdty=96 mxl=32(02) mxlc=00 mal=00 scl=00 pre=00
  oacflg=01 fl2=1000000 frm=01 csi=178 siz=0 off=192
  kxsbbbfp=0532a4d0  bln=32  avl=02  flg=01
  value="20"
 Bind#7
  oacdty=96 mxl=32(02) mxlc=00 mal=00 scl=00 pre=00
  oacflg=01 fl2=1000000 frm=01 csi=178 siz=0 off=224
  kxsbbbfp=0532a4f0  bln=32  avl=02  flg=01
  value="30"
EXEC #435118472:c=0,e=300,p=0,cr=3,cu=1,mis=0,r=1,dep=0,og=1,plh=755874150,tim=150927704902
WAIT #435118472: nam='SQL*Net message to client' ela= 2 driver id=1413697536 #bytes=1 p3=0 obj#=81989 tim=150927704977
WAIT #435118472: nam='SQL*Net message from client' ela= 177 driver id=1413697536 #bytes=1 p3=0 obj#=81989 tim=150927705171
BINDS #435118472:
 Bind#0
  oacdty=96 mxl=32(16) mxlc=00 mal=00 scl=00 pre=00
  oacflg=01 fl2=1000000 frm=01 csi=178 siz=256 off=0
  kxsbbbfp=0532a410  bln=32  avl=16  flg=05
  value="2011-04-20-0:0:0"
 Bind#1
  oacdty=96 mxl=32(01) mxlc=00 mal=00 scl=00 pre=00
  oacflg=01 fl2=1000000 frm=01 csi=178 siz=0 off=32
  kxsbbbfp=0532a430  bln=32  avl=01  flg=01
  value="W"
...
 Bind#7
  oacdty=96 mxl=32(02) mxlc=00 mal=00 scl=00 pre=00
  oacflg=01 fl2=1000000 frm=01 csi=178 siz=0 off=224
  kxsbbbfp=0532a4f0  bln=32  avl=02  flg=01
  value="40"
EXEC #435118472:c=15600,e=510,p=0,cr=3,cu=1,mis=0,r=1,dep=0,og=1,plh=755874150,tim=150927705707
WAIT #435118472: nam='SQL*Net message to client' ela= 2 driver id=1413697536 #bytes=1 p3=0 obj#=81989 tim=150927705800
WAIT #435118472: nam='SQL*Net message from client' ela= 1217 driver id=1413697536 #bytes=1 p3=0 obj#=81989 tim=150927707038 

Looking at the above, you may see a couple of odd items.  First, the cursor number is not 27 as was indicated in my trace file profiler’s output – it is instead the huge number 435,118,472.  Tanel Poder provided an explanation of this change which was introduced in Oracle Database 11.2.0.2 here – that change initially caused a lot of problems for my trace file profiler which in hindsight made the silly assumption that no session would have more than 5,000 or 10,000 open cursors (which would thus result in cursors numbers below 10,000).

What I thought that the casual observer might find interesting is this line in the trace file:

EXEC #435118472:c=15600,e=510,p=0,cr=3,cu=1,mis=0,r=1,dep=0,og=1,plh=755874150,tim=150927705707

The above line indicates that the instance consumed 0.015600 seconds of CPU time in a 0.000510 second time period - a bit of an unusual feat to see the CPU consumption 30 times greater than the elapsed time considering that this SQL statement was not executed in parallel.  Is there a clue why this happened?  Take a look at the trace file line that shows the previous execution:

EXEC #435118472:c=0,e=300,p=0,cr=3,cu=1,mis=0,r=1,dep=0,og=1,plh=755874150,tim=150927704902 

This time the elapsed time is 300 / 0 times longer than the CPU time.  So now the brain teaser: if the CPU time is 30 times (15600 / 510) greater than the elapsed time, and then the elapsed time is infinitely (300 / 0) longer than the CPU time, how is it possible that the overall CPU time for this SQL statement is roughly the same as the overall elapsed time?  (On a side note, you might wonder if this could compound into odd time reporting errors if different SQL statements are executed in between the executions of this SQL statement.)

Just for fun, here is the TKPROF output for this SQL statement:

SQL ID: aw9mpsx4pyta2 Plan Hash: 755874150

UPDATE REQUIREMENT SET REQUIRED_DATE = :1
WHERE
 WORKORDER_TYPE = :2 AND WORKORDER_BASE_ID = :3 AND WORKORDER_SUB_ID = :4 AND
  WORKORDER_LOT_ID = :5 AND WORKORDER_SPLIT_ID = :6 AND OPERATION_SEQ_NO = :7
  AND PIECE_NO = :8

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.00       0.00          0          0          0           0
Execute  82848     25.84      26.04        556     248550      84702       82848
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total    82849     25.84      26.04        556     248550      84702       82848

Misses in library cache during parse: 1
Misses in library cache during execute: 1
Optimizer mode: ALL_ROWS
Parsing user id: 70 
Number of plan statistics captured: 1

Rows (1st) Rows (avg) Rows (max)  Row Source Operation
---------- ---------- ----------  ---------------------------------------------------
         0          0          0  UPDATE  REQUIREMENT (cr=3 pr=2 pw=0 time=861 us)
         1          1          1   INDEX UNIQUE SCAN SYS_C0025561 (cr=3 pr=2 pw=0 time=754 us cost=2 size=33 card=1)(object id 81989)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                   82849        0.00          0.10
  SQL*Net message from client                 82849        0.00         19.33
  db file sequential read                        95        0.00          0.03
  db file scattered read                         95        0.00          0.04 




Oracle Database Time Model Viewer in Excel 5

16 03 2011

March 16, 2011 (Updated August 11, 2011)

(Back to the Previous Post in the Series) (Forward to the Next Post in the Series)

In the previous articles in this series we looked at ways to analyze the Oracle time model data at the system-wide level with drill-down into the session level detail, with cross references to a handful of statistics found in V$OSSTAT and V$SYSSTAT, and the system-wide wait events with drill-down into the session level wait event detail.  There is a chance that some of the statistics might appear to be inconsistent between the various performance views, or possibly even between the start of the retrieval of the rows from a single performance view and the retrieval of the final row from the query of that performance view.  You might even find in some cases, with some combinations of operating system platform and Oracle release version that the statistics in V$OSSTAT might not be in the unit of measure described in the Oracle Database documentation – a recent thread on the OTN forums contains an example of such a case (I completely overlooked the inconsistency that was pointed out in that thread).  Is there a reason for the inconsistency?  A quick browse through Metalink (MOS) finds the following articles:

Bug 7430365: INCORRECT VALUES FOR USER_TIME IN V$OSSTAT (3.79 hours per CPU per elapsed hour)
Bug 3574504: INCORRECT STATISTICS IN V$OSSTAT IN HP-UX
Bug 5933195: NUM_CPUS VALUE IN V$OSSTAT IS WRONG
Bug 5639749: CPU_COUNT NOT SHOWN PROPERLY FROM THE DATABASE
Bug 10427553: HOW DOES V$OSSTAT GET IT’S INFORMATION ON AIX
Bug 9228541: CPU TIME REPORTED INCORRECTLY IN V$SYSMETRIC_HISTORY (3.75 hours per CPU per elapsed hour)
Doc ID 889396.1: Very large value for OS_CPU_WAIT_TIME FROM V$OSSTAT / AWR Report
Bug 7447648: OS_CPU_WAIT_TIME VALUE FROM V$OSSTAT IS INCORRECT

At the end of the previous article, we had produced a demonstration project that generated screen output similar to the following (note that the project code as of the end of part four in the series may be downloaded by using the link at the end of the fourth article):

Let’s continue adding features to the project.  We will start by adding three new CommandButtons to the UserForm with the (Name) property set to the following (one name per CommandButton): cmdTraceSession, cmdStopTrace, and cmdShowExecutionPlan.  Assign useful titles to the CommandButtons by setting appropriate values for the Caption property – due to limited available space on the UserForm I selected the Captions: Trace, Stop Trace, and XPLAN.  The UserForm in my sample project currently appears as shown in the following screen capture:

Next, we need to add a little more code to the Initialize event of the UserForm to add the SQL statements that will allow the CommandButtons to function.  Double-click in the background area of the UserForm to display the Initialize event code for the UserForm.

Scroll down through the code until you find the following comment section:

    'More code will be copied here
    '
    '
    '

Add a couple of blank lines above that comment section and paste in the following code:

    Set snpSQLStats = New ADODB.Recordset
    Set comSQLStats = New ADODB.Command

    With comTrace
        strSQL = "DBMS_MONITOR.SESSION_TRACE_ENABLE(?,?,TRUE,TRUE)"

        .CommandText = strSQL
        .CommandType = adCmdStoredProc
        .ActiveConnection = dbDatabase
    End With

    With comXPLAN
        strSQL = "SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY_CURSOR( ?, ?, 'TYPICAL +PEEKED_BINDS'))"

        'Add the bind variables
        .Parameters.Append .CreateParameter("sqlid", adVarChar, adParamInput, 40, "")
        .Parameters.Append .CreateParameter("childnumber", adNumeric, adParamInput, 8, 0)

        .CommandText = strSQL
        .CommandType = adCmdText
        .CommandTimeout = 30
        .ActiveConnection = dbDatabase
    End With 

    With comSQLChildReason
        strSQL = "SELECT" & vbCrLf
        strSQL = strSQL & "  SSC.*" & vbCrLf
        strSQL = strSQL & "FROM" & vbCrLf
        strSQL = strSQL & "  V$SQL_SHARED_CURSOR SSC" & vbCrLf
        strSQL = strSQL & "WHERE" & vbCrLf
        strSQL = strSQL & "  SSC.SQL_ID= ?" & vbCrLf
        strSQL = strSQL & "  AND SSC.CHILD_NUMBER= ?" & vbCrLf

        'Set up the command properties
        .CommandText = strSQL
        .CommandType = adCmdText
        .CommandTimeout = 30

        .ActiveConnection = dbDatabase

        'Add the bind variables
        .Parameters.Append .CreateParameter("sqlid", adVarChar, adParamInput, 40, "")
        .Parameters.Append .CreateParameter("childnumber", adNumeric, adParamInput, 8, 0)
    End With

    With comSQLChildBind
        strSQL = "SELECT" & vbCrLf
        strSQL = strSQL & "  SBM.POSITION," & vbCrLf
        strSQL = strSQL & "  SBM.DATATYPE," & vbCrLf
        strSQL = strSQL & "  SBM.MAX_LENGTH," & vbCrLf
        strSQL = strSQL & "  SBM.BIND_NAME" & vbCrLf
        strSQL = strSQL & "FROM" & vbCrLf
        strSQL = strSQL & "  V$SQL S," & vbCrLf
        strSQL = strSQL & "  V$SQL_BIND_METADATA SBM" & vbCrLf
        strSQL = strSQL & "WHERE" & vbCrLf
        strSQL = strSQL & "  S.SQL_ID= ?" & vbCrLf
        strSQL = strSQL & "  AND S.CHILD_NUMBER= ?" & vbCrLf
        strSQL = strSQL & "  AND S.CHILD_ADDRESS=SBM.ADDRESS" & vbCrLf
        strSQL = strSQL & "ORDER BY" & vbCrLf
        strSQL = strSQL & "  SBM.POSITION" & vbCrLf

        'Set up the command properties
        .CommandText = strSQL
        .CommandType = adCmdText
        .CommandTimeout = 30

        .ActiveConnection = dbDatabase

        'Add the bind variables
        .Parameters.Append .CreateParameter("sqlid", adVarChar, adParamInput, 40, "")
        .Parameters.Append .CreateParameter("childnumber", adNumeric, adParamInput, 8, 0)
    End With

    Set snpSQLStats = New ADODB.Recordset
    Set comSQLStats = New ADODB.Command

    With comSQLStats
        strSQL = "SELECT" & vbCrLf
        strSQL = strSQL & "  LAST_ACTIVE_TIME," & vbCrLf
        strSQL = strSQL & "  PARSE_CALLS," & vbCrLf
        strSQL = strSQL & "  EXECUTIONS," & vbCrLf
        strSQL = strSQL & "  CPU_TIME," & vbCrLf
        strSQL = strSQL & "  ELAPSED_TIME," & vbCrLf
        strSQL = strSQL & "  APPLICATION_WAIT_TIME," & vbCrLf
        strSQL = strSQL & "  CONCURRENCY_WAIT_TIME," & vbCrLf
        strSQL = strSQL & "  CLUSTER_WAIT_TIME," & vbCrLf
        strSQL = strSQL & "  USER_IO_WAIT_TIME," & vbCrLf
        strSQL = strSQL & "  PLSQL_EXEC_TIME," & vbCrLf
        strSQL = strSQL & "  JAVA_EXEC_TIME," & vbCrLf
        strSQL = strSQL & "  BUFFER_GETS," & vbCrLf
        strSQL = strSQL & "  DISK_READS," & vbCrLf
        strSQL = strSQL & "  DIRECT_WRITES," & vbCrLf
        strSQL = strSQL & "  ROWS_PROCESSED," & vbCrLf
        strSQL = strSQL & "  FETCHES," & vbCrLf
        strSQL = strSQL & "  LOADS," & vbCrLf
        strSQL = strSQL & "  INVALIDATIONS" & vbCrLf
        strSQL = strSQL & "FROM" & vbCrLf
        strSQL = strSQL & "  V$SQLSTATS" & vbCrLf
        strSQL = strSQL & "WHERE" & vbCrLf
        strSQL = strSQL & "  SQL_ID= ?" & vbCrLf
        strSQL = strSQL & "  AND PLAN_HASH_VALUE= ?"
        'Set up the command properties
        .CommandText = strSQL
        .CommandType = adCmdText
        .CommandTimeout = 30

        .ActiveConnection = dbDatabase

        'Add the bind variables
        .Parameters.Append .CreateParameter("sqlid", adVarChar, adParamInput, 40, "")
        .Parameters.Append .CreateParameter("plan_hash_value", adNumeric, adParamInput, 8, 0)
    End With

In the above, you might have noticed that I neglected to set up the two bind variables for the comTrace object (an object of type ADODB.Command), while I did set up the two bind variables for the comXPLAN object.  The reason for this omission is that in previous testing I simply could not make the SQL code execute with bind variables, so I cheated a bit, and will simply replace the CommandText property value for the comTrace object with hardcoded values for the session’s SID and SERIAL# when the cmdTraceSession CommandButton is clicked.

View the UserForm again (find frmTimeModel under the Forms heading, right-click the UserForm’s name, and select View Object).  Then double-click the cmdTraceSession CommandButton to show the Click event for that object.  Change the Click event so that it includes the following code:

Private Sub cmdTraceSession_Click()
    Dim i As Integer
    Dim intSessionTrace As Integer
    Dim strSQL As String

    If intCurrentSessionIndex > -1 Then
        strSQL = "DBMS_MONITOR.SESSION_TRACE_ENABLE(" & Format(lngSID(intCurrentSessionIndex)) & "," & Format(lngSerial(intCurrentSessionIndex)) & " ,TRUE,TRUE)"
        comTrace.CommandText = strSQL
        comTrace.Execute
    End If

    'Remember that we enabled trace for this session
    intSessionTrace = 0
    For i = 1 To 1000
        If SessionTrace(i).lngSID = lngSID(intCurrentSessionIndex) Then
            intSessionTrace = i
            Exit For
        End If
    Next i
    If intSessionTrace = 0 Then
        'Find an unused entry
        For i = 1 To 1000
            If SessionTrace(i).lngSID = 0 Then
                intSessionTrace = i
                SessionTrace(i).lngSID = lngSID(intCurrentSessionIndex)
                SessionTrace(i).lngSerial = lngSerial(intCurrentSessionIndex)
                Exit For
            End If
        Next i
    End If
    SessionTrace(intSessionTrace).int10046Level = 12
    cmdStopTrace.Enabled = True
    cmdTraceSession.Enabled = False
    tvTimeModel.SetFocus 
End Sub

If you examine the code, you will see that we use the intCurrentSessionIndex variable’s value to know which session is the session of interest, and then set the SessionTrace object’s int10046Level property to 12 to indicate that we have enabled a level 12 trace for the session (this allows us to remember which sessions are being traced).  But, we have a couple of problems: the intCurrentSessionIndex variable has a default value of 0 and so far we have not added code to assign a value to that variable; secondly, the SessionTrace object simply does not exist.  Adding the SessionTrace object is easy, so we will start there.  Scroll all the way up to the top of the project’s code and add the following code above everything else:

Private Type TraceDefinition
    lngSID As Long
    lngSerial As Long
    int10046Level As Integer
    int10053Level As Integer
    int10032Level As Integer
    int10033Level As Integer
    int10104Level As Integer
End Type

Dim SessionTrace(1000) As TraceDefinition

The first of the above sections creates the definition of the object type TraceDefinition which is simply composed of seven variables.

While in that section of the project code, add a couple of more variable declarations that will be used later (first scroll down to where you see similar variable declarations):

Dim snpSQLStats As ADODB.Recordset          'ADO recordset object used to retrieve the statistics for the execution plan
Dim comSQLStats As ADODB.Command            'ADO command object used to retrieve the statistics for the execution plan

The second section (beginning with the word Dim) creates an array of 1,000 (actually 1,001) objects of type TraceDefinition.

Now for the hard part – how do we know which session is the current session – the one that is currently highlighted in the TreeView control?  The key to this is in how we named the TreeView rows (by setting the Key property) as the rows were added in the UpdateDisplay subroutine.  Each row that contains session-level detail has a Key property that begins with the value SESSION, so we are able to easily determine when a session-level detail row is clicked.  Also part of the Key property is an underscore ( _ ) character that acts as a field delimiter between the rest of the name and a sequential number that points to additional information about that session.  View the UserForm object again and double-click the TreeView control.  Switch to the NodeClick event for the TreeView control (in the drop-down list at the right of the code window) and change the NodeClick event’s code to show the following:

Private Sub tvTimeModel_NodeClick(ByVal Node As MSComctlLib.Node)
    Dim i As Integer
    Dim intSessionTrace As Integer

    If Left(Node.Key, 7) = "SESSION" Then
        intCurrentSessionIndex = Right(Node.Key, Len(Node.Key) - InStr(Node.Key, "_"))

        intSessionTrace = 0
        For i = 1 To 1000
            If (SessionTrace(i).lngSID = lngSID(intCurrentSessionIndex)) And (SessionTrace(i).lngSerial = lngSerial(intCurrentSessionIndex)) Then
                intSessionTrace = i
                Exit For
            End If
        Next i
        If intSessionTrace > 0 Then
            If SessionTrace(intSessionTrace).int10046Level > 0 Then
                cmdTraceSession.Enabled = False
                cmdStopTrace.Enabled = True
            Else
                cmdTraceSession.Enabled = True
                cmdStopTrace.Enabled = False
            End If
        Else
            cmdTraceSession.Enabled = True
            cmdStopTrace.Enabled = False
        End If
        If strSQLID(intCurrentSessionIndex) <> "" Then
            cmdShowExecutionPlan.Enabled = True
        Else
            cmdShowExecutionPlan.Enabled = False
        End If
    Else
        intCurrentSessionIndex = -1
        cmdTraceSession.Enabled = False
        cmdStopTrace.Enabled = False
        cmdShowExecutionPlan.Enabled = False
    End If
End Sub

Easy to understand so far?  Let’s add the code to the cmdStopTrace CommandButton.  View the UserForm and then double-click the cmdStopTrace CommandButton.  Change the Click event’s code to show the following:

Private Sub cmdStopTrace_Click()
    Dim i As Integer
    Dim intSessionTrace As Integer
    Dim strSQL As String

    If intCurrentSessionIndex > -1 Then
        strSQL = "DBMS_MONITOR.SESSION_TRACE_DISABLE(" & Format(lngSID(intCurrentSessionIndex)) & "," & Format(lngSerial(intCurrentSessionIndex)) & ")"
        comTrace.CommandText = strSQL
        comTrace.Execute

        'Remember that we disabled trace for this session
        intSessionTrace = 0
        For i = 1 To 1000
            If SessionTrace(i).lngSID = lngSID(intCurrentSessionIndex) Then
                intSessionTrace = i
                Exit For
            End If
        Next i
        If intSessionTrace <> 0 Then
            SessionTrace(intSessionTrace).int10046Level = 0
            If (SessionTrace(intSessionTrace).int10032Level = 0) _
              And (SessionTrace(intSessionTrace).int10033Level = 0) _
              And (SessionTrace(intSessionTrace).int10046Level = 0) _
              And (SessionTrace(intSessionTrace).int10053Level = 0) _
              And (SessionTrace(intSessionTrace).int10104Level = 0) Then
                'Forget this trace entry
                SessionTrace(intSessionTrace).lngSID = 0
                SessionTrace(intSessionTrace).lngSerial = 0
            End If
        End If
        cmdStopTrace.Enabled = False
        cmdTraceSession.Enabled = True
    End If
    tvTimeModel.SetFocus
End Sub

You might notice that the code to stop the trace for a session is very similar to the code to start the trace.

The code for the cmdShowExecutionPlan CommandButton could be quite tame, as it was in the original Time Model Viewer project, but that would be a bit boring.  Let’s do something a little special.  First, view the UserForm object and then double-click the cmdShowExecutionPlan CommandButton.  Change the Click event for the CommandButton to show the following:

Private Sub cmdShowExecutionPlan_Click()
    Dim strOut As String
    Dim strSQLSQLID As String
    Dim intSQLChildNumber As Integer
    Dim intFileNum As Integer
    Dim intFlag As Integer
    Dim j As Integer

    On Error Resume Next

    tvTimeModel.SetFocus
    If intCurrentSessionIndex > -1 Then
        strSQLSQLID = Left(strSQLID(intCurrentSessionIndex), InStr(strSQLID(intCurrentSessionIndex), "/") - 1)
        intSQLChildNumber = Val(Right(strSQLID(intCurrentSessionIndex), Len(strSQLID(intCurrentSessionIndex)) - InStr(strSQLID(intCurrentSessionIndex), "/")))

        comXPLAN("sqlid") = strSQLSQLID
        comXPLAN("childnumber") = Null
        'If you only want the plan for the current SQL statement, uncomment the following
        'comXPLAN("childnumber") = intSQLChildNumber

        Set snpXPLAN = comXPLAN.Execute
        If Not (snpXPLAN Is Nothing) Then
            If snpXPLAN.State = 1 Then
                'Create the directory if it does not already exist
                If Len(Dir("C:\ExcelTimeModelViewer", vbDirectory)) < 5 Then
                    MkDir "C:\ExcelTimeModelViewer"
                End If

                intFileNum = FreeFile
                Open "C:\ExcelTimeModelViewer\DBMS_XPLAN.txt" For Output As #intFileNum

                If snpXPLAN.EOF = True Then
                    strOut = "No Execution Plans for SQL ID " & strSQLSQLID
                Else
                    strOut = ""
                End If
                Do While Not snpXPLAN.EOF
                    If (Left(snpXPLAN(0), 7) = "SQL_ID ") And (InStr(LCase(snpXPLAN(0)), "child number ") > 1) And (InStr(LCase(snpXPLAN(0)), "cannot be found") = 0) Then
                        If intFlag = True Then
                            strOut = strOut & String(100, "~") & vbCrLf
                            strOut = strOut & "" & vbCrLf
                            intFlag = False
                        End If
                        strOut = strOut & String(100, "*") & vbCrLf
                        comSQLChildReason("sqlid") = strSQLSQLID
                        comSQLChildReason("childnumber") = CInt(Right(snpXPLAN(0), Len(snpXPLAN(0)) - (InStr(snpXPLAN(0), "child number ") + 12)))
                        Set snpSQLChildReason = comSQLChildReason.Execute

                        If Not (snpSQLChildReason Is Nothing) Then
                            If snpSQLChildReason.State = 1 Then
                                If Not (snpSQLChildReason.EOF) Then
                                    strOut = strOut & "Reason for Child Cursor Creation" & vbCrLf
                                    For j = 4 To snpSQLChildReason.Fields.Count - 1
                                        If snpSQLChildReason(j) = "Y" Then
                                            strOut = strOut & snpSQLChildReason.Fields(j).Name & "" & vbCrLf
                                        End If
                                    Next j
                                    strOut = strOut & "**********" & vbCrLf
                                End If
                                snpSQLChildReason.Close
                            End If
                        End If

                        comSQLChildBind("sqlid") = strSQLSQLID
                        comSQLChildBind("childnumber") = CInt(Right(snpXPLAN(0), Len(snpXPLAN(0)) - (InStr(snpXPLAN(0), "child number ") + 12)))
                        Set snpSQLChildBind = comSQLChildBind.Execute

                        If Not (snpSQLChildBind Is Nothing) Then
                            If snpSQLChildBind.State = 1 Then
                                If Not (snpSQLChildBind.EOF) Then
                                    strOut = strOut & "Bind Variable Definitions" & vbCrLf
                                    Do While Not (snpSQLChildBind.EOF)
                                        strOut = strOut & "  Position:" & CStr(snpSQLChildBind("position"))
                                        strOut = strOut & "  Max Length:" & CStr(snpSQLChildBind("max_length"))
                                        Select Case snpSQLChildBind("datatype")
                                          Case 1
                                              strOut = strOut & "  VARCHAR2"
                                          Case 2
                                              strOut = strOut & "  NUMBER"
                                          Case 8
                                              strOut = strOut & "  LONG"
                                          Case 11
                                              strOut = strOut & "  ROWID"
                                          Case 12
                                              strOut = strOut & "  DATE"
                                          Case 23
                                              strOut = strOut & "  RAW"
                                          Case 24
                                              strOut = strOut & "  LONG RAW"
                                          Case 96
                                              strOut = strOut & "  CHAR"
                                          Case 112
                                              strOut = strOut & "  CLOB"
                                          Case 113
                                              strOut = strOut & "  BLOB"
                                          Case 114
                                              strOut = strOut & "  BFILE"
                                          Case Else
                                              strOut = strOut & "  TYPE " & CStr(snpSQLChildBind("datatype"))
                                        End Select
                                        strOut = strOut & "  Name:" & snpSQLChildBind("bind_name")
                                        strOut = strOut & "" & vbCrLf

                                        snpSQLChildBind.MoveNext
                                    Loop
                                    strOut = strOut & "**********" & vbCrLf
                                End If
                                snpSQLChildBind.Close
                            End If
                        End If
                    End If

                    If InStr(UCase(snpXPLAN(0)), "PLAN HASH VALUE:") = 1 Then
                        'Found the PLAN_HASH_VALUE
                        comSQLStats("sqlid") = strSQLSQLID
                        comSQLStats("plan_hash_value") = Val(Right(snpXPLAN(0), Len(snpXPLAN(0)) - InStr(snpXPLAN(0), ":")))
                        Set snpSQLStats = comSQLStats.Execute

                        If Not (snpSQLStats Is Nothing) Then
                            If snpSQLStats.State = 1 Then
                                If Not (snpSQLStats.EOF) Then
                                    If snpSQLStats("executions") > 0 Then
                                        strOut = strOut & "" & vbCrLf
                                        strOut = strOut & "Statistics for Execution Plan:" & vbCrLf
                                        strOut = strOut & "  Last Active: " & snpSQLStats("last_active_time") & vbCrLf
                                        strOut = strOut & "  Parses:                " & Format(Format(snpSQLStats("parse_calls"), "#,##0   "), "@@@@@@@@@@@@@@") & vbCrLf
                                        strOut = strOut & "  Executions:            " & Format(Format(snpSQLStats("executions"), "#,##0   "), "@@@@@@@@@@@@@@") _
                                            & "    Exec Per Parse: " & Format(Format(snpSQLStats("executions") / snpSQLStats("parse_calls"), "#,##0.00"), "@@@@@@@@@@@@@@") & vbCrLf
                                        strOut = strOut & "  CPU Time:              " & Format(Format(snpSQLStats("cpu_time") / 1000000, "#,##0.00"), "@@@@@@@@@@@@@@") _
                                            & "    Per Exec:       " & Format(Format(snpSQLStats("cpu_time") / snpSQLStats("executions") / 1000000, "#,##0.00"), "@@@@@@@@@@@@@@") & vbCrLf
                                        strOut = strOut & "  Elapsed Time:          " & Format(Format(snpSQLStats("elapsed_time") / 1000000, "#,##0.00"), "@@@@@@@@@@@@@@") _
                                            & "    Per Exec:       " & Format(Format(snpSQLStats("elapsed_time") / snpSQLStats("executions") / 1000000, "#,##0.00"), "@@@@@@@@@@@@@@") & vbCrLf
                                        strOut = strOut & "  Application Wait Time: " & Format(Format(snpSQLStats("application_wait_time") / 1000000, "#,##0.00"), "@@@@@@@@@@@@@@") _
                                            & "    Per Exec:       " & Format(Format(snpSQLStats("application_wait_time") / snpSQLStats("executions") / 1000000, "#,##0.00"), "@@@@@@@@@@@@@@") & vbCrLf
                                        strOut = strOut & "  Concurrency Wait Time: " & Format(Format(snpSQLStats("concurrency_wait_time") / 1000000, "#,##0.00"), "@@@@@@@@@@@@@@") _
                                            & "    Per Exec:       " & Format(Format(snpSQLStats("concurrency_wait_time") / snpSQLStats("executions") / 1000000, "#,##0.00"), "@@@@@@@@@@@@@@") & vbCrLf
                                        strOut = strOut & "  User IO Wait Time:     " & Format(Format(snpSQLStats("user_io_wait_time") / 1000000, "#,##0.00"), "@@@@@@@@@@@@@@") _
                                            & "    Per Exec:       " & Format(Format(snpSQLStats("user_io_wait_time") / snpSQLStats("executions") / 1000000, "#,##0.00"), "@@@@@@@@@@@@@@") & vbCrLf
                                        strOut = strOut & "  Application Wait Time: " & Format(Format(snpSQLStats("application_wait_time") / 1000000, "#,##0.00"), "@@@@@@@@@@@@@@") _
                                            & "    Per Exec:       " & Format(Format(snpSQLStats("application_wait_time") / snpSQLStats("executions"), "#,##0.00"), "@@@@@@@@@@@@@@") & vbCrLf
                                        strOut = strOut & "  Cluster Wait Time:     " & Format(Format(snpSQLStats("cluster_wait_time") / 1000000, "#,##0.00"), "@@@@@@@@@@@@@@") _
                                            & "    Per Exec:       " & Format(Format(snpSQLStats("cluster_wait_time") / snpSQLStats("executions"), "#,##0.00"), "@@@@@@@@@@@@@@") & vbCrLf
                                        strOut = strOut & "  PL/SQL Execute Time:   " & Format(Format(snpSQLStats("plsql_exec_time") / 1000000, "#,##0.00"), "@@@@@@@@@@@@@@") _
                                            & "    Per Exec:       " & Format(Format(snpSQLStats("plsql_exec_time") / snpSQLStats("executions") / 1000000, "#,##0.00"), "@@@@@@@@@@@@@@") & vbCrLf
                                        strOut = strOut & "  Java Execution Time:   " & Format(Format(snpSQLStats("java_exec_time") / 1000000, "#,##0.00"), "@@@@@@@@@@@@@@") _
                                            & "    Per Exec:       " & Format(Format(snpSQLStats("java_exec_time") / snpSQLStats("executions") / 1000000, "#,##0.00"), "@@@@@@@@@@@@@@") & vbCrLf
                                        strOut = strOut & "  Buffer (Cons.) Gets:   " & Format(Format(snpSQLStats("buffer_gets"), "#,##0   "), "@@@@@@@@@@@@@@") _
                                            & "    Per Exec:       " & Format(Format(snpSQLStats("buffer_gets") / snpSQLStats("executions"), "#,##0.00"), "@@@@@@@@@@@@@@") & vbCrLf
                                        strOut = strOut & "  Disk (Block) Reads:    " & Format(Format(snpSQLStats("disk_reads"), "#,##0   "), "@@@@@@@@@@@@@@") _
                                            & "    Per Exec:       " & Format(Format(snpSQLStats("disk_reads") / snpSQLStats("executions"), "#,##0.00"), "@@@@@@@@@@@@@@") & vbCrLf
                                        strOut = strOut & "  Direct Writes:         " & Format(Format(snpSQLStats("direct_writes"), "#,##0   "), "@@@@@@@@@@@@@@") _
                                            & "    Per Exec:       " & Format(Format(snpSQLStats("direct_writes") / snpSQLStats("executions"), "#,##0.00"), "@@@@@@@@@@@@@@") & vbCrLf
                                        strOut = strOut & "  Rows Processed:        " & Format(Format(snpSQLStats("rows_processed"), "#,##0   "), "@@@@@@@@@@@@@@") _
                                            & "    Per Exec:       " & Format(Format(snpSQLStats("rows_processed") / snpSQLStats("executions"), "#,##0.00"), "@@@@@@@@@@@@@@") & vbCrLf
                                        strOut = strOut & "  Fetches:               " & Format(Format(snpSQLStats("fetches"), "#,##0   "), "@@@@@@@@@@@@@@") _
                                            & "    Per Exec:       " & Format(Format(snpSQLStats("fetches") / snpSQLStats("executions"), "#,##0.00"), "@@@@@@@@@@@@@@") & vbCrLf
                                        strOut = strOut & "  Loads:                 " & Format(Format(snpSQLStats("loads"), "#,##0   "), "@@@@@@@@@@@@@@") _
                                            & "    Per Exec:       " & Format(Format(snpSQLStats("loads") / snpSQLStats("executions"), "#,##0.00"), "@@@@@@@@@@@@@@") & vbCrLf
                                        strOut = strOut & "  Invalidations:         " & Format(Format(snpSQLStats("invalidations"), "#,##0   "), "@@@@@@@@@@@@@@") _
                                            & "    Per Exec:       " & Format(Format(snpSQLStats("invalidations") / snpSQLStats("executions"), "#,##0.00"), "@@@@@@@@@@@@@@") & vbCrLf

                                        strOut = strOut & "" & vbCrLf
                                    End If
                                End If
                                snpSQLStats.Close
                            End If
                        End If
                    End If

                    If (InStr(snpXPLAN(0), "SQL_ID") > 0) And (InStr(snpXPLAN(0), "child number " & Format(intSQLChildNumber)) > 0) Then
                        intFlag = True
                        strOut = strOut & "Plan Used by the Session" & vbCrLf
                        strOut = strOut & String(100, "~") & vbCrLf
                        strOut = strOut & snpXPLAN(0) & vbCrLf
                        strOut = strOut & String(100, "~") & vbCrLf
                    Else
                        strOut = strOut & snpXPLAN(0) & vbCrLf
                    End If

                    snpXPLAN.MoveNext
                Loop
                snpXPLAN.Close
                If intFlag = True Then
                    strOut = strOut & String(100, "~") & vbCrLf
                End If
                strOut = strOut & vbCrLf
            End If
        End If

        Print #intFileNum, strOut
        Close #intFileNum
        Shell "notepad.exe C:\ExcelTimeModelViewer\DBMS_XPLAN.txt", vbNormalFocus
    End If
End Sub

Note that in the above code, if you are running Windows Vista or Window 7 with User Access Control enabled, you will need to replace all instances of C:\ExcelTimeModelViewer in the code with a writeable file location.

Press the F5 key to start up the execution of the UserForm.  You might need to toggle the chkPauseFresh CheckBox to allow the UserForm data to begin updating.  Just as an experiment, I decided to take a look at the execution plan for the SQL_ID that was identified for my Excel session.  The following is the output that was displayed on screen (in the Notepad application window):

****************************************************************************************************
Reason for Child Cursor Creation
**********
Plan Used by the Session
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SQL_ID  6uw0vzxdsd8f8, child number 0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-------------------------------------
SELECT    S.SID,    S.SERIAL#,    S.STATUS,    NVL(S.USERNAME,' ')
USERNAME,    NVL(S.MACHINE,' ') MACHINE,    NVL(S.PROGRAM,' ') PROGRAM,
   NVL(S.SQL_ID,NVL(S.PREV_SQL_ID,' ')) SQL_ID,   
NVL(S.SQL_CHILD_NUMBER,NVL(S.PREV_CHILD_NUMBER,0)) SQL_CHILD_NUMBER,   
STM.VALUE,    STM.STAT_NAME  FROM    V$SESS_TIME_MODEL STM,   
V$SESSION S  WHERE    S.SID=STM.SID  ORDER BY    S.USERNAME,   
S.PROGRAM,    S.SID

Statistics for Execution Plan:
  Last Active: 3/15/2011 11:12:31 PM
  Parses:                         14  
  Executions:                     18       Exec Per Parse:           1.29
  CPU Time:                        0.06    Per Exec:                 0.00
  Elapsed Time:                    0.08    Per Exec:                 0.00
  Application Wait Time:           0.00    Per Exec:                 0.00
  Concurrency Wait Time:           0.00    Per Exec:                 0.00
  User IO Wait Time:               0.01    Per Exec:                 0.00
  Application Wait Time:           0.00    Per Exec:                 0.00
  Cluster Wait Time:               0.00    Per Exec:                 0.00
  PL/SQL Execute Time:             0.00    Per Exec:                 0.00
  Java Execution Time:             0.00    Per Exec:                 0.00
  Buffer (Cons.) Gets:           201       Per Exec:                11.17
  Disk (Block) Reads:              4       Per Exec:                 0.22
  Direct Writes:                   0       Per Exec:                 0.00
  Rows Processed:              8,170       Per Exec:               453.89
  Fetches:                        90       Per Exec:                 5.00
  Loads:                           2       Per Exec:                 0.11
  Invalidations:                   0       Per Exec:                 0.00

Plan hash value: 186343697

------------------------------------------------------------------------------------------------------------
| Id  | Operation                    | Name               | Rows  | Bytes | Cost (%CPU)| Time     | Inst   |
------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT             |                    |       |       |     2 (100)|          |        |
|   1 |  SORT ORDER BY               |                    |   273 | 27846 |     2 (100)| 00:00:01 |        |
|*  2 |   HASH JOIN                  |                    |   273 | 27846 |     1 (100)| 00:00:01 |        |
|*  3 |    FIXED TABLE FULL          | X$KEWSSMAP         |    13 |   455 |     0   (0)|          |  OR112 |
|   4 |    NESTED LOOPS              |                    |  1604 |   104K|     0   (0)|          |        |
|   5 |     NESTED LOOPS             |                    |    24 |  1224 |     0   (0)|          |        |
|   6 |      NESTED LOOPS            |                    |    24 |   288 |     0   (0)|          |        |
|   7 |       FIXED TABLE FULL       | X$KSLWT            |    24 |   192 |     0   (0)|          |  OR112 |
|*  8 |       FIXED TABLE FIXED INDEX| X$KSLED (ind:2)    |     1 |     4 |     0   (0)|          |  OR112 |
|*  9 |      FIXED TABLE FIXED INDEX | X$KSUSE (ind:1)    |     1 |    39 |     0   (0)|          |  OR112 |
|* 10 |     FIXED TABLE FIXED INDEX  | X$KEWSSESV (ind:1) |    67 |  1072 |     0   (0)|          |  OR112 |
------------------------------------------------------------------------------------------------------------

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

   2 - access("MAP"."SOFFST"="SESV"."KEWSNUM")
   3 - filter(("MAP"."AGGID"=1 AND INTERNAL_FUNCTION("MAP"."STYPE") AND
              "MAP"."INST_ID"=USERENV('INSTANCE')))
   8 - filter("W"."KSLWTEVT"="E"."INDX")
   9 - filter((BITAND("S"."KSUSEFLG",1)<>0 AND BITAND("S"."KSSPAFLG",1)<>0 AND
              "S"."INST_ID"=USERENV('INSTANCE') AND "S"."INDX"="W"."KSLWTSID"))
  10 - filter((BITAND("SESV"."KSUSEFLG",1)<>0 AND BITAND("SESV"."KSSPAFLG",1)<>0 AND
              "S"."INDX"="SESV"."KSUSENUM"))

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

****************************************************************************************************
Reason for Child Cursor Creation
STATS_ROW_MISMATCH
**********
SQL_ID  6uw0vzxdsd8f8, child number 1
-------------------------------------
SELECT    S.SID,    S.SERIAL#,    S.STATUS,    NVL(S.USERNAME,' ')
USERNAME,    NVL(S.MACHINE,' ') MACHINE,    NVL(S.PROGRAM,' ') PROGRAM,
   NVL(S.SQL_ID,NVL(S.PREV_SQL_ID,' ')) SQL_ID,   
NVL(S.SQL_CHILD_NUMBER,NVL(S.PREV_CHILD_NUMBER,0)) SQL_CHILD_NUMBER,   
STM.VALUE,    STM.STAT_NAME  FROM    V$SESS_TIME_MODEL STM,   
V$SESSION S  WHERE    S.SID=STM.SID  ORDER BY    S.USERNAME,   
S.PROGRAM,    S.SID

Statistics for Execution Plan:
  Last Active: 3/15/2011 11:12:31 PM
  Parses:                         14  
  Executions:                     18       Exec Per Parse:           1.29
  CPU Time:                        0.06    Per Exec:                 0.00
  Elapsed Time:                    0.08    Per Exec:                 0.00
  Application Wait Time:           0.00    Per Exec:                 0.00
  Concurrency Wait Time:           0.00    Per Exec:                 0.00
  User IO Wait Time:               0.01    Per Exec:                 0.00
  Application Wait Time:           0.00    Per Exec:                 0.00
  Cluster Wait Time:               0.00    Per Exec:                 0.00
  PL/SQL Execute Time:             0.00    Per Exec:                 0.00
  Java Execution Time:             0.00    Per Exec:                 0.00
  Buffer (Cons.) Gets:           201       Per Exec:                11.17
  Disk (Block) Reads:              4       Per Exec:                 0.22
  Direct Writes:                   0       Per Exec:                 0.00
  Rows Processed:              8,170       Per Exec:               453.89
  Fetches:                        90       Per Exec:                 5.00
  Loads:                           2       Per Exec:                 0.11
  Invalidations:                   0       Per Exec:                 0.00

Plan hash value: 186343697

------------------------------------------------------------------------------------------------------------
| Id  | Operation                    | Name               | Rows  | Bytes | Cost (%CPU)| Time     | Inst   |
------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT             |                    |       |       |     2 (100)|          |        |
|   1 |  SORT ORDER BY               |                    |   273 | 27846 |     2 (100)| 00:00:01 |        |
|*  2 |   HASH JOIN                  |                    |   273 | 27846 |     1 (100)| 00:00:01 |        |
|*  3 |    FIXED TABLE FULL          | X$KEWSSMAP         |    13 |   455 |     0   (0)|          |  OR112 |
|   4 |    NESTED LOOPS              |                    |  1604 |   104K|     0   (0)|          |        |
|   5 |     NESTED LOOPS             |                    |    24 |  1224 |     0   (0)|          |        |
|   6 |      NESTED LOOPS            |                    |    24 |   288 |     0   (0)|          |        |
|   7 |       FIXED TABLE FULL       | X$KSLWT            |    24 |   192 |     0   (0)|          |  OR112 |
|*  8 |       FIXED TABLE FIXED INDEX| X$KSLED (ind:2)    |     1 |     4 |     0   (0)|          |  OR112 |
|*  9 |      FIXED TABLE FIXED INDEX | X$KSUSE (ind:1)    |     1 |    39 |     0   (0)|          |  OR112 |
|* 10 |     FIXED TABLE FIXED INDEX  | X$KEWSSESV (ind:1) |    67 |  1072 |     0   (0)|          |  OR112 |
------------------------------------------------------------------------------------------------------------

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

   2 - access("MAP"."SOFFST"="SESV"."KEWSNUM")
   3 - filter(("MAP"."AGGID"=1 AND INTERNAL_FUNCTION("MAP"."STYPE") AND
              "MAP"."INST_ID"=USERENV('INSTANCE')))
   8 - filter("W"."KSLWTEVT"="E"."INDX")
   9 - filter((BITAND("S"."KSUSEFLG",1)<>0 AND BITAND("S"."KSSPAFLG",1)<>0 AND
              "S"."INST_ID"=USERENV('INSTANCE') AND "S"."INDX"="W"."KSLWTSID"))
  10 - filter((BITAND("SESV"."KSUSEFLG",1)<>0 AND BITAND("SESV"."KSSPAFLG",1)<>0 AND
              "S"."INDX"="SESV"."KSUSENUM"))

If you examine the above, you will notice that the output from V$SQLSTATS is identical for both of the child cursors – that is because the PLAN_HASH_VALUE is identical for both of the child cursors.

Where do we head next with the project?  I am a person who prefers looking at raw numbers, but maybe someone reading this blog prefers pictures?

Added August 11, 2011:

The Excel project code to this point, save with a .XLS extension (currently has a .DOC extension, please change):
TimeModelViewerExcelArticle5.xls





Oracle Database Time Model Viewer in Excel 4

6 03 2011

March 6, 2011 (Updated March 15, 2011)

(Back to the Previous Post in the Series) (Forward to the Next Post in the Series)

In the previous three parts of this series we started building an Oracle Database time model statistics viewer using nothing more than Microsoft Excel.  The end result will hopefully duplicate some of the functionality that is found in a portion of a program that I have been building over the course of the last several years.  My program’s window that shows the Oracle Database time model statistics looks like this:

If you have been following along with the previous articles in this series,  at this point your Excel UserForm project should look something like the following screen capture:

We still need to add the wait events to the project.  While we could display the wait events information in a TreeView control, there would not be much sense to display the wait event information in a grid type control when we are able to just push that information out to a worksheet in the Excel workbook.  So that we are able to control which worksheet that information will be push to, we should begin by naming the worksheet.  In the main Excel window, right-click Sheet1 and select Rename.  Change the name to Wait Events.

Now switch back to the code window for the project (note that you can display the code window by right-click a worksheet tab and selecting View Code).  Right-click frmTimeModel (under the Forms heading which is below Microsoft Excel Objects) and select View Object.  The Caption property of the UserForm likely still shows UserForm1 – change the Caption property to something that is more meaningful (I will change my Caption to I Can’t Believe I Build an Oracle Database Time Model Viewer in Excel - yes, that typo is intentional).  Double-click the background of the UserForm to show the code for the UserForm’s Initialize event.  Locate the following text in the Initialize event:

    'More code will be copied here
    '
    '
    ' 

Move the cursor just above that text and press the Enter key a couple of times.  Add the following code above the ‘More code will be copied here line.  Note that the second of the SQL statements uses bind variables:

    'Added in Article 4
    With comDataWait
        strSQL = "SELECT" & vbCrLf
        strSQL = strSQL & "  WAIT_CLASS," & vbCrLf
        strSQL = strSQL & "  EVENT," & vbCrLf
        strSQL = strSQL & "  TOTAL_WAITS," & vbCrLf
        strSQL = strSQL & "  TOTAL_TIMEOUTS," & vbCrLf
        strSQL = strSQL & "  TIME_WAITED" & vbCrLf
        strSQL = strSQL & "FROM" & vbCrLf
        strSQL = strSQL & "  V$SYSTEM_EVENT" & vbCrLf
        strSQL = strSQL & "ORDER BY" & vbCrLf
        strSQL = strSQL & "  WAIT_CLASS," & vbCrLf
        strSQL = strSQL & "  EVENT"

        .CommandText = strSQL
        .CommandType = adCmdText
        .CommandTimeout = 30
        .ActiveConnection = dbDatabase
    End With

    With comSessionWait
        strSQL = "SELECT" & vbCrLf
        strSQL = strSQL & "  S.SID," & vbCrLf
        strSQL = strSQL & "  S.SERIAL#," & vbCrLf
        strSQL = strSQL & "  S.STATUS," & vbCrLf
        strSQL = strSQL & "  NVL(S.USERNAME,' ') USERNAME," & vbCrLf
        strSQL = strSQL & "  NVL(S.MACHINE,' ') MACHINE," & vbCrLf
        strSQL = strSQL & "  NVL(S.PROGRAM,' ') PROGRAM," & vbCrLf
        strSQL = strSQL & "  NVL(S.SQL_ID,NVL(S.PREV_SQL_ID,' ')) SQL_ID," & vbCrLf
        strSQL = strSQL & "  NVL(S.SQL_CHILD_NUMBER,NVL(S.PREV_CHILD_NUMBER,0)) SQL_CHILD_NUMBER," & vbCrLf
        strSQL = strSQL & "  SE.EVENT," & vbCrLf
        strSQL = strSQL & "  SE.TOTAL_WAITS," & vbCrLf
        strSQL = strSQL & "  SE.TOTAL_TIMEOUTS," & vbCrLf
        strSQL = strSQL & "  SE.TIME_WAITED" & vbCrLf
        strSQL = strSQL & "FROM" & vbCrLf
        strSQL = strSQL & "  V$SESSION_EVENT SE," & vbCrLf
        strSQL = strSQL & "  V$SESSION S" & vbCrLf
        strSQL = strSQL & "WHERE" & vbCrLf
        strSQL = strSQL & "  SE.EVENT = ?" & vbCrLf
        strSQL = strSQL & "  AND SE.SID=S.SID" & vbCrLf
        strSQL = strSQL & "ORDER BY" & vbCrLf
        strSQL = strSQL & "  S.SID"

        .CommandText = strSQL
        .CommandType = adCmdText
        .ActiveConnection = dbDatabase

        'Add the bind variables
        .Parameters.Append .CreateParameter("event", adVarChar, adParamInput, 40, "")
    End With 

Scroll up in the code until you locate the ReadData subroutine.  Locate the following line at the bottom of that subroutine:

dteLastLoopStart = Now

Move the cursor just above that line and press the Enter key a couple of times.  In the blank area that was just created paste the following code which will read in the system-wide wait event statistics and store those statistics in variables:

    'Added in Article 4
    Set snpDataWait = comDataWait.Execute
    If Not (snpDataWait Is Nothing) Then
        Do While Not (snpDataWait.EOF)
            intWaitCurrent = intWaitCount + 1
            'Find the previous entry for this wait event
            For j = 1 To intWaitCount
                If strWaitEventName(j) = CStr(snpDataWait("event")) Then
                    intWaitCurrent = j
                    Exit For
                End If
            Next j
            If intWaitCurrent = intWaitCount + 1 Then
                'New entry
                intWaitCount = intWaitCount + 1
                strWaitEventName(intWaitCurrent) = CStr(snpDataWait("event"))
                strWaitEventClass(intWaitCurrent) = snpDataWait("wait_class")
            End If
            dblWaitValueLast(intWaitCurrent) = dblWaitValue(intWaitCurrent)
            dblWaitValue(intWaitCurrent) = CDbl(snpDataWait("time_waited"))
            dblWaitWaitsValueLast(intWaitCurrent) = dblWaitWaitsValue(intWaitCurrent)
            dblWaitWaitsValue(intWaitCurrent) = CDbl(snpDataWait("total_waits"))
            dblWaitTOValueLast(intWaitCurrent) = dblWaitTOValue(intWaitCurrent)
            dblWaitTOValue(intWaitCurrent) = CDbl(snpDataWait("total_timeouts"))

            snpDataWait.MoveNext
        Loop
        snpDataWait.Close
    End If 

Note in the above code the snpDataWait.Close command that is below the Loop and above the End If lines.  That command closes the snpDataWait recordset, which is necessary to prevent cursor leaks.  Review the other code sections that are in the ReadData subroutine and verify that the recordset is always closed between the Loop and End If lines, and if it is not, fix that problem (hint: there is at least one code section that needs to be corrected).

Find the UpdateDisplay subroutine and locate the following line near the start of the subroutine:

On Error Resume Next 

Just above that line, press the Enter key a couple of times and add the following variable declaration – this variable will be used to control where the output is placed on the worksheet:

Dim lngRow As Long 

Scroll down to the bottom of the UpdateDisplay subroutine and locate the following line:

intCurrentSessionIndex = -1 

Move the cursor just above that line, press the Enter key a couple of times.  Paste in the following code on the blank lines:

    'Added in Article 4
    lngRow = 1
    Sheets("Wait Events").Rows("1:10000").Delete Shift:=xlUp
    Sheets("Wait Events").Cells(lngRow, 1).Value = "Wait Event Name"
    Sheets("Wait Events").Cells(lngRow, 2).Value = "Wait Time"
    Sheets("Wait Events").Cells(lngRow, 3).Value = "Waits"
    Sheets("Wait Events").Cells(lngRow, 4).Value = "Timeouts"
    Sheets("Wait Events").Cells(lngRow, 5).Value = "Session Description"

    For j = 1 To intWaitCount
        If (strWaitEventClass(j) <> "Idle") Or (intExcludeIdleWaits = False) Then
            If strLastWaitClass <> strWaitEventClass(j) Then
                If strLastWaitClass <> "" Then
                    'Do not write out on the first pass
                    Sheets("Wait Events").Cells(intLastWaitClassRow, 2).Value = Format(sglWaitClassTime / 100, "0.00")
                End If

                strLastWaitClass = strWaitEventClass(j)
                lngRow = lngRow + 1
                Sheets("Wait Events").Cells(lngRow, 1).Value = strLastWaitClass & " Wait Class"
                Sheets("Wait Events").Cells(lngRow, 1).Font.Bold = True
                Sheets("Wait Events").Cells(lngRow, 2).Font.Bold = True
                intLastWaitClassRow = lngRow
                sglWaitClassTime = 0
            End If

            If (dblWaitValue(j) - dblWaitValueLast(j)) <> 0 Then
                sglWaitClassTime = sglWaitClassTime + (dblWaitValue(j) - dblWaitValueLast(j))

                If strWaitEventClass(j) <> "Idle" Then
                    sglTotalWaitTime = sglTotalWaitTime + (dblWaitValue(j) - dblWaitValueLast(j))
                End If

                lngRow = lngRow + 1
                Sheets("Wait Events").Cells(lngRow, 1).Value = "-- " & strWaitEventName(j)
                Sheets("Wait Events").Cells(lngRow, 2).Value = Format((dblWaitValue(j) - dblWaitValueLast(j)) / 100, "0.00")
                Sheets("Wait Events").Cells(lngRow, 3).Value = Format((dblWaitWaitsValue(j) - dblWaitWaitsValueLast(j)), "0")
                Sheets("Wait Events").Cells(lngRow, 4).Value = Format((dblWaitTOValue(j) - dblWaitTOValueLast(j)), "0")
                Sheets("Wait Events").Cells(lngRow, 5).Value = ""

                If (intDisplaySessionDetail = True) Then
                    comSessionWait("event") = strWaitEventName(j)
                    Set snpSessionWait = comSessionWait.Execute

                    If Not (snpSessionWait Is Nothing) Then
                        If snpSessionWait.State = 1 Then
                            Do While Not (snpSessionWait.EOF)
                                intSessionCurrent = 0
                                For k = 1 To intSessionCount
                                    If (lngSID(k) = CLng(snpSessionWait("sid"))) And (lngSerial(k) = CLng(snpSessionWait("serial#"))) Then
                                        intSessionCurrent = k

                                        'Output the session wait information
                                        If (snpSessionWait("time_waited") - dblSessionWaitValue(j, intSessionCurrent) > 0) Then
                                            'Output only if time change is more that the sglSessionMinimumPercent value
                                            If ((CDbl(snpSessionWait("time_waited")) - dblSessionWaitValue(j, intSessionCurrent)) > 0) And (CDbl(snpSessionWait("time_waited")) - dblSessionWaitValue(j, intSessionCurrent)) / (dblWaitValue(j) - dblWaitValueLast(j)) >= sglSessionMinimumPercent Then
                                                lngRow = lngRow + 1
                                                Sheets("Wait Events").Cells(lngRow, 1).Value = "---- session level wait " & Format((CDbl(snpSessionWait("time_waited")) - dblSessionWaitValue(j, intSessionCurrent)) / (dblWaitValue(j) - dblWaitValueLast(j)), "0.00%") & " of system wait event"
                                                Sheets("Wait Events").Cells(lngRow, 2).Value = Format((CDbl(snpSessionWait("time_waited")) - dblSessionWaitValue(j, intSessionCurrent)) / 100, "0.00")
                                                Sheets("Wait Events").Cells(lngRow, 3).Value = Format((CDbl(snpSessionWait("total_waits")) - dblSessionWaitWaitsValue(j, intSessionCurrent)), "0")
                                                Sheets("Wait Events").Cells(lngRow, 4).Value = Format((CDbl(snpSessionWait("total_timeouts")) - dblSessionWaitTOValue(j, intSessionCurrent)), "0")

                                                strOut = "SID:" & Format(snpSessionWait("sid")) & " SERIAL#:" & Format(snpSessionWait("serial#"))
                                                strOut = strOut & " ~ Machine: " & snpSessionWait("machine") & " ~ " & snpSessionWait("username") & " ~ " & snpSessionWait("program")
                                                If snpSessionWait("sql_id") <> " " Then
                                                    strOut = strOut & " ~ SQL_ID/Child: " & snpSessionWait("sql_id") & "/" & Format(snpSessionWait("sql_child_number"), "0") & " "
                                                    If UCase(snpSessionWait("status")) = "ACTIVE" Then
                                                        strOut = strOut & " (A)"
                                                    End If
                                                End If
                                                Sheets("Wait Events").Cells(lngRow, 5).Value = strOut
                                            End If
                                        End If
                                        dblSessionWaitValue(j, intSessionCurrent) = CDbl(snpSessionWait("time_waited"))
                                        dblSessionWaitWaitsValue(j, intSessionCurrent) = CDbl(snpSessionWait("total_waits"))
                                        dblSessionWaitTOValue(j, intSessionCurrent) = CDbl(snpSessionWait("total_timeouts"))

                                        Exit For
                                    End If
                                Next k

                                snpSessionWait.MoveNext
                            Loop
                            snpSessionWait.Close
                        End If
                    End If
                End If
            End If
        End If
    Next j

    If strLastWaitClass <> "" Then
        Sheets("Wait Events").Cells(intLastWaitClassRow, 2).Value = Format(sglWaitClassTime / 100, "0.00")
    End If

    Sheets("Wait Events").Columns("A:A").EntireColumn.AutoFit
    Sheets("Wait Events").Columns("B:B").EntireColumn.AutoFit
    Sheets("Wait Events").Columns("C:C").EntireColumn.AutoFit
    Sheets("Wait Events").Columns("D:D").EntireColumn.AutoFit
    Sheets("Wait Events").Columns("E:E").EntireColumn.AutoFit
    Sheets("Wait Events").Columns("B:B").NumberFormat = "0.00"
    Sheets("Wait Events").Range("B2").Select
    ActiveWindow.FreezePanes = True 

'    lblTotalWaitTime = Format(sglTotalWaitTime / 100, "0.00")

You may have noticed that the chkPauseRefresh CheckBox (with caption Pause Refresh) does not work quite as expected – this is a simple logic problem that needs to be addressed.  Find the chkPauseRefresh CheckBox on the UserForm and double-click it to show the code that is behind the CheckBox control.  You will see a line of code that looks like this:

If intKillFlag <> False Then

Change the <> characters to an = character so that the line appears as follows:

If intKillFlag = False Then 

If you then show the UserForm (switch to the Initialize event of the UserForm and press the F5 key, you may then need to toggle the chkPauseRefresh check box between checked and not checked) you should see something like this after the second 60 second delay:

We still have a slight problem that needs to be addressed.  We need another Label control on the UserForm, with the name lblTotalWaitTime.  Once you have created that Label control, you can go back to the UpdateDisplay subroutine and remove the single quote (‘) that is in front of the following line:

'    lblTotalWaitTime = Format(sglTotalWaitTime / 100, "0.00") 

When the single quote is removed, the text color should change from green to black.

What more are we able to do with this project?  We could display the execution plans for the captured SQL_ID and CHILD_NUMBER (stored in the strSQLID() array), we could enable/disable 10046 tracing for sessions, we could write out the statistics in real-time to another worksheet and then graph the results, or maybe we could just sit back and stare at the screen in amazement that this project was built in Microsoft Excel ;-)

—-

Added March 15, 2011:

The Excel project code to this point, save with a .XLS extension (currently has a .DOC extension, please change):
timemodelviewerexcelarticle4xls





Oracle Database Time Model Viewer in Excel 3

3 03 2011

March 3, 2011 (Updated March 5, 2011)

(Back to the Previous Post in the Series) (Forward to the Next Post in the Series)

In the previous articles of this series we started building a solution in Microsoft Excel that duplicates some of the functionality in one of my programs – the Oracle Database Time Model viewer.  So far, the project only works at just the system-wide level.  Hopefully, not too many people are having difficulty following along with this article series - it has been more than a decade since I professionally taught programming and Microsoft Excel, so I might be overlooking a couple of “obviously” difficult points. 

If you have not done so yet, you may need to change Excel’s default behavior when an error occurs in the code, since some errors are expected and should be handled appropriately within our programming code.  To check the error trapping setting in the Excel code editor window, select from the menu ToolsOptions.  On the General tab, find and select the setting Break on Unhandled Errors, then click the OK button.  If you plan to do much programming in Excel, I also suggest setting the Require Variable Declaration option on the Editor tab – setting that option helps to avoid some forms of typing errors (all used variables must be officially declared before use).

If you find that the macro seems to pause unexpectedly when first started, there is a simple solution for that issue, and we will apply the simple solution later in this article.

We will start by adding a couple of more controls to the UserForm to add a little more functionality to the programming code.  In my sample project I will be adding the extra controls at the top of the UserForm.  We need to add three CheckBox controls to the UserForm with the (Name) property set to: chkPauseRefresh, chkDisplaySessionDetail, and chkExcludeIdleWaits (one name for each CheckBox).  Change the Caption property of those checkboxes to describe the function of the CheckBoxes (I used: Pause Refresh, Show Session Detail, and No Idle Waits).  Add two ComboBox controls to the UserForm with the (Name) property set to: cboUpdateFrequency and cboSessionMinimumPercent.  Set the Text property of the cboUpdateFrequency ComboBox to 60.  Set the Text property of the cboSessionMinimumPercent ComboBox to 10.  Add a Label control near each of the ComboBox controls, and change the Caption property of the Label controls to describe the purpose of the ComboBox controls (I used: Update Freq (S) and Min Utilization to Inc. Session %).  Your UserForm should look something like this when finished with the above instructions:

The extra controls at this point do nothing, other than occupy space on the UserForm, so we need to add functionality to the extra controls.  Double-click the chkPauseRefresh CheckBox to show the default code event for the CheckBox – the “Click” event.  The TimerEvent subroutine that we modified in the previous article is set to abort re-executing the TimerEvent subroutine any time the intKillFlag variable is set to something other than False (a value of 0).  So, the code for the chkPauseRefresh CheckBox’s Click event will simply toggle this intKillFlag variable between the values of True and False – if the value becomes True we need to restart the re-execution of the TimerEvent procedure.  The easiest way to accomplish this task is with the following code in the chkPauseRefresh CheckBox’s Click event (note that in Visual Basic versions 4.0 through 6.0 this same code will toggle the intKillFlag variable between the values of 0 and 1, but the code as written will behave the same way.  Value is the default property of a CheckBox control, so technically we could have omitted the .Value portion of the code):

Private Sub chkPauseRefresh_Click()
    intKillFlag = chkPauseRefresh.Value

    If intKillFlag <> False Then
        TimerEvent
    End If
End Sub 

The chkDisplaySessionDetail CheckBox technically does not require any special programming code in its Click event, so we will come back to this program functionality later.

The Click event for the chkExcludeIdleWaits CheckBox is similar to that of the same event for the chkPauseRefresh CheckBox.  On the UserForm, double-click the chkExcludeIdleWaits CheckBox (or simply select that name from the left ComboBox (drop-down list) in the code editor).  Change the Click event for that CheckBox to the following:

Private Sub chkExcludeIdleWaits_Click()
    intExcludeIdleWaits = chkExcludeIdleWaits.Value
End Sub

We need to add a little code to the two ComboBox controls in order to prevent the user of this tool from entering silly values, such as Sixty for the update frequency or 1,000,000 for the minimum utilization percent – we will check the entered values only when the user “tabs” out of the controls (or clicks something else).  Double-click the cboUpdateFrequency ComboBox, then select the Exit event from the ComboBox (drop-down list) that is at the top-right of the code window.  Add the following code to that event:

Private Sub cboUpdateFrequency_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    Dim intResult As Integer

    If IsNumeric(cboUpdateFrequency.Text) Then
        If (Val(cboUpdateFrequency.Text) >= 1) And (Val(cboUpdateFrequency.Text) <= 18000) Then
            'OK
            lngTimerTriggerSeconds = Val(cboUpdateFrequency.Text)
        Else
            intResult = MsgBox(cboUpdateFrequency.Text & " is an invalid value." & vbCrLf & _
                "Must enter a number between 1 and 18000", vbCritical, "Charles Hooper's Oracle Database Time Model Viewer") 

            cboUpdateFrequency.Text = "60"
            lngTimerTriggerSeconds = 60
        End If
    Else
        intResult = MsgBox(cboUpdateFrequency.Text & " is an invalid value." & vbCrLf & _
            "Must enter a number between 1 and 18000", vbCritical, "Charles Hooper's Oracle Database Time Model Viewer")

        cboUpdateFrequency.Text = "60"
        lngTimerTriggerSeconds = 60
    End If
End Sub 

We need similar code in the Exit event of the cboUpdateFrequency ComboBox.  Double-click the cboUpdateFrequency ComboBox, and switch to the Exit event.  Add the following code:

Private Sub cboSessionMinimumPercent_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    Dim intResult As Integer

    If IsNumeric(cboSessionMinimumPercent.Text) Then
        If (Val(cboSessionMinimumPercent.Text) >= 0.001) And (Val(cboSessionMinimumPercent.Text) <= 100) Then
            'OK
        Else
            intResult = MsgBox(cboSessionMinimumPercent.Text & " is an invalid value." & vbCrLf & _
                "Must enter a number between 0.001 and 100.0", vbCritical, "Charles Hooper's Oracle Database Time Model Viewer")

            cboSessionMinimumPercent.Text = "10"
        End If
    Else
        intResult = MsgBox(cboSessionMinimumPercent.Text & " is an invalid value." & vbCrLf & _
            "Must enter a number between 0.001 and 100.0", vbCritical, "Charles Hooper's Oracle Database Time Model Viewer")

        cboSessionMinimumPercent.Text = "10"
    End If
End Sub 

We still need to add the functionality for the chkDisplaySessionDetail CheckBox and the cboSessionMinimumPercent ComboBox, and we have not done anything with the wait events yet (that feature will be added in the next article in this series).  Find the following code section in the UpdateDisplay subroutine:

'    If chkDisplaySessionDetail = 0 Then
'        intDisplaySessionDetail = False
'    Else
'        intDisplaySessionDetail = True
'    End If
'    sglSessionMinimumPercent = Val(cboSessionMinimumPercent.Text) / 100 

Remove the single quote characters (‘) in front of each of those lines so that the code appears like this:

    If chkDisplaySessionDetail = 0 Then
        intDisplaySessionDetail = False
    Else
        intDisplaySessionDetail = True
    End If
    sglSessionMinimumPercent = Val(cboSessionMinimumPercent.Text) / 100 

The above simple fix adds the functionality to the chkDisplaySessionDetail CheckBox and the cboSessionMinimumPercent ComboBox.  We still need to provide a list of items in the ComboBoxes that the users are able to select from, and fix the problem where the macro seems to pause unexpectedly when first started.  Switch to the Initialize event in the UserForm (double-click the UserForm’s background area), and then locate the following code in that subroutine:

    'More code will be copied here
    '
    '
    ' 

Just below that section of the code (and above the TimerEvent line), add the following code:

    cboUpdateFrequency.AddItem "5"
    cboUpdateFrequency.AddItem "10"
    cboUpdateFrequency.AddItem "30"
    cboUpdateFrequency.AddItem "60"
    cboUpdateFrequency.AddItem "120"
    cboUpdateFrequency.AddItem "600"
    cboUpdateFrequency.AddItem "3600"
    cboUpdateFrequency.AddItem "7200"
    cboUpdateFrequency.Text = "60"
    lngTimerTriggerSeconds = 60

    cboSessionMinimumPercent.AddItem "1"
    cboSessionMinimumPercent.AddItem "5"
    cboSessionMinimumPercent.AddItem "10"
    cboSessionMinimumPercent.AddItem "15"
    cboSessionMinimumPercent.AddItem "20"
    cboSessionMinimumPercent.AddItem "25"
    cboSessionMinimumPercent.AddItem "50"
    cboSessionMinimumPercent.AddItem "75"
    cboSessionMinimumPercent.Text = "10"

    DoEvents 

In the above, the lines containing .AddItem add entries to the list that is suggested to the user of the tool that we are building.  The lines containing .Text set the default text that appears in each of the ComboBoxes, and the lngTimerTriggerSeconds value must be identical to the numeric value that is assigned to the cboUpdateFrequency.Text property.  Save the project and press the F5 key on the keyboard to display the UserForm and start updating the statistics (after a 60 second delay).  Place a check in the chkDisplaySessionDetail CheckBox (identified as Show Session Detail in the sample project).  You should see something like this (up to 60 seconds after placing a check in that CheckBox):

By looking at the above screen capture it is probably obvious that those sessions which had consumed a small percentage of a Time Model Statistic are displayed with a yellow background, those sessions that had consumed 50% of a Time Model Statistic are displayed with a deep orange background, and sessions that had consumed 100% of a Time Model Statistic are displayed with a solid red background.

We still have a bit more to add to this tool, so keep an eye open for the next article in this series.

—-

Added March 5, 2011:

The Excel project code to this point, save with a .XLS extension (currently has a .DOC extension, please change):
timemodelviewerexcelarticle3xls





Oracle Database Time Model Viewer in Excel 2

1 03 2011

March 1, 2011 (Updated March 2, 2011)

(Back to the Previous Post in the Series) (Forward to the Next Post in the Series)

In the previous blog article in this series, we examined the output generated by one of my programs.  Most of that output was centered on the analysis of the time model statistics in Oracle Database 10.1 and above.  The intention of this blog article series is to try to build a similar tool using nothing more than Microsoft Excel.  I do not know yet if it is possible, but we will definitely try to make it work.  Unfortunately, there are a couple of features missing in Oracle Database 10.1 as well as some of the statistics being named differently from later release versions of Oracle Database, so this project will target Oracle Database 10.2.0.1 and above.  This project will use a Microsoft TreeView control which might not be installed on your computer, however I verified on a Windows 7 32 bit computer with Excel 2010 installed, that if you are able to find the OCX file containing the Treeview and register that file with Windows, it can be used in the Excel development environment for this project.

If you attempted the project in the previous article of this series (that project is the starting point for today’s article), you may have received an odd error message when opening the project (at least I did on Excel 2007).  The message is “Can’t execute code in break mode” - if you received that error message, there is a simple fix – just hit the F5 key on the keyboard to tell Excel to continue executing the code.  The reason why this error message appears is likely related to the ShowModal property of the UserForm.  When that property is set to True (apparently the default), that UserForm has the full attention of Microsoft Excel until it is closed – that of course causes problems when the worksheet opens and the form displays automatically.  There are two methods to work around this issue, the first requires changing the following line in the code:

frmTimeModel.Show 

to this:

frmTimeModel.Show vbModeless 

In my opinion, the above is a little ugly, so let’s instead change the ShowModal property of the UserForm.  View the code in the worksheet (see the directions found in the previous article), double-click frmTimeModel under the Forms heading (below Microsoft Excel Objects that was used in the previous article), click once on the background of the UserForm, and then in the Properties window, change the ShowModal property from True to False (don’t ask me why the constant is spelled differently than the property, someone was just being creative I guess):

Now double-click the UserForm’s background area - that will display the programming code that is related to what we double-clicked (the UserForm in this case).  So far, only the following code should appear in the UserForm’s code – this is what causes the TimerEvent procedure to start executing once a second when the UserForm is first displayed on the screen:

Private Sub UserForm_Initialize()
    TimerEvent
End Sub 

Move the cursor in front of “P” in the word Private and hit the Enter key a couple of times to insert a couple of blank lines.  We will need to copy in a lot of code into that blank area – some of the code will not be used immediately, but we will need it later.  Add the following code above the word Private – these are all of the variables that are needed throughout our UserForm:

Option Explicit

Dim dbDatabase As ADODB.Connection          'The ADO connection to the database

Dim dteLastUpdateDate As Variant            'Last update date for queries
Dim intCheckIterations As Integer           'Number of times to check the instances
Dim intDelayIterations As Integer           'Number of seconds to delay between iterations
Dim sglSessionMinimumPercent As Single      'Minimum percent of the total required for the session to be included in the report detail
Dim dteLastLoopStart As Variant             'Time of the last loop start
Dim intDisplaySessionDetail As Integer      'Indicates whether or not to display the session level detail

Dim intFlag As Integer                      'Loop control variable, allow to jump out of the loop early

Dim intCurrentSessionIndex As Integer       'Session index to the currently selected item in the tree view
Dim intNumCPUs As Integer                   'Number of CPUs
Dim dblIdleTime As Double                   'Current value of idle time from V$OSSTAT
Dim dblBusyTime As Double                   'Current value of busy time from V$OSSTAT
Dim dblUserTime As Double                   'Current value of user time from V$OSSTAT
Dim dblSysTime As Double                    'Current value of system/kernel mode time from V$OSSTAT
Dim dblIdleTimeLast As Double               'Previous value of idle time from V$OSSTAT
Dim dblBusyTimeLast As Double               'Previous value of busy time from V$OSSTAT
Dim dblUserTimeLast As Double               'Previous value of user time from V$OSSTAT
Dim dblSysTimeLast As Double                'Previous value of system/kernel mode time from V$OSSTAT

Dim dblCPUUsedByThisSession As Double       'Current value of 'CPU used by this session' from V$SYSSTAT, in seconds
Dim dblParseTimeCPU As Double               'Current value of 'parse time cpu' from V$SYSSTAT, in seconds
Dim dblRecursiveCPUUsage As Double          'Current value of 'recursive cpu usage' from V$SYSSTAT, in seconds
Dim lngParseCountTotal As Long              'Current value of 'parse count (total)' from V$SYSSTAT
Dim lngParseCountHard As Long               'Current value of 'parse count (hard)' from V$SYSSTAT
Dim lngParseCountFailures As Long           'Current value of 'parse count (failures)' from V$SYSSTAT
Dim lngSessionCacheHits As Long             'Current value of 'session cursor cache hits' from V$SYSSTAT
Dim dblCPUUsedByThisSessionLast As Double   'previous value of 'CPU used by this session' from V$SYSSTAT, in seconds
Dim dblParseTimeCPULast As Double           'Previous value of 'parse time cpu' from V$SYSSTAT, in seconds
Dim dblRecursiveCPUUsageLast As Double      'Previous value of 'recursive cpu usage' from V$SYSSTAT, in seconds
Dim lngParseCountTotalLast As Long          'Previous value of 'parse count (total)' from V$SYSSTAT
Dim lngParseCountHardLast As Long           'Previous value of 'parse count (hard)' from V$SYSSTAT
Dim lngParseCountFailuresLast As Long       'Previous value of 'parse count (failures)' from V$SYSSTAT
Dim lngSessionCacheHitsLast As Long         'Previous value of 'session cursor cache hits' from V$SYSSTAT

Dim dblDBCPU As Double                      'Current value of DB CPU from V$SYS_TIME_MODEL
Dim dblDBTime As Double                     'Current value of DB time from V$SYS_TIME_MODEL
Dim dblJavaTime As Double                   'Current value of Java execution elapsed time from V$SYS_TIME_MODEL
Dim dblPLSQLCompile As Double               'Current value of PL/SQL compilation elapsed time from V$SYS_TIME_MODEL
Dim dblPLSQLExecution As Double             'Current value of PL/SQL execution elapsed time from V$SYS_TIME_MODEL
Dim dblRMANCPU As Double                    'Current value of RMAN cpu time (backup/restore) from V$SYS_TIME_MODEL
Dim dblBackgroundCPU As Double              'Current value of background cpu time from V$SYS_TIME_MODEL
Dim dblBackgroundElapsed As Double          'Current value of background elapsed time from V$SYS_TIME_MODEL
Dim dblConnectMgmt As Double                'Current value of connection management call elapsed time from V$SYS_TIME_MODEL
Dim dblFailedParseMemory As Double          'Current value of failed parse (out of shared memory) elapsed time from V$SYS_TIME_MODEL
Dim dblFailedParseElapsed As Double         'Current value of failed parse elapsed time from V$SYS_TIME_MODEL
Dim dblHardParseBind As Double              'Current value of hard parse (bind mismatch) elapsed time from V$SYS_TIME_MODEL
Dim dblHardParseSharing As Double           'Current value of hard parse (sharing criteria) elapsed time from V$SYS_TIME_MODEL
Dim dblHardParseElapsed As Double           'Current value of hard parse elapsed time from V$SYS_TIME_MODEL
Dim dblInboundPLSQL As Double               'Current value of inbound PL/SQL rpc elapsed time from V$SYS_TIME_MODEL
Dim dblParseTimeElapsed As Double           'Current value of parse time elapsed from V$SYS_TIME_MODEL
Dim dblRepeatedBind As Double               'Current value of repeated bind elapsed time from V$SYS_TIME_MODEL
Dim dblSequenceLoad As Double               'Current value of sequence load elapsed time from V$SYS_TIME_MODEL
Dim dblSQLExecuteTime As Double             'Current value of sql execute elapsed time from V$SYS_TIME_MODEL

Dim dblDBCPULast As Double                  'Last value of DB CPU from V$SYS_TIME_MODEL
Dim dblDBTimeLast As Double                 'Last value of DB time from V$SYS_TIME_MODEL
Dim dblJavaTimeLast As Double               'Last value of Java execution elapsed time from V$SYS_TIME_MODEL
Dim dblPLSQLCompileLast As Double           'Last value of PL/SQL compilation elapsed time from V$SYS_TIME_MODEL
Dim dblPLSQLExecutionLast As Double         'Last value of PL/SQL execution elapsed time from V$SYS_TIME_MODEL
Dim dblRMANCPULast As Double                'Last value of RMAN cpu time (backup/restore) from V$SYS_TIME_MODEL
Dim dblBackgroundCPULast As Double          'Last value of background cpu time from V$SYS_TIME_MODEL
Dim dblBackgroundElapsedLast As Double      'Last value of background elapsed time from V$SYS_TIME_MODEL
Dim dblConnectMgmtLast As Double            'Last value of connection management call elapsed time from V$SYS_TIME_MODEL
Dim dblFailedParseMemoryLast As Double      'Last value of failed parse (out of shared memory) elapsed time from V$SYS_TIME_MODEL
Dim dblFailedParseElapsedLast As Double     'Last value of failed parse elapsed time from V$SYS_TIME_MODEL
Dim dblHardParseBindLast As Double          'Last value of hard parse (bind mismatch) elapsed time from V$SYS_TIME_MODEL
Dim dblHardParseSharingLast As Double       'Last value of hard parse (sharing criteria) elapsed time from V$SYS_TIME_MODEL
Dim dblHardParseElapsedLast As Double       'Last value of hard parse elapsed time from V$SYS_TIME_MODEL
Dim dblInboundPLSQLLast As Double           'Last value of inbound PL/SQL rpc elapsed time from V$SYS_TIME_MODEL
Dim dblParseTimeElapsedLast As Double       'Last value of parse time elapsed from V$SYS_TIME_MODEL
Dim dblRepeatedBindLast As Double           'Last value of repeated bind elapsed time from V$SYS_TIME_MODEL
Dim dblSequenceLoadLast As Double           'Last value of sequence load elapsed time from V$SYS_TIME_MODEL
Dim dblSQLExecuteTimeLast As Double         'Last value of sql execute elapsed time from V$SYS_TIME_MODEL

Dim intSessionCount As Integer              'Number of sessions logged
Dim intSessionCurrent As Integer            'Index of the current session
Dim lngSIDLast As Long                      'SID for the previous row from the database
Dim lngSerialLast As Long                   'SERIAL# for the previous row
Dim intSessionExists(999) As Integer        'Used to determine if the session is still found in the system
Dim lngSID(999) As Long                     'SID for session
Dim lngSerial(999) As Long                  'SERIAL# for the session
Dim strSessionOther(999) As String          'USERNAME, MACHINE, PROGRAM
Dim strSQLID(999) As String                 'SQL_ID and CHILD_NUMBER for the session
Dim dblSessionWait(999, 999) As Double           'Session Amount of time waited by the session in the selected wait event (wait#, session#)
Dim dblSessionWaitValue(999, 999) As Double      'Session wait event total time (wait#, session#)
Dim dblSessionWaitWaitsValue(999, 999) As Double 'Session wait event number of waits (wait#, session#)
Dim dblSessionWaitTOValue(999, 999) As Double    'Session wait event number of timeouts (wait#, session#)

Dim strSessionWaitEvent As String           'Name of the monitored wait event
Dim dblDBCPUS(999) As Double                'Current value of DB CPU from V$SESS_TIME_MODEL
Dim dblDBTimeS(999) As Double               'Current value of DB time from V$SESS_TIME_MODEL
Dim dblJavaTimeS(999) As Double             'Current value of Java execution elapsed time from V$SESS_TIME_MODEL
Dim dblPLSQLCompileS(999) As Double         'Current value of PL/SQL compilation elapsed time from V$SESS_TIME_MODEL
Dim dblPLSQLExecutionS(999) As Double       'Current value of PL/SQL execution elapsed time from V$SESS_TIME_MODEL
Dim dblRMANCPUS(999) As Double              'Current value of RMAN cpu time (backup/restore) from V$SESS_TIME_MODEL
Dim dblBackgroundCPUS(999) As Double        'Current value of background cpu time from V$SESS_TIME_MODEL
Dim dblBackgroundElapsedS(999) As Double    'Current value of background elapsed time from V$SESS_TIME_MODEL
Dim dblConnectMgmtS(999) As Double          'Current value of connection management call elapsed time from V$SESS_TIME_MODEL
Dim dblFailedParseMemoryS(999) As Double    'Current value of failed parse (out of shared memory) elapsed time from V$SESS_TIME_MODEL
Dim dblFailedParseElapsedS(999) As Double   'Current value of failed parse elapsed time from V$SESS_TIME_MODEL
Dim dblHardParseBindS(999) As Double        'Current value of hard parse (bind mismatch) elapsed time from V$SESS_TIME_MODEL
Dim dblHardParseSharingS(999) As Double     'Current value of hard parse (sharing criteria) elapsed time from V$SESS_TIME_MODEL
Dim dblHardParseElapsedS(999) As Double     'Current value of hard parse elapsed time from V$SESS_TIME_MODEL
Dim dblInboundPLSQLS(999) As Double         'Current value of inbound PL/SQL rpc elapsed time from V$SESS_TIME_MODEL
Dim dblParseTimeElapsedS(999) As Double     'Current value of parse time elapsed from V$SESS_TIME_MODEL
Dim dblRepeatedBindS(999) As Double         'Current value of repeated bind elapsed time from V$SESS_TIME_MODEL
Dim dblSequenceLoadS(999) As Double         'Current value of sequence load elapsed time from V$SESS_TIME_MODEL
Dim dblSQLExecuteTimeS(999) As Double       'Current value of sql execute elapsed time from V$SESS_TIME_MODEL

Dim dblDBCPUSLast(999) As Double                 'Last value of DB CPU from V$SESS_TIME_MODEL
Dim dblDBTimeSLast(999) As Double                'Last value of DB time from V$SESS_TIME_MODEL
Dim dblJavaTimeSLast(999) As Double              'Last value of Java execution elapsed time from V$SESS_TIME_MODEL
Dim dblPLSQLCompileSLast(999) As Double          'Last value of PL/SQL compilation elapsed time from V$SESS_TIME_MODEL
Dim dblPLSQLExecutionSLast(999) As Double        'Last value of PL/SQL execution elapsed time from V$SESS_TIME_MODEL
Dim dblRMANCPUSLast(999) As Double               'Last value of RMAN cpu time (backup/restore) from V$SESS_TIME_MODEL
Dim dblBackgroundCPUSLast(999) As Double         'Last value of background cpu time from V$SESS_TIME_MODEL
Dim dblBackgroundElapsedSLast(999) As Double     'Last value of background elapsed time from V$SESS_TIME_MODEL
Dim dblConnectMgmtSLast(999) As Double           'Last value of connection management call elapsed time from V$SESS_TIME_MODEL
Dim dblFailedParseMemorySLast(999) As Double     'Last value of failed parse (out of shared memory) elapsed time from V$SESS_TIME_MODEL
Dim dblFailedParseElapsedSLast(999) As Double    'Last value of failed parse elapsed time from V$SESS_TIME_MODEL
Dim dblHardParseBindSLast(999) As Double         'Last value of hard parse (bind mismatch) elapsed time from V$SESS_TIME_MODEL
Dim dblHardParseSharingSLast(999) As Double      'Last value of hard parse (sharing criteria) elapsed time from V$SESS_TIME_MODEL
Dim dblHardParseElapsedSLast(999) As Double      'Last value of hard parse elapsed time from V$SESS_TIME_MODEL
Dim dblInboundPLSQLSLast(999)                    'Last value of inbound PL/SQL rpc elapsed time from V$SESS_TIME_MODEL
Dim dblParseTimeElapsedSLast(999)                'Last value of parse time elapsed from V$SESS_TIME_MODEL
Dim dblRepeatedBindSLast(999)                    'Last value of repeated bind elapsed time from V$SESS_TIME_MODEL
Dim dblSequenceLoadSLast(999)                    'Last value of sequence load elapsed time from V$SESS_TIME_MODEL
Dim dblSQLExecuteTimeSLast(999)                  'Last value of sql execute elapsed time from V$SESS_TIME_MODEL

Dim intWaitCount As Integer                 'Number of wait events read from the database
Dim intWaitCurrent As Integer               'Current index of the wait event
Dim strWaitEventName(1300) As String        'Name of the wait event
Dim strWaitEventClass(1300) As String       'Wait Class of the wait event
Dim dblWaitValue(1300) As Double            'Current wait event total time
Dim dblWaitValueLast(1300) As Double        'Previous wait event total time
Dim dblWaitWaitsValue(1300) As Double       'Current wait event number of waits
Dim dblWaitWaitsValueLast(1300) As Double   'Previous wait event number of waits
Dim dblWaitTOValue(1300) As Double          'Current wait event number of timeouts
Dim dblWaitTOValueLast(1300) As Double      'Previous wait event number of timeouts

Dim snpDataWait As ADODB.Recordset          'ADO recordset used to query V$SYSTEM_EVENT
Dim comDataWait As ADODB.Command            'ADO command object used to retrieve data from V$SYSTEM_EVENT
Dim snpDataOSStat As ADODB.Recordset        'ADO recordset used to query V$OSSTAT
Dim comDataOSStat As ADODB.Command          'ADO command object used to retrieve data from V$OSSTAT
Dim snpDataSysTime As ADODB.Recordset       'ADO recordset used to query V$SYS_TIME_MODEL
Dim comDataSysTime As ADODB.Command         'ADO command object used to retrieve from V$SYS_TIME_MODEL
Dim snpDataSessTime As ADODB.Recordset      'ADO recordset used to query V$SESS_TIME_MODEL
Dim comDataSessTime As ADODB.Command        'ADO command object used to retrieve from V$SESS_TIME_MODEL
Dim comTrace As ADODB.Command               'ADO command object used to enable a 10046 trace
Dim snpXPLAN As ADODB.Recordset             'ADO Recordset object used to retrieve the execution plan
Dim comXPLAN As ADODB.Command               'ADO command object used to retrieve the execution plan
Dim snpSQLChildReason As ADODB.Recordset    'ADO recordset object used to retrieve the reason for the child cursor
Dim comSQLChildReason As ADODB.Command      'ADO command object used to retrieve the reason for the child cursor
Dim snpSQLChildBind As ADODB.Recordset      'ADO recordset object used to retrieve the bind variable definitions
Dim comSQLChildBind As ADODB.Command        'ADO command object used to retrieve the bind variable definitions
Dim snpSessionWait As ADODB.Recordset       'ADO recordset object used to retrieve the session level waits
Dim comSessionWait As ADODB.Command         'ADO command object used to retrieve the session level waits
Dim snpSYSSTAT As ADODB.Recordset           'ADO recordset object used to retrieve the system level statistics from V$SYSSTAT
Dim comSYSSTAT As ADODB.Command             'ADO command object used to retrieve the system level statistics from V$SYSSTAT

Dim intActivated As Integer                 'Indicates whether or not the form is refreshed and ready for use
Dim intRefreshSeconds As Integer            'Minimum number of seconds to wait before the next refresh
Dim intRefreshCount As Integer              'Counter that indicates the number of elapsed seconds since the last refresh
Dim intPauseRefresh As Integer              'Indicates whether or not the refresh is paused
Dim intExcludeIdleWaits As Integer          'Indicates whether or not to exclude idle wait events 

Now change the UserForm_Initialize procedure so that it shows the following:

Private Sub UserForm_Initialize()
    Dim intResult As Integer
    Dim strUsername As String
    Dim strPassword As String
    Dim strDatabase As String
    Dim strSQL As String

    On Error Resume Next

    'Database configuration
    strUsername = "MyUsername"
    strPassword = "MyPassword"
    strDatabase = "MyDB"

    Set dbDatabase = New ADODB.Connection

    dbDatabase.ConnectionString = "Provider=OraOLEDB.Oracle;Data Source=" & strDatabase _
        & ";User ID=" & strUsername & ";Password=" & strPassword & ";ChunkSize=1000;FetchSize=100;"

    dbDatabase.ConnectionTimeout = 40
    dbDatabase.CursorLocation = adUseClient
    dbDatabase.Open

    If (dbDatabase.State <> 1) Or (Err <> 0) Then
        intResult = MsgBox("Could not connect to the database.  Check your user name and password." & vbCrLf & Error(Err), 16, "Charles Hooper's Oracle Database Time Model Viewer")
        Exit Sub
    End If

    'More code will be copied here
    '
    '
    '
   
    TimerEvent
End Sub 

At this point, after replacing MyUsername, MyPassword, and MyDB (the DB name from the tnsnames.ora file) with the appropriate logon credentials for one of your databases, you should be able to verify that the database connection works by running the UserForm_Initialize subroutine, simply by pressing the F5 key on the keyboard.  If no error message appears on the screen, the macro is able to connect to the database.  Now that we have verified that database connectivity works as expected, let’s close the UserForm’s window and add a little more code to the UserForm_Initialize subroutine.  Move the cursor just above the ‘More code will be copied here line and press the Enter key a couple of times to move that line down a little.  Move the cursor back up to one of the blank lines and paste in the following code which sets up a couple of the SQL statements that will be used by this tool:

    lngTimerTriggerSeconds = 60
    sglSessionMinimumPercent = 0.1  '10% of the total for the time period needed to be included in the detail
    Set snpDataWait = New ADODB.Recordset
    Set comDataWait = New ADODB.Command
    Set snpDataOSStat = New ADODB.Recordset
    Set comDataOSStat = New ADODB.Command
    Set snpDataSysTime = New ADODB.Recordset
    Set comDataSysTime = New ADODB.Command
    Set snpDataSessTime = New ADODB.Recordset
    Set comDataSessTime = New ADODB.Command
    Set comTrace = New ADODB.Command
    Set snpXPLAN = New ADODB.Recordset
    Set comXPLAN = New ADODB.Command
    Set snpSQLChildReason = New ADODB.Recordset
    Set comSQLChildReason = New ADODB.Command
    Set snpSQLChildBind = New ADODB.Recordset
    Set comSQLChildBind = New ADODB.Command
    Set snpSessionWait = New ADODB.Recordset
    Set comSessionWait = New ADODB.Command
    Set snpSYSSTAT = New ADODB.Recordset
    Set comSYSSTAT = New ADODB.Command

    With comDataOSStat
        strSQL = "SELECT" & vbCrLf
        strSQL = strSQL & "  STAT_NAME," & vbCrLf
        strSQL = strSQL & "  VALUE" & vbCrLf
        strSQL = strSQL & "FROM" & vbCrLf
        strSQL = strSQL & "  V$OSSTAT" & vbCrLf
        strSQL = strSQL & "WHERE" & vbCrLf
        strSQL = strSQL & "  STAT_NAME IN ('NUM_CPUS','IDLE_TIME','BUSY_TIME','USER_TIME','SYS_TIME')"

        .CommandText = strSQL
        .CommandType = adCmdText
        .CommandTimeout = 30
        .ActiveConnection = dbDatabase
    End With

    With comDataSysTime
        strSQL = "SELECT" & vbCrLf
        strSQL = strSQL & "  VALUE," & vbCrLf
        strSQL = strSQL & "  STAT_NAME" & vbCrLf
        strSQL = strSQL & "FROM" & vbCrLf
        strSQL = strSQL & "  V$SYS_TIME_MODEL"

        .CommandText = strSQL
        .CommandType = adCmdText
        .CommandTimeout = 30
        .ActiveConnection = dbDatabase
    End With

    With comDataSessTime
        strSQL = "SELECT" & vbCrLf
        strSQL = strSQL & "  S.SID," & vbCrLf
        strSQL = strSQL & "  S.SERIAL#," & vbCrLf
        strSQL = strSQL & "  S.STATUS," & vbCrLf
        strSQL = strSQL & "  NVL(S.USERNAME,' ') USERNAME," & vbCrLf
        strSQL = strSQL & "  NVL(S.MACHINE,' ') MACHINE," & vbCrLf
        strSQL = strSQL & "  NVL(S.PROGRAM,' ') PROGRAM," & vbCrLf
        strSQL = strSQL & "  NVL(S.SQL_ID,NVL(S.PREV_SQL_ID,' ')) SQL_ID," & vbCrLf
        strSQL = strSQL & "  NVL(S.SQL_CHILD_NUMBER,NVL(S.PREV_CHILD_NUMBER,0)) SQL_CHILD_NUMBER," & vbCrLf
        strSQL = strSQL & "  STM.VALUE," & vbCrLf
        strSQL = strSQL & "  STM.STAT_NAME" & vbCrLf
        strSQL = strSQL & "FROM" & vbCrLf
        strSQL = strSQL & "  V$SESS_TIME_MODEL STM," & vbCrLf
        strSQL = strSQL & "  V$SESSION S" & vbCrLf
        strSQL = strSQL & "WHERE" & vbCrLf
        strSQL = strSQL & "  S.SID=STM.SID" & vbCrLf
        strSQL = strSQL & "ORDER BY" & vbCrLf
        strSQL = strSQL & "  S.USERNAME," & vbCrLf
        strSQL = strSQL & "  S.PROGRAM," & vbCrLf
        strSQL = strSQL & "  S.SID"

        .CommandText = strSQL
        .CommandType = adCmdText
        .CommandTimeout = 30
        .ActiveConnection = dbDatabase
    End With

    With comSYSSTAT
        strSQL = "SELECT" & vbCrLf
        strSQL = strSQL & "  NAME," & vbCrLf
        strSQL = strSQL & "  VALUE" & vbCrLf
        strSQL = strSQL & "FROM" & vbCrLf
        strSQL = strSQL & "  V$SYSSTAT" & vbCrLf
        strSQL = strSQL & "WHERE" & vbCrLf
        strSQL = strSQL & "  NAME IN ('CPU used by this session','parse time cpu','recursive cpu usage','parse count (total)','parse count (hard)','parse count (failures)','session cursor cache hits')"

        .CommandText = strSQL
        .CommandType = adCmdText
        .ActiveConnection = dbDatabase
    End With 

We will add more later, but that is sufficient for a starting point.  Just below the End Sub in the UserForm_Initialize procedure, add the following code, which will perform clean up when the UserForm is closed:

Private Sub UserForm_Terminate()
    intKillFlag = True

    If dbDatabase.State = 1 Then
        dbDatabase.Close
    End If

    Set snpDataWait = Nothing
    Set comDataWait = Nothing
    Set snpDataOSStat = Nothing
    Set comDataOSStat = Nothing
    Set snpDataSysTime = Nothing
    Set comDataSysTime = Nothing
    Set snpDataSessTime = Nothing
    Set comDataSessTime = Nothing
    Set comTrace = Nothing
    Set snpXPLAN = Nothing
    Set comXPLAN = Nothing
    Set snpSQLChildReason = Nothing
    Set comSQLChildReason = Nothing
    Set snpSQLChildBind = Nothing
    Set comSQLChildBind = Nothing
    Set snpSessionWait = Nothing
    Set comSessionWait = Nothing
    Set snpSYSSTAT = Nothing
    Set comSYSSTAT = Nothing
    Set dbDatabase = Nothing
End Sub

Let’s switch back to the design of the UserForm (if you cannot see the UserForm’s window, right-click frmTimeModel below Microsoft Excel Objects and select View Object from the menu), where we will add a couple of labels to the form.  This will be a little time consuming, but if you create one of the white box labels and a heading label, you can copy and paste the two labels as many times as is necessary (hold down the shift key to select more than one label to copy).  We will need a total of 11 labels with BackColor property set to &H00FFFFFF&  (white) and with the BorderStyle property set to 1 – fmBorderStyleSingle and with the TextAlign property set to 3 – fmTextAlignRight - we will also need a total of 11 plain labels with the TextAlign property set to 2 – fmTextAlignCenter

Set the (Name) property of the white background labels using the following list (one name per label): lblCPUs, lblBusyTime, lblIdleTime, lblBusyPercent, lblUserMode, lblKernelMode, lblUserModePercent, lblCPUUsedBySession, lblParseTimeCPU, lblRecursiveCPUUsage, lblOtherCPU

For the 11 plain labels with the centered text, change the Caption property of those labels to identify the contents (such as CPUs, Busy Time, etc.) of the closest white background label.  When the additions are complete, your UserForm might look something like the picture below:

Now we need to switch back to the code for the frmTimeModel UserForm and add a little more code to actually query the database.  Scroll up toward the top of the code in the UserForm, and locate this line:

Dim intExcludeIdleWaits As Integer          'Indicates whether or not to exclude idle wait events 

Move the cursor to the end of that line and press the Enter key a couple of times to add a couple of blank lines.  On one of the new blank lines paste the following code, which will query the database when executed:

Public Sub ReadData()
    Dim i As Integer
    Dim j As Integer
    Dim k As Integer
    Dim strSQL As String

    On Error Resume Next

    dteLastUpdateDate = Now

    Set snpDataOSStat = comDataOSStat.Execute
    If Not (snpDataOSStat Is Nothing) Then
        Do While Not (snpDataOSStat.EOF)
          Select Case CStr(snpDataOSStat("stat_name"))
            Case "NUM_CPUS"
              intNumCPUs = CInt(snpDataOSStat("value"))
            Case "IDLE_TIME"
              dblIdleTimeLast = dblIdleTime
              dblIdleTime = CDbl(snpDataOSStat("value"))
            Case "BUSY_TIME"
              dblBusyTimeLast = dblBusyTime
              dblBusyTime = CDbl(snpDataOSStat("value"))
            Case "USER_TIME"
              dblUserTimeLast = dblUserTime
              dblUserTime = CDbl(snpDataOSStat("value"))
            Case "SYS_TIME"
              dblSysTimeLast = dblSysTime
              dblSysTime = CDbl(snpDataOSStat("value"))
          End Select

          snpDataOSStat.MoveNext
        Loop
    End If

    Set snpDataSysTime = comDataSysTime.Execute
    If Not (snpDataSysTime Is Nothing) Then
        Do While Not (snpDataSysTime.EOF)
          Select Case CStr(snpDataSysTime("stat_name"))
            Case "DB CPU"
              dblDBCPULast = dblDBCPU
              dblDBCPU = CDbl(snpDataSysTime("value"))
            Case "DB time"
              dblDBTimeLast = dblDBTime
              dblDBTime = CDbl(snpDataSysTime("value"))
            Case "Java execution elapsed time"
              dblJavaTimeLast = dblJavaTime
              dblJavaTime = CDbl(snpDataSysTime("value"))
            Case "PL/SQL compilation elapsed time"
              dblPLSQLCompileLast = dblPLSQLCompile
              dblPLSQLCompile = CDbl(snpDataSysTime("value"))
            Case "PL/SQL execution elapsed time"
              dblPLSQLExecutionLast = dblPLSQLExecution
              dblPLSQLExecution = CDbl(snpDataSysTime("value"))
            Case "RMAN cpu time (backup/restore)"
              dblRMANCPULast = dblRMANCPU
              dblRMANCPU = CDbl(snpDataSysTime("value"))
            Case "background cpu time"
              dblBackgroundCPULast = dblBackgroundCPU
              dblBackgroundCPU = CDbl(snpDataSysTime("value"))
            Case "background elapsed time"
              dblBackgroundElapsedLast = dblBackgroundElapsed
              dblBackgroundElapsed = CDbl(snpDataSysTime("value"))
            Case "connection management call elapsed time"
              dblConnectMgmtLast = dblConnectMgmt
              dblConnectMgmt = CDbl(snpDataSysTime("value"))
            Case "failed parse (out of shared memory) elapsed time"
              dblFailedParseMemoryLast = dblFailedParseMemory
              dblFailedParseMemory = CDbl(snpDataSysTime("value"))
            Case "failed parse elapsed time"
              dblFailedParseElapsedLast = dblFailedParseElapsed
              dblFailedParseElapsed = CDbl(snpDataSysTime("value"))
            Case "hard parse (bind mismatch) elapsed time"
              dblHardParseBindLast = dblHardParseBind
              dblHardParseBind = CDbl(snpDataSysTime("value"))
            Case "hard parse (sharing criteria) elapsed time"
              dblHardParseSharingLast = dblHardParseSharing
              dblHardParseSharing = CDbl(snpDataSysTime("value"))
            Case "hard parse elapsed time"
              dblHardParseElapsedLast = dblHardParseElapsed
              dblHardParseElapsed = CDbl(snpDataSysTime("value"))
            Case "inbound PL/SQL rpc elapsed time"
              dblInboundPLSQLLast = dblInboundPLSQL
              dblInboundPLSQL = CDbl(snpDataSysTime("value"))
            Case "parse time elapsed"
              dblParseTimeElapsedLast = dblParseTimeElapsed
              dblParseTimeElapsed = CDbl(snpDataSysTime("value"))
            Case "repeated bind elapsed time"
              dblRepeatedBindLast = dblRepeatedBind
              dblRepeatedBind = CDbl(snpDataSysTime("value"))
            Case "sequence load elapsed time"
              dblSequenceLoadLast = dblSequenceLoad
              dblSequenceLoad = CDbl(snpDataSysTime("value"))
            Case "sql execute elapsed time"
              dblSQLExecuteTimeLast = dblSQLExecuteTime
              dblSQLExecuteTime = CDbl(snpDataSysTime("value"))
          End Select

          snpDataSysTime.MoveNext
        Loop
    End If

    For j = 1 To intSessionCount
        intSessionExists(j) = False
    Next j

    Set snpDataSessTime = comDataSessTime.Execute
    If Not (snpDataSessTime Is Nothing) Then
        Do While Not (snpDataSessTime.EOF)
          'Find the matching session's previous statistics
          If (lngSIDLast <> CLng(snpDataSessTime("sid"))) Or (lngSerialLast <> CLng(snpDataSessTime("serial#"))) Then
            'This is a different session, see if the session was previously captured
            lngSIDLast = CLng(snpDataSessTime("sid"))
            lngSerialLast = CLng(snpDataSessTime("serial#"))

            intSessionCurrent = intSessionCount + 1
            For j = 1 To intSessionCount
              If (lngSID(j) = CLng(snpDataSessTime("sid"))) And (lngSerial(j) = CLng(snpDataSessTime("serial#"))) Then
                intSessionCurrent = j
                Exit For
              End If
            Next j
            If intSessionCurrent = intSessionCount + 1 Then
              intSessionCount = intSessionCount + 1
              lngSID(intSessionCurrent) = CLng(snpDataSessTime("sid"))
              lngSerial(intSessionCurrent) = CLng(snpDataSessTime("serial#"))
              strSessionOther(intSessionCurrent) = CStr(snpDataSessTime("machine")) & " ~ " & _
                 CStr(snpDataSessTime("username")) & " ~ " & _
                 CStr(snpDataSessTime("program")) & " ~ "
              If snpDataSessTime("sql_id") <> " " Then
                strSessionOther(intSessionCurrent) = strSessionOther(intSessionCurrent) & "SQL_ID/Child: " & _
                  CStr(snpDataSessTime("sql_id")) & "/" & CStr(snpDataSessTime("sql_child_number"))
                If UCase(snpDataSessTime("status")) = "ACTIVE" Then
                    strSessionOther(intSessionCurrent) = strSessionOther(intSessionCurrent) & " (A)"
                End If
                strSQLID(intSessionCurrent) = CStr(snpDataSessTime("sql_id")) & "/" & CStr(snpDataSessTime("sql_child_number"))
              Else
                strSQLID(intSessionCurrent) = ""
              End If
            End If
          End If

          intSessionExists(intSessionCurrent) = True
          Select Case CStr(snpDataSessTime("stat_name"))
            Case "DB CPU"
              dblDBCPUSLast(intSessionCurrent) = dblDBCPUS(intSessionCurrent)
              dblDBCPUS(intSessionCurrent) = CDbl(snpDataSessTime("value"))
            Case "DB time"
              dblDBTimeSLast(intSessionCurrent) = dblDBTimeS(intSessionCurrent)
              dblDBTimeS(intSessionCurrent) = CDbl(snpDataSessTime("value"))
            Case "Java execution elapsed time"
              dblJavaTimeSLast(intSessionCurrent) = dblJavaTimeS(intSessionCurrent)
              dblJavaTimeS(intSessionCurrent) = CDbl(snpDataSessTime("value"))
            Case "PL/SQL compilation elapsed time"
              dblPLSQLCompileSLast(intSessionCurrent) = dblPLSQLCompileS(intSessionCurrent)
              dblPLSQLCompileS(intSessionCurrent) = CDbl(snpDataSessTime("value"))
            Case "PL/SQL execution elapsed time"
              dblPLSQLExecutionSLast(intSessionCurrent) = dblPLSQLExecutionS(intSessionCurrent)
              dblPLSQLExecutionS(intSessionCurrent) = CDbl(snpDataSessTime("value"))
            Case "RMAN cpu time (backup/restore)"
              dblRMANCPUSLast(intSessionCurrent) = dblRMANCPUS(intSessionCurrent)
              dblRMANCPUS(intSessionCurrent) = CDbl(snpDataSessTime("value"))
            Case "background cpu time"
              dblBackgroundCPUSLast(intSessionCurrent) = dblBackgroundCPUS(intSessionCurrent)
              dblBackgroundCPUS(intSessionCurrent) = CDbl(snpDataSessTime("value"))
            Case "background elapsed time"
              dblBackgroundElapsedSLast(intSessionCurrent) = dblBackgroundElapsedS(intSessionCurrent)
              dblBackgroundElapsedS(intSessionCurrent) = CDbl(snpDataSessTime("value"))
            Case "connection management call elapsed time"
              dblConnectMgmtSLast(intSessionCurrent) = dblConnectMgmtS(intSessionCurrent)
              dblConnectMgmtS(intSessionCurrent) = CDbl(snpDataSessTime("value"))
            Case "failed parse (out of shared memory) elapsed time"
              dblFailedParseMemorySLast(intSessionCurrent) = dblFailedParseMemoryS(intSessionCurrent)
              dblFailedParseMemoryS(intSessionCurrent) = CDbl(snpDataSessTime("value"))
            Case "failed parse elapsed time"
              dblFailedParseElapsedSLast(intSessionCurrent) = dblFailedParseElapsedS(intSessionCurrent)
              dblFailedParseElapsedS(intSessionCurrent) = CDbl(snpDataSessTime("value"))
            Case "hard parse (bind mismatch) elapsed time"
              dblHardParseBindSLast(intSessionCurrent) = dblHardParseBindS(intSessionCurrent)
              dblHardParseBindS(intSessionCurrent) = CDbl(snpDataSessTime("value"))
            Case "hard parse (sharing criteria) elapsed time"
              dblHardParseSharingSLast(intSessionCurrent) = dblHardParseSharingS(intSessionCurrent)
              dblHardParseSharingS(intSessionCurrent) = CDbl(snpDataSessTime("value"))
            Case "hard parse elapsed time"
              dblHardParseElapsedSLast(intSessionCurrent) = dblHardParseElapsedS(intSessionCurrent)
              dblHardParseElapsedS(intSessionCurrent) = CDbl(snpDataSessTime("value"))
            Case "inbound PL/SQL rpc elapsed time"
              dblInboundPLSQLSLast(intSessionCurrent) = dblInboundPLSQLS(intSessionCurrent)
              dblInboundPLSQLS(intSessionCurrent) = CDbl(snpDataSessTime("value"))
            Case "parse time elapsed"
              dblParseTimeElapsedSLast(intSessionCurrent) = dblParseTimeElapsedS(intSessionCurrent)
              dblParseTimeElapsedS(intSessionCurrent) = CDbl(snpDataSessTime("value"))
            Case "repeated bind elapsed time"
              dblRepeatedBindSLast(intSessionCurrent) = dblRepeatedBindS(intSessionCurrent)
              dblRepeatedBindS(intSessionCurrent) = CDbl(snpDataSessTime("value"))
            Case "sequence load elapsed time"
              dblSequenceLoadSLast(intSessionCurrent) = dblSequenceLoadS(intSessionCurrent)
              dblSequenceLoadS(intSessionCurrent) = CDbl(snpDataSessTime("value"))
            Case "sql execute elapsed time"
              dblSQLExecuteTimeSLast(intSessionCurrent) = dblSQLExecuteTimeS(intSessionCurrent)
              dblSQLExecuteTimeS(intSessionCurrent) = CDbl(snpDataSessTime("value"))
          End Select

          snpDataSessTime.MoveNext
        Loop
        snpDataSessTime.Close
    End If

    Set snpSYSSTAT = comSYSSTAT.Execute
    If Not (snpSYSSTAT Is Nothing) Then
        Do While Not (snpSYSSTAT.EOF)
            Select Case snpSYSSTAT("name")
                Case "CPU used by this session"
                    dblCPUUsedByThisSessionLast = dblCPUUsedByThisSession
                    dblCPUUsedByThisSession = CDbl(snpSYSSTAT("value")) / 100
                Case "parse time cpu"
                    dblParseTimeCPULast = dblParseTimeCPU
                    dblParseTimeCPU = CDbl(snpSYSSTAT("value")) / 100
                Case "recursive cpu usage"
                    dblRecursiveCPUUsageLast = dblRecursiveCPUUsage
                    dblRecursiveCPUUsage = CDbl(snpSYSSTAT("value")) / 100
                Case "parse count (total)"
                    lngParseCountTotalLast = lngParseCountTotal
                    lngParseCountTotal = snpSYSSTAT("value")
                Case "parse count (hard)"
                    lngParseCountHardLast = lngParseCountHard
                    lngParseCountHard = snpSYSSTAT("value")
                Case "parse count (failures)"
                    lngParseCountFailuresLast = lngParseCountFailures
                    lngParseCountFailures = snpSYSSTAT("value")
                Case "session cursor cache hits"
                    lngSessionCacheHitsLast = lngSessionCacheHits
                    lngSessionCacheHits = snpSYSSTAT("value")
            End Select

            snpSYSSTAT.MoveNext
        Loop
        snpSYSSTAT.Close
    End If

    dteLastLoopStart = Now
End Sub 

As you are probably able to tell, the above code reads a lot of data from the database and places that data into variables.  Now we need code to display the query results on the UserForm.  Paste this code directly below the code that was just pasted:

Public Sub UpdateDisplay()
    Dim i As Integer
    Dim j As Integer
    Dim k As Integer
    Dim sglColor As Single
    Dim lngResult As Long
    Dim dblDBTimeDelta As Double
    Dim dblBusyTimeSecondsDelta As Double
    Dim strAT As String
    Dim strOut As String
    Dim strLine As String
    Dim strLastWaitClass As String
    Dim intLastWaitClassRow As Integer
    Dim sglWaitClassTime As Single
    Dim sglTotalWaitTime As Single

    On Error Resume Next

    intActivated = False
'    If chkDisplaySessionDetail = 0 Then
'        intDisplaySessionDetail = False
'    Else
'        intDisplaySessionDetail = True
'    End If
'    sglSessionMinimumPercent = Val(cboSessionMinimumPercent.Text) / 100
    If sglSessionMinimumPercent = 0 Then
        sglSessionMinimumPercent = 0.1
    End If

    lblCPUs = Format(intNumCPUs)
    lblBusyTime = Format((dblBusyTime - dblBusyTimeLast) / 100, "0.00")
    lblIdleTime = Format((dblIdleTime - dblIdleTimeLast) / 100, "0.00")
    lblBusyPercent = Format(((dblBusyTime - dblBusyTimeLast) / ((dblBusyTime - dblBusyTimeLast) + (dblIdleTime - dblIdleTimeLast)) * 100), "0.00")
    lblUserMode = Format((dblUserTime - dblUserTimeLast) / 100, "0.00")
    lblKernelMode = Format((dblSysTime - dblSysTimeLast) / 100, "0.00")
    lblUserModePercent = Format(((dblUserTime - dblUserTimeLast) / ((dblUserTime - dblUserTimeLast) + (dblSysTime - dblSysTimeLast)) * 100), "0.00")

    lblCPUUsedBySession = Format(dblCPUUsedByThisSession - dblCPUUsedByThisSessionLast, "0.00")
    lblParseTimeCPU = Format(dblParseTimeCPU - dblParseTimeCPULast, "0.00")
    lblRecursiveCPUUsage = Format(dblRecursiveCPUUsage - dblRecursiveCPUUsageLast, "0.00")
    lblOtherCPU = Format((dblCPUUsedByThisSession - dblCPUUsedByThisSessionLast) - (dblParseTimeCPU - dblParseTimeCPULast) - (dblRecursiveCPUUsage - dblRecursiveCPUUsageLast), "0.00")

    dblBusyTimeSecondsDelta = (dblBusyTime - dblBusyTimeLast) / 100

    strAT = String(Len(Format(((dblBackgroundElapsed - dblBackgroundElapsedLast) + (dblDBTime - dblDBTimeLast)) / 1000000, "0.00")), "@")

    'tvTimeModel.Visible = False
    tvTimeModel.Nodes.Clear
    tvTimeModel.Nodes.Add , , "BackgroundElapsedTime", Format(Format((dblBackgroundElapsed - dblBackgroundElapsedLast) / 1000000, "0.00"), strAT) & " Background Elapsed Time"
    If ((dblBackgroundElapsed - dblBackgroundElapsedLast) <> 0) And (intDisplaySessionDetail = True) Then
        For j = 1 To intSessionCount
            If intSessionExists(j) = True Then
                If ((dblBackgroundElapsedS(j) - dblBackgroundElapsedSLast(j)) / (dblBackgroundElapsed - dblBackgroundElapsedLast) >= sglSessionMinimumPercent) Then
                    tvTimeModel.Nodes.Add "BackgroundElapsedTime", tvwChild, "SESSIONBackgroundElapsedTime_" & Format(j), "-- " & Format(Format((dblBackgroundElapsedS(j) - dblBackgroundElapsedSLast(j)) / 1000000, "0.00"), strAT) & "  SID: " & Format(lngSID(j)) & " Serial #: " & Format(lngSerial(j)) & " " & strSessionOther(j)
                    sglColor = Round((dblBackgroundElapsedS(j) - dblBackgroundElapsedSLast(j)) / (dblBackgroundElapsed - dblBackgroundElapsedLast) * 255)
                    If sglColor > 255 Then
                        sglColor = 255
                    Else
                        If sglColor < 0 Then
                            sglColor = 0
                        End If
                    End If
                    tvTimeModel.Nodes(tvTimeModel.Nodes.Count).BackColor = RGB(255, 255 - sglColor, 0)
                End If
            End If
        Next j
    End If

    strLine = Format(Format((dblBackgroundCPU - dblBackgroundCPULast) / 1000000, "0.00"), strAT) & " Background CPU Time"
    If (dblBackgroundElapsed - dblBackgroundElapsedLast) <> 0 Then
        strLine = strLine & " (" & Format((dblBackgroundCPU - dblBackgroundCPULast) / (dblBackgroundElapsed - dblBackgroundElapsedLast), "0.00%") & " of Background Time)"
    End If
    If dblBusyTimeSecondsDelta <> 0 Then
        strLine = strLine & " (" & Format((dblBackgroundCPU - dblBackgroundCPULast) / 1000000 / dblBusyTimeSecondsDelta, "0.00%") & " of Total Consumed Server CPU)"
    End If
    tvTimeModel.Nodes.Add "BackgroundElapsedTime", tvwChild, "BackgroundCPU", strLine
    If ((dblBackgroundCPU - dblBackgroundCPULast) <> 0) And (intDisplaySessionDetail = True) Then
        For j = 1 To intSessionCount
            If intSessionExists(j) = True Then
                If ((dblBackgroundCPUS(j) - dblBackgroundCPUSLast(j)) / (dblBackgroundCPU - dblBackgroundCPULast) >= sglSessionMinimumPercent) Then
                    tvTimeModel.Nodes.Add "BackgroundCPU", tvwChild, "SESSIONBackgroundCPU_" & Format(j), "-- " & Format(Format((dblBackgroundCPUS(j) - dblBackgroundCPUSLast(j)) / 1000000, "0.00"), strAT) & "  SID: " & Format(lngSID(j)) & " Serial #: " & Format(lngSerial(j)) & " " & strSessionOther(j)
                    sglColor = Round((dblBackgroundCPUS(j) - dblBackgroundCPUSLast(j)) / (dblBackgroundCPU - dblBackgroundCPULast) * 255)
                    If sglColor > 255 Then
                        sglColor = 255
                    Else
                        If sglColor < 0 Then
                            sglColor = 0
                        End If
                    End If
                    tvTimeModel.Nodes(tvTimeModel.Nodes.Count).BackColor = RGB(255, 255 - sglColor, 0)
                End If
            End If
        Next j
    End If

    strLine = Format(Format((dblRMANCPU - dblRMANCPULast) / 1000000, "0.00"), strAT) & " RMAN CPU Time (Backup/Restore)"
    If (dblBackgroundElapsed - dblBackgroundElapsedLast) <> 0 Then
        strLine = strLine & " (" & Format((dblRMANCPU - dblRMANCPULast) / (dblBackgroundElapsed - dblBackgroundElapsedLast), "0.00%") & " of Background Time)"
    End If
    If (dblBackgroundCPU - dblBackgroundCPULast) <> 0 Then
        strLine = strLine & " (" & Format((dblRMANCPU - dblRMANCPULast) / (dblBackgroundCPU - dblBackgroundCPULast), "0.00%") & " of Background CPU)"
    End If
    If dblBusyTimeSecondsDelta <> 0 Then
        strLine = strLine & " (" & Format((dblRMANCPU - dblRMANCPULast) / 1000000 / dblBusyTimeSecondsDelta, "0.00%") & " of Total Consumed Server CPU)"
    End If
    tvTimeModel.Nodes.Add "BackgroundCPU", tvwChild, "RMANCPU", strLine
    If ((dblRMANCPU - dblRMANCPULast) <> 0) And (intDisplaySessionDetail = True) Then
        For j = 1 To intSessionCount
            If intSessionExists(j) = True Then
                If ((dblRMANCPUS(j) - dblRMANCPUSLast(j)) / (dblRMANCPU - dblRMANCPULast) >= sglSessionMinimumPercent) Then
                    tvTimeModel.Nodes.Add "RMANCPU", tvwChild, "SESSIONRMANCPU_" & Format(j), "-- " & Format(Format((dblRMANCPUS(j) - dblRMANCPUSLast(j)) / 1000000, "0.00"), strAT) & "  SID: " & Format(lngSID(j)) & " Serial #: " & Format(lngSerial(j)) & " " & strSessionOther(j)
                    sglColor = Round((dblRMANCPUS(j) - dblRMANCPUSLast(j)) / (dblRMANCPU - dblRMANCPULast) * 255)
                    If sglColor > 255 Then
                        sglColor = 255
                    Else
                        If sglColor < 0 Then
                            sglColor = 0
                        End If
                    End If
                    tvTimeModel.Nodes(tvTimeModel.Nodes.Count).BackColor = RGB(255, 255 - sglColor, 0)
                End If
            End If
        Next j
    End If

    dblDBTimeDelta = dblDBTime - dblDBTimeLast
    tvTimeModel.Nodes.Add , , "DBTime", Format(Format((dblDBTime - dblDBTimeLast) / 1000000, "0.00"), strAT) & " DB Time"
    If ((dblDBTime - dblDBTimeLast) <> 0) And (intDisplaySessionDetail = True) Then
        For j = 1 To intSessionCount
            If intSessionExists(j) = True Then
                If ((dblDBTimeS(j) - dblDBTimeSLast(j)) / (dblDBTime - dblDBTimeLast) >= sglSessionMinimumPercent) Then
                    tvTimeModel.Nodes.Add "DBTime", tvwChild, "SESSIONDBTime_" & Format(j), "-- " & Format(Format((dblDBTimeS(j) - dblDBTimeSLast(j)) / 1000000, "0.00"), strAT) & "  SID: " & Format(lngSID(j)) & " Serial #: " & Format(lngSerial(j)) & " " & strSessionOther(j)
                    sglColor = Round((dblDBTimeS(j) - dblDBTimeSLast(j)) / (dblDBTime - dblDBTimeLast) * 255)
                    If sglColor > 255 Then
                        sglColor = 255
                    Else
                        If sglColor < 0 Then
                            sglColor = 0
                        End If
                    End If
                    tvTimeModel.Nodes(tvTimeModel.Nodes.Count).BackColor = RGB(255, 255 - sglColor, 0)
                End If
            End If
        Next j
    End If

    strLine = Format(Format((dblDBCPU - dblDBCPULast) / 1000000, "0.00"), strAT) & " DB CPU"
    If dblDBTimeDelta <> 0 Then
        strLine = strLine & " (" & Format((dblDBCPU - dblDBCPULast) / dblDBTimeDelta, "0.00%") & " of DB Time)"
    End If
    If dblBusyTimeSecondsDelta <> 0 Then
        strLine = strLine & " (" & Format((dblDBCPU - dblDBCPULast) / 1000000 / dblBusyTimeSecondsDelta, "0.00%") & " of Total Consumed Server CPU)"
    End If
    tvTimeModel.Nodes.Add "DBTime", tvwChild, "DBCPU", strLine
    If ((dblDBCPU - dblDBCPULast) <> 0) And (intDisplaySessionDetail = True) Then
        For j = 1 To intSessionCount
            If intSessionExists(j) = True Then
                If ((dblDBCPUS(j) - dblDBCPUSLast(j)) / (dblDBCPU - dblDBCPULast) >= sglSessionMinimumPercent) Then
                    tvTimeModel.Nodes.Add "DBCPU", tvwChild, "SESSIONDBCPU_" & Format(j), "-- " & Format(Format((dblDBCPUS(j) - dblDBCPUSLast(j)) / 1000000, "0.00"), strAT) & "  SID: " & Format(lngSID(j)) & " Serial #: " & Format(lngSerial(j)) & " " & strSessionOther(j)
                    sglColor = Round((dblDBCPUS(j) - dblDBCPUSLast(j)) / (dblDBCPU - dblDBCPULast) * 255)
                    If sglColor > 255 Then
                        sglColor = 255
                    Else
                        If sglColor < 0 Then
                            sglColor = 0
                        End If
                    End If
                    tvTimeModel.Nodes(tvTimeModel.Nodes.Count).BackColor = RGB(255, 255 - sglColor, 0)
                End If
            End If
        Next j
    End If

    strLine = Format(Format((dblConnectMgmt - dblConnectMgmtLast) / 1000000, "0.00"), strAT) & " Connection Management Call Elapsed Time"
    If dblDBTimeDelta <> 0 Then
        strLine = strLine & " (" & Format((dblConnectMgmt - dblConnectMgmtLast) / dblDBTimeDelta, "0.00%") & " of DB Time)"
    End If
    tvTimeModel.Nodes.Add "DBTime", tvwChild, "ConnectionManagementCallElapsedTime", strLine
    If ((dblConnectMgmt - dblConnectMgmtLast) <> 0) And (intDisplaySessionDetail = True) Then
        For j = 1 To intSessionCount
            If intSessionExists(j) = True Then
                If ((dblConnectMgmtS(j) - dblConnectMgmtSLast(j)) / (dblConnectMgmt - dblConnectMgmtLast) >= sglSessionMinimumPercent) Then
                    tvTimeModel.Nodes.Add "ConnectionManagementCallElapsedTime", tvwChild, "SESSIONConMgm_" & Format(j), "-- " & Format(Format((dblConnectMgmtS(j) - dblConnectMgmtSLast(j)) / 1000000, "0.00"), strAT) & "  SID: " & Format(lngSID(j)) & " Serial #: " & Format(lngSerial(j)) & " " & strSessionOther(j)
                    sglColor = Round((dblConnectMgmtS(j) - dblConnectMgmtSLast(j)) / (dblConnectMgmt - dblConnectMgmtLast) * 255)
                    If sglColor > 255 Then
                        sglColor = 255
                    Else
                        If sglColor < 0 Then
                            sglColor = 0
                        End If
                    End If
                    tvTimeModel.Nodes(tvTimeModel.Nodes.Count).BackColor = RGB(255, 255 - sglColor, 0)
                End If
            End If
        Next j
    End If

    strLine = Format(Format((dblSequenceLoad - dblSequenceLoadLast) / 1000000, "0.00"), strAT) & " Sequence Load Elapsed Time"
    If dblDBTimeDelta <> 0 Then
        strLine = strLine & " (" & Format((dblSequenceLoad - dblSequenceLoadLast) / dblDBTimeDelta, "0.00%") & " of DB Time)"
    End If
    tvTimeModel.Nodes.Add "DBTime", tvwChild, "SequenceLoadElapsedTime", strLine
    If ((dblSequenceLoad - dblSequenceLoadLast) <> 0) And (intDisplaySessionDetail = True) Then
        For j = 1 To intSessionCount
            If intSessionExists(j) = True Then
                If ((dblSequenceLoadS(j) - dblSequenceLoadSLast(j)) / (dblSequenceLoad - dblSequenceLoadLast) >= sglSessionMinimumPercent) Then
                    tvTimeModel.Nodes.Add "SequenceLoadElapsedTime", tvwChild, "SESSIONSeqLoad_" & Format(j), "-- " & Format(Format((dblSequenceLoadS(j) - dblSequenceLoadSLast(j)) / 1000000, "0.00"), strAT) & "  SID: " & Format(lngSID(j)) & " Serial #: " & Format(lngSerial(j)) & " " & strSessionOther(j)
                    sglColor = Round((dblSequenceLoadS(j) - dblSequenceLoadSLast(j)) / (dblSequenceLoad - dblSequenceLoadLast) * 255)
                    If sglColor > 255 Then
                        sglColor = 255
                    Else
                        If sglColor < 0 Then
                            sglColor = 0
                        End If
                    End If
                    tvTimeModel.Nodes(tvTimeModel.Nodes.Count).BackColor = RGB(255, 255 - sglColor, 0)
                End If
            End If
        Next j
    End If

    strLine = Format(Format((dblSQLExecuteTime - dblSQLExecuteTimeLast) / 1000000, "0.00"), strAT) & " SQL Execute Elapsed Time"
    If dblDBTimeDelta <> 0 Then
        strLine = strLine & " (" & Format((dblSQLExecuteTime - dblSQLExecuteTimeLast) / dblDBTimeDelta, "0.00%") & " of DB Time)"
    End If
    tvTimeModel.Nodes.Add "DBTime", tvwChild, "SQLExecuteElapsedTime", strLine
    If ((dblSQLExecuteTime - dblSQLExecuteTimeLast) <> 0) And (intDisplaySessionDetail = True) Then
        For j = 1 To intSessionCount
            If intSessionExists(j) = True Then
                If ((dblSQLExecuteTimeS(j) - dblSQLExecuteTimeSLast(j)) / (dblSQLExecuteTime - dblSQLExecuteTimeLast) >= sglSessionMinimumPercent) Then
                    tvTimeModel.Nodes.Add "SQLExecuteElapsedTime", tvwChild, "SESSIONSQLExec_" & Format(j), "-- " & Format(Format((dblSQLExecuteTimeS(j) - dblSQLExecuteTimeSLast(j)) / 1000000, "0.00"), strAT) & "  SID: " & Format(lngSID(j)) & " Serial #: " & Format(lngSerial(j)) & " " & strSessionOther(j)
                    sglColor = Round((dblSQLExecuteTimeS(j) - dblSQLExecuteTimeSLast(j)) / (dblSQLExecuteTime - dblSQLExecuteTimeLast) * 255)
                    If sglColor > 255 Then
                        sglColor = 255
                    Else
                        If sglColor < 0 Then
                            sglColor = 0
                        End If
                    End If
                    tvTimeModel.Nodes(tvTimeModel.Nodes.Count).BackColor = RGB(255, 255 - sglColor, 0)
                End If
            End If
        Next j
    End If

    strLine = Format(Format((dblParseTimeElapsed - dblParseTimeElapsedLast) / 1000000, "0.00"), strAT) & " Parse Time Elapsed"
    If dblDBTimeDelta <> 0 Then
        strLine = strLine & " (" & Format((dblParseTimeElapsed - dblParseTimeElapsedLast) / dblDBTimeDelta, "0.00%") & " of DB Time)"
    End If
    If (lngParseCountTotal - lngParseCountTotalLast) <> 0 Then
        strLine = strLine & " (" & Format(lngParseCountTotal - lngParseCountTotalLast) & " Total Parses, " & Format(lngParseCountHard - lngParseCountHardLast) & " Hard Parses, " & Format((lngParseCountTotal - lngParseCountTotalLast) - (lngParseCountHard - lngParseCountHardLast)) & " Soft Parses with " & (lngSessionCacheHits - lngSessionCacheHitsLast) & " Session Cache Cursor Hits, " & Format(lngParseCountFailures - lngParseCountFailuresLast) & " Failed Parses)"
    End If
    tvTimeModel.Nodes.Add "DBTime", tvwChild, "ParseTimeElapsed", strLine
    If ((dblParseTimeElapsed - dblParseTimeElapsedLast) <> 0) And (intDisplaySessionDetail = True) Then
        For j = 1 To intSessionCount
            If intSessionExists(j) = True Then
                If ((dblParseTimeElapsedS(j) - dblParseTimeElapsedSLast(j)) / (dblParseTimeElapsed - dblParseTimeElapsedLast) >= sglSessionMinimumPercent) Then
                    tvTimeModel.Nodes.Add "ParseTimeElapsed", tvwChild, "SESSIONParseTimeElapsed_" & Format(j), "-- " & Format(Format((dblParseTimeElapsedS(j) - dblParseTimeElapsedSLast(j)) / 1000000, "0.00"), strAT) & "  SID: " & Format(lngSID(j)) & " Serial #: " & Format(lngSerial(j)) & " " & strSessionOther(j)
                    sglColor = Round((dblParseTimeElapsedS(j) - dblParseTimeElapsedSLast(j)) / (dblParseTimeElapsed - dblParseTimeElapsedLast) * 255)
                    If sglColor > 255 Then
                        sglColor = 255
                    Else
                        If sglColor < 0 Then
                            sglColor = 0
                        End If
                    End If
                    tvTimeModel.Nodes(tvTimeModel.Nodes.Count).BackColor = RGB(255, 255 - sglColor, 0)
                End If
            End If
        Next j
    End If

    strLine = Format(Format((dblHardParseElapsed - dblHardParseElapsedLast) / 1000000, "0.00"), strAT) & " Hard Parse Elapsed Time"
    If dblDBTimeDelta <> 0 Then
        strLine = strLine & " (" & Format((dblHardParseElapsed - dblHardParseElapsedLast) / dblDBTimeDelta, "0.00%") & " of DB Time)"
    End If
    If (dblParseTimeElapsed - dblParseTimeElapsedLast) <> 0 Then
        strLine = strLine & " (" & Format((dblHardParseElapsed - dblHardParseElapsedLast) / (dblParseTimeElapsed - dblParseTimeElapsedLast), "0.00%") & " of Parse Time)"
    End If
    If ((lngParseCountHard - lngParseCountHardLast) <> 0) And ((lngParseCountTotal - lngParseCountTotalLast) <> 0) Then
        strLine = strLine & " (" & Format((lngParseCountHard - lngParseCountHardLast) / (lngParseCountTotal - lngParseCountTotalLast), "0.00%") & " of All Parses are Hard Parses)"
    End If

    tvTimeModel.Nodes.Add "ParseTimeElapsed", tvwChild, "HardParseElapsedTime", strLine
    If ((dblHardParseElapsed - dblHardParseElapsedLast) <> 0) And (intDisplaySessionDetail = True) Then
        For j = 1 To intSessionCount
            If intSessionExists(j) = True Then
                If ((dblHardParseElapsedS(j) - dblHardParseElapsedSLast(j)) / (dblHardParseElapsed - dblHardParseElapsedLast) >= sglSessionMinimumPercent) Then
                    tvTimeModel.Nodes.Add "HardParseElapsedTime", tvwChild, "SESSIONHardParseTimeElapsed_" & Format(j), "-- " & Format(Format((dblHardParseElapsedS(j) - dblHardParseElapsedSLast(j)) / 1000000, "0.00"), strAT) & "  SID: " & Format(lngSID(j)) & " Serial #: " & Format(lngSerial(j)) & " " & strSessionOther(j)
                    sglColor = Round((dblHardParseElapsedS(j) - dblHardParseElapsedSLast(j)) / (dblHardParseElapsed - dblHardParseElapsedLast) * 255)
                    If sglColor > 255 Then
                        sglColor = 255
                    Else
                        If sglColor < 0 Then
                            sglColor = 0
                        End If
                    End If
                    tvTimeModel.Nodes(tvTimeModel.Nodes.Count).BackColor = RGB(255, 255 - sglColor, 0)
                End If
            End If
        Next j
    End If

    strLine = Format(Format((dblHardParseSharing - dblHardParseSharingLast) / 1000000, "0.00"), strAT) & " Hard Parse (Sharing Criteria) Elapsed Time"
    If dblDBTimeDelta <> 0 Then
        strLine = strLine & " (" & Format((dblHardParseSharing - dblHardParseSharingLast) / dblDBTimeDelta, "0.00%") & " of DB Time)"
    End If
    If (dblParseTimeElapsed - dblParseTimeElapsedLast) <> 0 Then
        strLine = strLine & " (" & Format((dblHardParseSharing - dblHardParseSharingLast) / (dblParseTimeElapsed - dblParseTimeElapsedLast), "0.00%") & " of Parse Time)"
    End If
    If (dblHardParseElapsed - dblHardParseElapsedLast) <> 0 Then
        strLine = strLine & " (" & Format((dblHardParseSharing - dblHardParseSharingLast) / (dblHardParseElapsed - dblHardParseElapsedLast), "0.00%") & " of Hard Parse Time)"
    End If
    tvTimeModel.Nodes.Add "HardParseElapsedTime", tvwChild, "HardParseSCElapsedTime", strLine
    If ((dblHardParseSharing - dblHardParseSharingLast) <> 0) And (intDisplaySessionDetail = True) Then
        For j = 1 To intSessionCount
            If intSessionExists(j) = True Then
                If ((dblHardParseSharingS(j) - dblHardParseSharingSLast(j)) / (dblHardParseSharing - dblHardParseSharingLast) >= sglSessionMinimumPercent) Then
                    tvTimeModel.Nodes.Add "HardParseSCElapsedTime", tvwChild, "SESSIONHardParseSCEElapsedTime_" & Format(j), "-- " & Format(Format((dblHardParseSharingS(j) - dblHardParseSharingSLast(j)) / 1000000, "0.00"), strAT) & "  SID: " & Format(lngSID(j)) & " Serial #: " & Format(lngSerial(j)) & " " & strSessionOther(j)
                    sglColor = Round((dblHardParseSharingS(j) - dblHardParseSharingSLast(j)) / (dblHardParseSharing - dblHardParseSharingLast) * 255)
                    If sglColor > 255 Then
                        sglColor = 255
                    Else
                        If sglColor < 0 Then
                            sglColor = 0
                        End If
                    End If
                    tvTimeModel.Nodes(tvTimeModel.Nodes.Count).BackColor = RGB(255, 255 - sglColor, 0)
                End If
            End If
        Next j
    End If

    strLine = Format(Format((dblHardParseBind - dblHardParseBindLast) / 1000000, "0.00"), strAT) & " Hard Parse (Bind Mismatch) Elapsed Time"
    If dblDBTimeDelta <> 0 Then
        strLine = strLine & " (" & Format((dblHardParseBind - dblHardParseBindLast) / dblDBTimeDelta, "0.00%") & " of DB Time)"
    End If
    If (dblParseTimeElapsed - dblParseTimeElapsedLast) <> 0 Then
        strLine = strLine & " (" & Format((dblHardParseBind - dblHardParseBindLast) / (dblParseTimeElapsed - dblParseTimeElapsedLast), "0.00%") & " of Parse Time)"
    End If
    If (dblHardParseElapsed - dblHardParseElapsedLast) <> 0 Then
        strLine = strLine & " (" & Format((dblHardParseBind - dblHardParseBindLast) / (dblHardParseElapsed - dblHardParseElapsedLast), "0.00%") & " of Hard Parse Time)"
    End If
    If (dblHardParseSharing - dblHardParseSharingLast) <> 0 Then
        strLine = strLine & " (" & Format((dblHardParseBind - dblHardParseBindLast) / (dblHardParseSharing - dblHardParseSharingLast), "0.00%") & " of Sharing Criteria Time)"
    End If
    tvTimeModel.Nodes.Add "HardParseSCElapsedTime", tvwChild, "HardParseBMElapsedTime", strLine
    If ((dblHardParseBind - dblHardParseBindLast) <> 0) And (intDisplaySessionDetail = True) Then
        For j = 1 To intSessionCount
            If intSessionExists(j) = True Then
                If ((dblHardParseBindS(j) - dblHardParseBindSLast(j)) / (dblHardParseBind - dblHardParseBindLast) >= sglSessionMinimumPercent) Then
                    tvTimeModel.Nodes.Add "HardParseBMElapsedTime", tvwChild, "SESSIONHardParseBMElapsedTime_" & Format(j), "-- " & Format(Format((dblHardParseBindS(j) - dblHardParseBindSLast(j)) / 1000000, "0.00"), strAT) & "  SID: " & Format(lngSID(j)) & " Serial #: " & Format(lngSerial(j)) & " " & strSessionOther(j)
                    sglColor = Round((dblHardParseBindS(j) - dblHardParseBindSLast(j)) / (dblHardParseBind - dblHardParseBindLast) * 255)
                    If sglColor > 255 Then
                        sglColor = 255
                    Else
                        If sglColor < 0 Then
                            sglColor = 0
                        End If
                    End If
                    tvTimeModel.Nodes(tvTimeModel.Nodes.Count).BackColor = RGB(255, 255 - sglColor, 0)
                End If
            End If
        Next j
    End If

    strLine = Format(Format((dblFailedParseElapsed - dblFailedParseElapsedLast) / 1000000, "0.00"), strAT) & " Failed Parse Elapsed Time"
    If dblDBTimeDelta <> 0 Then
        strLine = strLine & " (" & Format((dblFailedParseElapsed - dblFailedParseElapsedLast) / dblDBTimeDelta, "0.00%") & " of DB Time)"
    End If
    If (dblParseTimeElapsed - dblParseTimeElapsedLast) <> 0 Then
        strLine = strLine & " (" & Format((dblFailedParseElapsed - dblFailedParseElapsedLast) / (dblParseTimeElapsed - dblParseTimeElapsedLast), "0.00%") & " of Parse Time)"
    End If
    If ((lngParseCountFailures - lngParseCountFailuresLast) <> 0) And ((lngParseCountTotal - lngParseCountTotalLast) <> 0) Then
        strLine = strLine & " (" & Format((lngParseCountFailures - lngParseCountFailuresLast) / (lngParseCountTotal - lngParseCountTotalLast), "0.00%") & " of All Parses Failed)"
    End If
    tvTimeModel.Nodes.Add "ParseTimeElapsed", tvwChild, "FailedParseElapsedTime", strLine
    If ((dblFailedParseElapsed - dblFailedParseElapsedLast) <> 0) And (intDisplaySessionDetail = True) Then
        For j = 1 To intSessionCount
            If intSessionExists(j) = True Then
                If ((dblFailedParseElapsedS(j) - dblFailedParseElapsedSLast(j)) / (dblFailedParseElapsed - dblFailedParseElapsedLast) >= sglSessionMinimumPercent) Then
                    tvTimeModel.Nodes.Add "FailedParseElapsedTime", tvwChild, "SESSIONFailedParseElapsedTime_" & Format(j), "-- " & Format(Format((dblFailedParseElapsedS(j) - dblFailedParseElapsedSLast(j)) / 1000000, "0.00"), strAT) & "  SID: " & Format(lngSID(j)) & " Serial #: " & Format(lngSerial(j)) & " " & strSessionOther(j)
                    sglColor = Round((dblFailedParseElapsedS(j) - dblFailedParseElapsedSLast(j)) / (dblFailedParseElapsed - dblFailedParseElapsedLast) * 255)
                    If sglColor > 255 Then
                        sglColor = 255
                    Else
                        If sglColor < 0 Then
                            sglColor = 0
                        End If
                    End If
                    tvTimeModel.Nodes(tvTimeModel.Nodes.Count).BackColor = RGB(255, 255 - sglColor, 0)
                End If
            End If
        Next j
    End If

    strLine = Format(Format((dblFailedParseMemory - dblFailedParseMemoryLast) / 1000000, "0.00"), strAT) & " Failed Parse (Out of Shared Memory) Elapsed Time"
    If dblDBTimeDelta <> 0 Then
        strLine = strLine & " (" & Format((dblFailedParseMemory - dblFailedParseMemoryLast) / dblDBTimeDelta, "0.00%") & " of DB Time)"
    End If
    If (dblParseTimeElapsed - dblParseTimeElapsedLast) <> 0 Then
        strLine = strLine & " (" & Format((dblFailedParseMemory - dblFailedParseMemoryLast) / (dblParseTimeElapsed - dblParseTimeElapsedLast), "0.00%") & " of Parse Time)"
    End If
    If (dblFailedParseElapsed - dblFailedParseElapsedLast) <> 0 Then
        strLine = strLine & " (" & Format((dblFailedParseMemory - dblFailedParseMemoryLast) / (dblFailedParseElapsed - dblFailedParseElapsedLast), "0.00%") & " of Failed Parse Time)"
    End If
    tvTimeModel.Nodes.Add "FailedParseElapsedTime", tvwChild, "FailedParseOutofSharedMemory", strLine
    If ((dblFailedParseMemory - dblFailedParseMemoryLast) <> 0) And (intDisplaySessionDetail = True) Then
        For j = 1 To intSessionCount
            If intSessionExists(j) = True Then
                If ((dblFailedParseMemoryS(j) - dblFailedParseMemorySLast(j)) / (dblFailedParseMemory - dblFailedParseMemoryLast) >= sglSessionMinimumPercent) Then
                    tvTimeModel.Nodes.Add "FailedParseOutofSharedMemory", tvwChild, "SESSIONFailedParseMemory_" & Format(j), "-- " & Format(Format((dblFailedParseMemoryS(j) - dblFailedParseMemorySLast(j)) / 1000000, "0.00"), strAT) & "  SID: " & Format(lngSID(j)) & " Serial #: " & Format(lngSerial(j)) & " " & strSessionOther(j)
                    sglColor = Round((dblFailedParseMemoryS(j) - dblFailedParseMemorySLast(j)) / (dblFailedParseMemory - dblFailedParseMemoryLast) * 255)
                    If sglColor > 255 Then
                        sglColor = 255
                    Else
                        If sglColor < 0 Then
                            sglColor = 0
                        End If
                    End If
                    tvTimeModel.Nodes(tvTimeModel.Nodes.Count).BackColor = RGB(255, 255 - sglColor, 0)
                End If
            End If
        Next j
    End If

    strLine = Format(Format((dblPLSQLExecution - dblPLSQLExecutionLast) / 1000000, "0.00"), strAT) & " PL/SQL Execution Elapsed Time"
    If dblDBTimeDelta <> 0 Then
        strLine = strLine & " (" & Format((dblPLSQLExecution - dblPLSQLExecutionLast) / dblDBTimeDelta, "0.00%") & " of DB Time)"
    End If
    tvTimeModel.Nodes.Add "DBTime", tvwChild, "PLSQLExecutionElapsedTime", strLine
    If ((dblPLSQLExecution - dblPLSQLExecutionLast) <> 0) And (intDisplaySessionDetail = True) Then
        For j = 1 To intSessionCount
            If intSessionExists(j) = True Then
                If ((dblPLSQLExecutionS(j) - dblPLSQLExecutionSLast(j)) / (dblPLSQLExecution - dblPLSQLExecutionLast) >= sglSessionMinimumPercent) Then
                    tvTimeModel.Nodes.Add "PLSQLExecutionElapsedTime", tvwChild, "SESSIONPLSQLExecutionElapsedTime_" & Format(j), "-- " & Format(Format((dblPLSQLExecutionS(j) - dblPLSQLExecutionSLast(j)) / 1000000, "0.00"), strAT) & "  SID: " & Format(lngSID(j)) & " Serial #: " & Format(lngSerial(j)) & " " & strSessionOther(j)
                    sglColor = Round((dblPLSQLExecutionS(j) - dblPLSQLExecutionSLast(j)) / (dblPLSQLExecution - dblPLSQLExecutionLast) * 255)
                    If sglColor > 255 Then
                        sglColor = 255
                    Else
                        If sglColor < 0 Then
                            sglColor = 0
                        End If
                    End If
                    tvTimeModel.Nodes(tvTimeModel.Nodes.Count).BackColor = RGB(255, 255 - sglColor, 0)
                End If
            End If
        Next j
    End If

    strLine = Format(Format((dblInboundPLSQL - dblInboundPLSQLLast) / 1000000, "0.00"), strAT) & " Inbound PL/SQL RPC Elapsed Time"
    If dblDBTimeDelta <> 0 Then
        strLine = strLine & " (" & Format((dblInboundPLSQL - dblInboundPLSQLLast) / dblDBTimeDelta, "0.00%") & " of DB Time)"
    End If
    tvTimeModel.Nodes.Add "DBTime", tvwChild, "InboundPLSQLRPCElapsedTime", strLine
    If ((dblInboundPLSQL - dblInboundPLSQLLast) <> 0) And (intDisplaySessionDetail = True) Then
        For j = 1 To intSessionCount
            If intSessionExists(j) = True Then
                If ((dblInboundPLSQLS(j) - dblInboundPLSQLSLast(j)) / (dblInboundPLSQL - dblInboundPLSQLLast) >= sglSessionMinimumPercent) Then
                    tvTimeModel.Nodes.Add "InboundPLSQLRPCElapsedTime", tvwChild, "SESSIONInboundPLSQLRPCElapsedTime_" & Format(j), "-- " & Format(Format((dblInboundPLSQLS(j) - dblInboundPLSQLSLast(j)) / 1000000, "0.00"), strAT) & "  SID: " & Format(lngSID(j)) & " Serial #: " & Format(lngSerial(j)) & " " & strSessionOther(j)
                    sglColor = Round((dblInboundPLSQLS(j) - dblInboundPLSQLSLast(j)) / (dblInboundPLSQL - dblInboundPLSQLLast) * 255)
                    If sglColor > 255 Then
                        sglColor = 255
                    Else
                        If sglColor < 0 Then
                            sglColor = 0
                        End If
                    End If
                    tvTimeModel.Nodes(tvTimeModel.Nodes.Count).BackColor = RGB(255, 255 - sglColor, 0)
                End If
            End If
        Next j
    End If

    strLine = Format(Format((dblPLSQLCompile - dblPLSQLCompileLast) / 1000000, "0.00"), strAT) & " PL/SQL Compilation Elapsed Time"
    If dblDBTimeDelta <> 0 Then
        strLine = strLine & " (" & Format((dblPLSQLCompile - dblPLSQLCompileLast) / dblDBTimeDelta, "0.00%") & " of DB Time)"
    End If
    tvTimeModel.Nodes.Add "DBTime", tvwChild, "PLSQLCompilationElapsedTime", strLine
    If ((dblPLSQLCompile - dblPLSQLCompileLast) <> 0) And (intDisplaySessionDetail = True) Then
        For j = 1 To intSessionCount
            If intSessionExists(j) = True Then
                If ((dblPLSQLCompileS(j) - dblPLSQLCompileSLast(j)) / (dblPLSQLCompile - dblPLSQLCompileLast) >= sglSessionMinimumPercent) Then
                    tvTimeModel.Nodes.Add "PLSQLCompilationElapsedTime", tvwChild, "SESSIONPLSQLCompilationElapsedTime_" & Format(j), "-- " & Format(Format((dblPLSQLCompileS(j) - dblPLSQLCompileSLast(j)) / 1000000, "0.00"), strAT) & "  SID: " & Format(lngSID(j)) & " Serial #: " & Format(lngSerial(j)) & " " & strSessionOther(j)
                    sglColor = Round((dblPLSQLCompileS(j) - dblPLSQLCompileSLast(j)) / (dblPLSQLCompile - dblPLSQLCompileLast) * 255)
                    If sglColor > 255 Then
                        sglColor = 255
                    Else
                        If sglColor < 0 Then
                            sglColor = 0
                        End If
                    End If
                    tvTimeModel.Nodes(tvTimeModel.Nodes.Count).BackColor = RGB(255, 255 - sglColor, 0)
                End If
            End If
        Next j
    End If

    strLine = Format(Format((dblJavaTime - dblJavaTimeLast) / 1000000, "0.00"), strAT) & " Java Execution Elapsed Time"
    If dblDBTimeDelta <> 0 Then
        strLine = strLine & " (" & Format((dblJavaTime - dblJavaTimeLast) / dblDBTimeDelta, "0.00%") & " of DB Time)"
    End If
    tvTimeModel.Nodes.Add "DBTime", tvwChild, "JavaExecutionElapsedTime", strLine
    If ((dblJavaTime - dblJavaTimeLast) <> 0) And (intDisplaySessionDetail = True) Then
        For j = 1 To intSessionCount
            If intSessionExists(j) = True Then
                If ((dblJavaTimeS(j) - dblJavaTimeSLast(j)) / (dblJavaTime - dblJavaTimeLast) >= sglSessionMinimumPercent) Then
                    tvTimeModel.Nodes.Add "JavaExecutionElapsedTime", tvwChild, "SESSIONJavaExecutionElapsedTime_" & Format(j), "-- " & Format(Format((dblJavaTimeS(j) - dblJavaTimeSLast(j)) / 1000000, "0.00"), strAT) & "  SID: " & Format(lngSID(j)) & " Serial #: " & Format(lngSerial(j)) & " " & strSessionOther(j)
                    sglColor = Round((dblJavaTimeS(j) - dblJavaTimeSLast(j)) / (dblJavaTime - dblJavaTimeLast) * 255)
                    If sglColor > 255 Then
                        sglColor = 255
                    Else
                        If sglColor < 0 Then
                            sglColor = 0
                        End If
                    End If
                    tvTimeModel.Nodes(tvTimeModel.Nodes.Count).BackColor = RGB(255, 255 - sglColor, 0)
                End If
            End If
        Next j
    End If

    strLine = Format(Format((dblRepeatedBind - dblRepeatedBindLast) / 1000000, "0.00"), strAT) & " Repeated Bind Elapsed Time"
    If dblDBTimeDelta <> 0 Then
        strLine = strLine & " (" & Format((dblRepeatedBind - dblRepeatedBindLast) / dblDBTimeDelta, "0.00%") & " of DB Time)"
    End If
    tvTimeModel.Nodes.Add "DBTime", tvwChild, "RepeatedBindElapsedTime", strLine
    If ((dblRepeatedBind - dblRepeatedBindLast) <> 0) And (intDisplaySessionDetail = True) Then
        For j = 1 To intSessionCount
            If intSessionExists(j) = True Then
                If ((dblRepeatedBindS(j) - dblRepeatedBindSLast(j)) / (dblRepeatedBind - dblRepeatedBindLast) >= sglSessionMinimumPercent) Then
                    tvTimeModel.Nodes.Add "RepeatedBindElapsedTime", tvwChild, "SESSIONRepeatedBindElapsedTime_" & Format(j), "-- " & Format(Format((dblRepeatedBindS(j) - dblRepeatedBindSLast(j)) / 1000000, "0.00"), strAT) & "  SID: " & Format(lngSID(j)) & " Serial #: " & Format(lngSerial(j)) & " " & strSessionOther(j)
                    sglColor = 255 - Round((dblRepeatedBindS(j) - dblRepeatedBindSLast(j)) / (dblRepeatedBind - dblRepeatedBindLast) * 255)
                    If sglColor > 255 Then
                        sglColor = 255
                    Else
                        If sglColor < 0 Then
                            sglColor = 0
                        End If
                    End If
                    tvTimeModel.Nodes(tvTimeModel.Nodes.Count).BackColor = RGB(255, sglColor, 0)
                End If
            End If
        Next j
    End If

    For j = 1 To tvTimeModel.Nodes.Count
        'Force all of the nodes to appear expanded
         tvTimeModel.Nodes(j).Expanded = True
    Next j
    tvTimeModel.Nodes(1).Selected = True

    'tvTimeModel.Visible = True

    intCurrentSessionIndex = -1
    intActivated = True
End Sub 

We are almost ready to take the code for a test drive.  First, we need to make a couple of changes to the code in the TimerEvent subroutine.  That subroutine is found in Module1 under the Modules heading (which is below the Microsoft Excel Objects heading).  Double-click Module1 to display the code in that module.  Change the TimerEvent subroutine to look like this:

Public Sub TimerEvent()
    lngTimerEventCounter = lngTimerEventCounter + 1

    If intKillFlag = False Then
        If lngTimerTriggerSeconds <= lngTimerEventCounter Then
            lngTimerEventCounter = 0
            frmTimeModel.ReadData
            frmTimeModel.UpdateDisplay
        End If

        'Instruct Excel to execute the TimerEvent sub again in 1 second
        Application.OnTime DateAdd("s", 1, Now), "TimerEvent"
    End If
End Sub 

The above code tells Excel to execute the ReadData subroutine and then the UpdateData subroutine every time the number of elapsed seconds is equal to the value specified by the lngTimerTriggerSeconds variable, which is set to 60 by default in the code.

Save the Excel workbook, close the workbook, and then open the workbook again.  If everything works right, after about 60 seconds you should see the time model statistics for the previous 60 seconds, something like this:

Wow, that is a lot of code for what little is shown in the above screen capture.  We will continue from here in the next segment of the series.

—-

Added March 2, 2011:

The Excel project code to this point, save with a .XLS extension (currently has a .DOC extension, please change):
TimeModelViewerExcelArticle2.xls





Oracle Database Time Model Viewer in Excel 1

28 02 2011

February 28, 2011

(Forward to the Next Post in the Series)

Previously, I had written a couple of blog articles that showed how to build a reasonably usable Oracle Database Time Model Viewer using nothing more than a text file (containing a VBS script) and a dynamically generated web page that is displayed on a Windows client computer using Internet Explorer (see the three part series).  It might be interesting to see what is possible in a more sophisticated programming environment, such as Microsoft Excel.

170.64 seconds of CPU time consumed in 60 seconds, meaning that on average the CPUs were 34.97% busy, 20.18 seconds of CPU time were consumed in kernel mode, meaning that 88.17% of the CPU time consumed was consumed by Oracle Database or other foregound processes.  Interesting, but I could probably obtain roughly the same information from an operating system utility.  Possibly the more important question is “What is happening in my database instance?”  Before the time model statistics were introduced in Oracle Database 10.1, we could see by examining repeated samplings of V$SYSSTAT that 78.05 CPU seconds were consumed by the sessions (falling into the CPU used by session statistic), that 2.43 CPU seconds were needed parsing activity (falling into the parse time cpu statistic, and 2.90 CPU seconds were needed for recursive operations (falling into the recursive cpu usage statistic) while performing operations such as trigger execution and space management calls – we are able to drill down into the session level detail by comparing delta values of V$SESSTAT.  Starting with Oracle Database 9.2 we could also monitor the CPU usage of SQL statements by repeatedly checking V$SQL (Oracle Database 10.2 and above permit accessing V$SQLSTATS as a less resource intensive method to access much of the same information using the SQL_ID and PLAN_HASH_VALUE).  We could also check the various views (V$SYSTEM_EVENT, V$SESSION_EVENT, V$SESSION_WAIT, V$LOCK, etc.) that compose the wait event interface, but that information will not indicate the amount of CPU used, and why the CPU was used by a session.

Let’s see if it is possible to build an extended version of the Oracle Database Time Model Viewer in Excel, hopefully something like this – the screen capture includes a lot of cross-referenced information that extends well beyond the Oracle Database time model views (V$SYS_TIME_MODEL, V$SESS_TIME_MODEL):

If you look closely at the above picture, we also see that this Oracle Database instance accounted for 80.63 CPU seconds (Background CPU Time plus DB CPU), with SID 1230 consuming the greatest percentage of CPU time at 19.13 seconds.  Looking at the bottom of the screen capture, we see wait events from V$SYSTEM_EVENT and V$SESSION_EVENT that are grouped into categories (Administrative, Application, Commit, Concurrency, Configuration, Idle, Network, Other, Scheduler, System I/O, and User I/O), a feature which first appeared in Oracle Database 10.2.   The time model statistics show that session 1230 spent 24.98 seconds executing SQL statements, a portion of the time was spent running on the CPU (19.13 seconds), and a port of the time was spent sitting in wait events (6.47 seconds in the direct path read wait event).  Interesting possibilities here.

Let’s look at another example.  793.46 seconds of CPU time consumed in (roughly) 60 seconds, meaning that on average the CPUs were just under 100.00% busy, 11.60 seconds of CPU time were consumed in kernel mode, meaning that 98.54% of the CPU time consumed was consumed by Oracle Database or other foregound processes.  Fantastic, we are using 100% of the server’s CPUs (oh wait, that is not a good idea).  Unlike the earlier screen capture, where DB Time (125.86 seconds) was roughly equal to DB CPU (80.61 seconds) plus the value for Total Non-Idle Wait Time (43.74 seconds); in this screen capture we find that DB Time (259.40 seconds) seems to have a bit of lost time because the DB CPU (131.66 seconds) plus Total Non-Idle Wait Time (34.72 seconds) is about 93 seconds short of the DB Time statistic – on a positive note, if we were only looking at the wait events, it would appear that the sessions waited 9.02 seconds less in this time interval than in the time interval of the previous screen capture – we would have missed that the missing time detail if we had we not been looking at more than just the wait events :-) .  If we look at the delta values from V$OSSTAT (the statistics at the top of the screen captures), and compare those statistics to the DB CPU plus Background CPU Time time model statistics, we get a sense of what the problem might entail.  The V$OSSTATS statistics indicate that the processes running on the server (and the kernel mode CPU usage that was provoked by those processes) consumed 793.46 seconds of CPU time, while we are only able to account for 131.65 seconds + 0.08 seconds, or roughly 16.6% of the total CPU usage within the database instance.  A relevant question at this point is what process or processes consumed the other 83.4% of the CPU time?

Moving on to the third screen capture, we see that things have started calming down a a little, with the average CPU utilization for the 60 second time period at 89.24% busy – of course this probably means that there were periods of 100% utilization, and periods of 70% utilization (I cheated, I watched the CPU utilization in roughly 5 second intervals, but note that DB Time minus DB CPU minus Total Non-Idle Wait Time indicates that 36.86 seconds are apparently missing… or lost in the CPU run queue, or in an uninstrumented code path).  In the following screen capture we are able to see that the database instance consumed 203.77 seconds plus 0.03 seconds of the 439.56 seconds of total server CPU time consumed in the interval (roughly 46.4% of the total server CPU consumed could be attributed to the database instance – what else is consuming the server’s CPU time, possibly another database instance?).

By the time of the fourth screen capture things are starting to settle down, with the server’s CPUs just 24.58% busy.  Unfortunately, the database instance being monitored only accounted for 13.95% of that CPU usage, so some other process is still competing for the server’s CPU time.  Lots of pretty colors and other information in the screen captures, but we will save the explanation for later.

Let’s start up Excel and begin building the project – you will probably need the 32 bit version of Excel for this exercise, even on a 64 bit computer.  Right-click one of the worksheet tabs and click View Code.

From the Tools menu, select References.  Find Microsoft ActiveX Data Objects 2.8 (or 6.0) Library, and place a check next to that item.  This is the feature that will allow our macros to communicate with the Oracle Database.  Click OK.

Next, we need to create a window for our application, and in Excel that window is called a UserForm.  Right-click Microsoft Excel Objects, and then select Insert – UserForm from the menu.

From the View menu, select Properties Explorer.  Change the (Name) property of the UserForm to frmTimeModel and feel free to change the other form properties as you see fit.

Now the potentially challenging part.  We need a Microsoft Windows built-in 32 bit element (control) called TreeView.  This 32 bit control is found in the MSCOMCTL.OCX, and on a 32 bit operating system the file should be found in the C:\Windows\System32 folder.  On a 64 bit operating system the file should be found in the C:\Windows\SysWOW64 folder.  This file might be installed by various installer programs, but can also be downloaded from Microsoft (this link might also work, but the file is much older).  If you had to download the file, put it in the correct folder location and then “register” the file with Windows, using a command like this (on a 64 bit client computer):

REGSVR32 c:\windows\SysWOW64\MSCOMCTL.OCX 

(Possible bad news, the TreeView control might not work without Visual Basic 5.0 or 6.0 installed, see this article - we might need to simulate the TreeView using an Excel worksheet.)

Once we verify that the TreeView control is on the computer and registered, switch back to the Visual Basic editor, and from the Tools menu, select Additional Controls…  Locate one of the Microsoft TreeView Controls in the list and place a checkmark next to it.  Then click the OK button.

Find the TreeView control in the Toolbox tools list, and click it.  Draw a rectangle convering most of the UserForm.  In the Properties window, change the (Name) property of the TreeView control to tvTimeModel and then double-click the word (Custom) in the Properties window.  In the Properties Pages window, change the Line Style to 1 – tvwRootLines and then click the OK button.  Back in the Properties window, change the font to Courier New with an 8 point font size (to do this, double-click the word Font in the properties list).

Now, let’s add a little code to the project.  Earlier, when we added a UserForm to the project, we right-clicked Microsoft Excel Object.  In the same area of the screen is an item titled ThisWorkbook – double click the word ThisWorkbook.  Add the following code to the code window that appeared:

Private Sub Workbook_Open()
    'Code to initialize sheets should be placed here
    lngTimerTriggerSeconds = 60
    lngTimerEventCounter = lngTimerTriggerSeconds
    frmTimeModel.Show
End Sub 

The above code sets the values of a couple of variables that can be accessed throughout the Excel project and then tells Microsoft Excel to display the UserForm that we just created, every time this Excel spreadsheet workbook is opened.

Now let’s create a timer subroutine that will automatically run once a second.  Right-click Microsoft Excel Objects, and then select Insert – Module from the menu.  Add the following code to the new module:

Option Explicit
Public lngTimerEventCounter As Long
Public lngTimerTriggerSeconds As Long
Public intKillFlag As Integer
Public Sub TimerEvent()
    Dim i As Integer
    lngTimerEventCounter = lngTimerEventCounter + 1

    If lngTimerTriggerSeconds <= lngTimerEventCounter Then
        frmTimeModel.tvTimeModel.Nodes.Clear
        frmTimeModel.tvTimeModel.Nodes.Add , , "BackgroundElapsedTime", "This is a test, the time is now " & Now
        frmTimeModel.tvTimeModel.Nodes.Add "BackgroundElapsedTime", tvwChild, "BackgroundCPU", "The background is still in the background."

        For i = 1 To frmTimeModel.tvTimeModel.Nodes.Count
            'Force all of the nodes to appear expanded
            frmTimeModel.tvTimeModel.Nodes(i).Expanded = True
        Next i
        frmTimeModel.tvTimeModel.Nodes(1).Selected = True

        lngTimerEventCounter = 0
        intKillFlag = intKillFlag + 1
    End If
    'Instruct Excel to execute the TimerEvent sub again in 1 second
    If intKillFlag < 10 Then
        Application.OnTime DateAdd("s", 1, Now), "TimerEvent"
    End If
End Sub 

The above creates a sort of recursive routine, where every time the TimerEvent subroutine executes, it instructs Excel to execute the subroutine again after waiting one second.  Every 60 times the TimerEvent subroutine executes, it will update the TreeView control on the UserForm.  But there is a catch – somehow we need to execute the TimerEvent the first time so that it will automatically execute once a second.  Below where you previously found Microsoft Excel Objects you will see frmTimeModel.  Right-click frmTimeModel and select View Code.  Add the following code:

Private Sub UserForm_Initialize()
    TimerEvent
End Sub 

Now save the Excel spreadsheet workbook, exit Excel, and the open the spreadsheet workbook that we just created.  If everything works as it should, you should see something like this (note that you may need to adjust the Macro Security Level to allow the execution of all macros):

We will continue from here in the next segment of the series.

Edit February 28, 2011:
The current Excel project file, it might be necessary to hit the F5 key on the keyboard for the macro to run correctly after the workbook opens: TimeModelViewerExcelArticle1





SQL Performance Problem, AWR Reports Query is #1 in Elapsed Time, #2 in CPU Time – How Would You Help?

6 02 2011

February 6, 2011 (Updated February 25, 2011)

I occasionally read various forums on the Internet including a couple of Usenet groups (comp.databases.oracle.server, comp.databases.oracle.misc), OTN forums (Database – General, SQL and PL/SQL), Oracle-L, AskTom, and a handful of other forums.  I don’t participate on all of the forums, but I try to help when possible on a couple of those forums.

I saw a SQL tuning request on one of the forums that caught my eye.  The original poster (OP) identified a SQL statement with the help of an AWR report, and he needed to tune that SQL statement.  The identified SQL statement was consuming the most elapsed time (19,307 seconds total, 1.90 seconds per execution, 48.30% of DB time), and the same SQL statement was also identified as consuming the second highest amount of CPU time (1,063 seconds).  A summarization of the advice provided by responders in the thread includes:

  • Check out these links (one of which is for a book that I reviewed a couple of months ago).
  • Start with hints, including those that change the OPTIMIZER_MODE, those that adjust the dynamic sampling, those that change the join type, and those that change which indexes are used.
  • Analyze the data dictionary.

I think that I would first start by trying to determine the intended result of the query.  What is that query supposed to show, and why are we executing it 10,176 times in the AWR reporting period?  To begin that process, I might try to reformat the SQL statement into my standardized format, something like this (changing upper/lower case, spacing, and aliases):

SELECT /*NORULE */
  'DATAPOINT EXTENTS_LEFT '  || ' ' ||
      NVL(MIN(DSE.MAXEXTS - DSE.EXTENTS), 111) || CHR(10) ||
      'DATAPOINT EXTENTS_LEFT_PCT'  || ' ' ||
      ROUND(NVL(MIN(ROUND(DSE.MAXEXTS - DSE.EXTENTS) * 100 / DSE.MAXEXTS), 100),0) BPB
FROM
  (SELECT
     DS.HEADER_FILE FILE#,
     DS.HEADER_BLOCK BLOCK#,
     DS.EXTENTS,
     DS.MAX_EXTENTS MAXEXTS,
     ST.TS#,
     SU.USER#
   FROM
     DBA_SEGMENTS DS,
     SYS.TS$ ST,
     SYS.USER$ SU
   WHERE
     ST.NAME=DS.TABLESPACE_NAME
     AND SU.NAME=DS.OWNER
     AND SEGMENT_TYPE NOT IN ('SPACE HEADER','CACHE')) DSE,
  (SELECT
     NAME,
     TS#,
     ONLINE$
   FROM
     SYS.TS$) TS,
  (SELECT
     TABLESPACE_NAME,
     CONTENTS
   FROM
     DBA_TABLESPACES) DT,
  (SELECT
     TS#,
     FILE#,
     BLOCK#
   FROM
     P$OBJ_EXCLUSION
   WHERE
     TS# IS NOT NULL
     AND FILE# IS NOT NULL
     AND BLOCK# IS NOT NULL) OEB,
  (SELECT
     TS#
   FROM
     P$OBJ_EXCLUSION
   WHERE
     OBJECT_TYPE = 'TABLE'
     AND FILE# IS NULL
     AND BLOCK# IS NULL
     AND USER# IS NULL) OETS,
  (SELECT
     USER#
   FROM
     P$OBJ_EXCLUSION
   WHERE
      USER# IS NOT NULL) OEU
WHERE
  DSE.MAXEXTS > 0 -- CACHE SEGMENT HAS MAXEXTS = 0
  AND TS.TS# > 0
  AND DSE.TS# = TS.TS#
  AND TS.ONLINE$ = 1
  AND DSE.TS# = OEB.TS#(+)
  AND OEB.TS# IS NULL
  AND DSE.FILE# = OEB.FILE#(+)
  AND OEB.FILE# IS NULL
  AND DSE.BLOCK# = OEB.BLOCK#(+)
  AND OEB.BLOCK# IS NULL
  AND DSE.TS# = OETS.TS#(+)
  AND OETS.TS# IS NULL
  AND DSE.USER# = OEU.USER#(+)
  AND OEU.USER# IS NULL
  AND TS.NAME = DT.TABLESPACE_NAME
  AND DT.CONTENTS = 'PERMANENT';

While the query begins with an interesting comment, we can ignore that for now.  What is the next step:

  • Why is the query accessing both SYS.TS$ and DBA_TABLESPACES?
  • Why are some of the restrictions (such as TS.TS# and TS.ONLINE, DT.CONTENTS) that are placed on the tablespaces not included in the WHERE clauses in the inline views?
  • Why does the query specify MIN(DSE.MAXEXTS – DSE.EXTENTS) with no GROUP BY clause?
  • Why does the query perform an implicit NUMBER to VARCHAR conversion in the data returned to the client?
  • The inline views that I aliased with names beginning with OE are apparently designed to provide exclusion lists for the objects in DBA_SEGMENTS, excluding by TS#, BLOCK# (HEADER_BLOCK), and USER#.  Why is the query not retrieving a distinct list of each type of item to be excluded, possibly from a materialized view?

What steps would you take to help the OP?  Would you just tell the OP that in a “Top 5″ type of report that there will always be something in the top two spots?

—–

Edit February 25, 2011:

Donald K. Burleson, apparently realizing what it means to file a false DMCA claim under penalty of perjury, did not file a lawsuit to back up his DMCA claim to copyright ownership of the modified SQL statement that I posted on February 6, 2011 in this article.  His false DMCA claim held hostage this article for a total of 17 days, during which time the article was not available for readers of this blog (for the record, I completely understand and agree with WordPress’ handing of this matter, where their processes require taking DMCA challenged articles offline for two weeks to allow the true copyright holder sufficient time to file a lawsuit).  False DMCA claims from Donald K. Burleson against my blog articles will not be tolerated, and this article will serve as evidence of past abuse, if necessary.





Adding Comments to SQL Statements Improves Performance?

15 01 2011

January 15, 2011

While reading the “Pro Oracle SQL” book I learned something interesting.  Commenting your work can improve database performance.  You certainly are aware that thoroughly documenting what you do could prevent hours of headaches that might appear later when trying to investigate problems or add additional features to an existing procedure (I think that was part of the message in Cary Millsap’s recent blog article). 

But how can commenting what you do actually improve database performance?  To demonstrate, let’s create a simple test case using two tables and a single insert statement to populate the two tables:

CREATE TABLE T1 (
  C1 NUMBER,
  C2 NUMBER,
  C3 VARCHAR2(200),
  PRIMARY KEY(C1));

CREATE TABLE T2 (
  C1 NUMBER,
  C2 NUMBER,
  C3 VARCHAR2(200),
  PRIMARY KEY(C1));

INSERT ALL
  WHEN 1=1 THEN
    INTO T1
  WHEN MOD(ROWNUM,2)=1 THEN
    INTO T2
SELECT
  ROWNUM C1,
  ROWNUM C2,
  LPAD('A',200,'A') C3
FROM
  DUAL
CONNECT BY
  LEVEL<=1000000;

COMMIT;

EXEC DBMS_STATS.GATHER_TABLE_STATS(OWNNAME=>USER,TABNAME=>'T1',CASCADE=>TRUE)
EXEC DBMS_STATS.GATHER_TABLE_STATS(OWNNAME=>USER,TABNAME=>'T2',CASCADE=>TRUE) 

The tables created by the above script both have primary key indexes, with table T1 having 1,000,000 rows and table T2 having 500,000 rows.  Now let’s create a simple SQL statement that joins the two tables and output the execution plan for the SQL statement:

SET LINESIZE 140
SET TRIMSPOOL ON
SET PAGESIZE 1000
SET AUTOTRACE TRACEONLY EXPLAIN

SELECT
  T1.C1,
  T1.C2,
  T2.C1,
  T2.C2
FROM
  T1,
  T2
WHERE
  T1.C1=T2.C1;

Execution Plan
----------------------------------------------------------
Plan hash value: 2959412835

-----------------------------------------------------------------------------------
| Id  | Operation          | Name | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
-----------------------------------------------------------------------------------
|   0 | SELECT STATEMENT   |      |   500K|  9765K|       | 13974   (1)| 00:02:48 |
|*  1 |  HASH JOIN         |      |   500K|  9765K|    10M| 13974   (1)| 00:02:48 |
|   2 |   TABLE ACCESS FULL| T2   |   500K|  4882K|       |  4126   (1)| 00:00:50 |
|   3 |   TABLE ACCESS FULL| T1   |  1000K|  9765K|       |  8276   (1)| 00:01:40 |
-----------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------
   1 - access("T1"."C1"="T2"."C1") 

The execution plan indicates that a hash join will be used to join the tables, with table T2 listed as the first row source below the words “HASH JOIN”.  The query is expected to require roughly 2 minutes and 48 seconds to execute.  Now let’s try the query again with a hint:

SELECT /*+ LEADING(T1) */
  T1.C1,
  T1.C2,
  T2.C1,
  T2.C2
FROM
  T1,
  T2
WHERE
  T1.C1=T2.C1;

Execution Plan
----------------------------------------------------------
Plan hash value: 1838229974

-----------------------------------------------------------------------------------
| Id  | Operation          | Name | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
-----------------------------------------------------------------------------------
|   0 | SELECT STATEMENT   |      |   500K|  9765K|       | 13973   (1)| 00:02:48 |
|*  1 |  HASH JOIN         |      |   500K|  9765K|    20M| 13973   (1)| 00:02:48 |
|   2 |   TABLE ACCESS FULL| T1   |  1000K|  9765K|       |  8276   (1)| 00:01:40 |
|   3 |   TABLE ACCESS FULL| T2   |   500K|  4882K|       |  4126   (1)| 00:00:50 |
-----------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------
   1 - access("T1"."C1"="T2"."C1") 

The execution plan again indicates that a hash join will be used to join the tables, this time with table T1 listed as the first row source below the words “HASH JOIN”.  The query is still expected to require roughly 2 minutes and 48 seconds to execute.  Let’s try the query again with a second hint: 

SELECT /*+ LEADING(T1) USE_NL(T2) */
  T1.C1,
  T1.C2,
  T2.C1,
  T2.C2
FROM
  T1,
  T2
WHERE
  T1.C1=T2.C1;

Execution Plan
----------------------------------------------------------
Plan hash value: 685492288

---------------------------------------------------------------------------------------------
| Id  | Operation                    | Name         | Rows  | Bytes | Cost (%CPU)| Time     |
---------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT             |              |   500K|  9765K|  1508K  (1)| 05:01:46 |
|   1 |  NESTED LOOPS                |              |       |       |            |          |
|   2 |   NESTED LOOPS               |              |   500K|  9765K|  1508K  (1)| 05:01:46 |
|   3 |    TABLE ACCESS FULL         | T1           |  1000K|  9765K|  8276   (1)| 00:01:40 |
|*  4 |    INDEX UNIQUE SCAN         | SYS_C0010199 |     1 |       |     1   (0)| 00:00:01 |
|   5 |   TABLE ACCESS BY INDEX ROWID| T2           |     1 |    10 |     2   (0)| 00:00:01 |
---------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------
   4 - access("T1"."C1"="T2"."C1") 

The execution plan this time indicates that two nested loops joins will be used to join the tables, with table T1 listed as the first row source below the words “NESTED LOOPS”.  The query is still expected to require roughly 301 minutes and 46 seconds to execute.  Now let’s document what we did to alter performance so that the next person to investigate the performance of this SQL statement will know why it performs as it does:

SELECT /*+ comment: I added these hints on Jan 15, 2011 to fix a performance problem LEADING(T1) USE_NL(T2) */
  T1.C1,
  T1.C2,
  T2.C1,
  T2.C2
FROM
  T1,
  T2
WHERE
  T1.C1=T2.C1;

Execution Plan
----------------------------------------------------------
Plan hash value: 2959412835

-----------------------------------------------------------------------------------
| Id  | Operation          | Name | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
-----------------------------------------------------------------------------------
|   0 | SELECT STATEMENT   |      |   500K|  9765K|       | 13974   (1)| 00:02:48 |
|*  1 |  HASH JOIN         |      |   500K|  9765K|    10M| 13974   (1)| 00:02:48 |
|   2 |   TABLE ACCESS FULL| T2   |   500K|  4882K|       |  4126   (1)| 00:00:50 |
|   3 |   TABLE ACCESS FULL| T1   |  1000K|  9765K|       |  8276   (1)| 00:01:40 |
-----------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------
   1 - access("T1"."C1"="T2"."C1") 

As you can see from the AUTOTRACE generated execution plan, simply commenting our changes is sufficient to convince the optimizer that the SQL statement will execute roughly 100 times faster than the version of the SQL statement without the comment that documents our work.  The reason for this estimated performance improvement is explained on page 516 of the book.  :-)





Query Executes in Seconds with the RULE Hint and Several Minutes Otherwise – What Would You Do?

10 01 2011

January 10, 2011

An interesting hypothetical question was posed on the OTN forums yesterday.  Consider this situation.  You are using Oracle Database 11.2.0.2 and you find a query that is executing much slower than expected, typically requiring 10 to 15 minutes to execute.  You add a RULE hint to the query and find that the query completes in just a couple of seconds.  How would you do to address this issue?

—-

To help your thought process, consider the following test case that I included in the OTN thread.  The table definition:

CREATE TABLE T5 (
  C1 NUMBER,
  C2 NUMBER,
  C3 NUMBER,
  C4 NUMBER,
  C5 NUMBER,
  C6 NUMBER,
  C7 NUMBER,
  C8 NUMBER,
  C9 VARCHAR2(50),
  C10 VARCHAR2(50));

INSERT INTO
  T5
SELECT
  ROWNUM,
  ROWNUM,
  MOD(ROWNUM,50),
  MOD(ROWNUM,40),
  MOD(ROWNUM,100),
  ROUND(ROWNUM/1000),
  ROUND(ROWNUM/950),
  ROUND(ROWNUM/600),
  RPAD(CHR(65 + MOD(ROWNUM-1,26)),50,CHR(65 + MOD(ROWNUM-1,26))),
  RPAD(CHR(65 + MOD(ROWNUM-1,26)),50,CHR(65 + MOD(ROWNUM-1,26)))
FROM
  DUAL
CONNECT BY
  LEVEL<=1000000;

COMMIT;

CREATE INDEX IND_T5_C10_F ON T5(LOWER(C10)); 

EXEC DBMS_STATS.GATHER_TABLE_STATS(OWNNAME=>USER,TABNAME=>'T5',CASCADE=>TRUE) 

Now, let’s put together a test case script that uses the above table:

ALTER SYSTEM FLUSH BUFFER_CACHE;
ALTER SYSTEM FLUSH BUFFER_CACHE;

SET TIMING ON
SET AUTOTRACE TRACEONLY STATISTICS EXPLAIN
SET ARRAYSIZE 1000

SELECT 
  * 
FROM 
  T5 
WHERE 
  LOWER(C10)=LPAD('a',50,'a'); 

SELECT /*+ RULE */
  * 
FROM 
  T5 
WHERE 
  LOWER(C10)=LPAD('a',50,'a'); 

SELECT /*+ __FAST=TRUE */
  * 
FROM 
  T5 
WHERE 
  LOWER(C10)=LPAD('a',50,'a');

SELECT /*+ INDEX(T5 IND_T5_C10_F) */
  * 
FROM 
  T5 
WHERE 
  LOWER(C10)=LPAD('a',50,'a'); 

In the above, we have an unhinted query, the same query with a RULE hint, the same query with the __FAST=TRUE hint, and the same query with an index hint. Which query will execute the fastest, and why? Let’s execute the test case script to find out (note that your results could be very different from my results):

SQL> SELECT
  2    *
  3  FROM
  4    T5
  5  WHERE
  6    LOWER(C10)=LPAD('a',50,'a');

38462 rows selected.

Elapsed: 00:00:00.57

Execution Plan
----------------------------------------------------------
Plan hash value: 2002323537

--------------------------------------------------------------------------
| Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |      | 38462 |  6911K|  5247   (1)| 00:01:03 |
|*  1 |  TABLE ACCESS FULL| T5   | 38462 |  6911K|  5247   (1)| 00:01:03 |
--------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------
   1 - filter(LOWER("C10")='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
              aaaaaa')

Statistics
----------------------------------------------------------
         99  recursive calls
          0  db block gets
      19441  consistent gets
      19295  physical reads
          0  redo size
    1178619  bytes sent via SQL*Net to client
        937  bytes received via SQL*Net from client
         40  SQL*Net roundtrips to/from client
         10  sorts (memory)
          0  sorts (disk)
      38462  rows processed 

The unhinted version completed in 0.57 seconds, and used a full table scan (your execution time may be a bit longer).

—-

SQL> SELECT /*+ RULE */
  2    *
  3  FROM
  4    T5
  5  WHERE
  6    LOWER(C10)=LPAD('a',50,'a');

38462 rows selected.

Elapsed: 00:00:00.31

Execution Plan
----------------------------------------------------------
Plan hash value: 2002323537

----------------------------------
| Id  | Operation         | Name |
----------------------------------
|   0 | SELECT STATEMENT  |      |
|*  1 |  TABLE ACCESS FULL| T5   |
----------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------
   1 - filter(LOWER("C10")='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
              aaaaaa')

Note
-----
   - rule based optimizer used (consider using cbo)

Statistics
----------------------------------------------------------
          1  recursive calls
          0  db block gets
      19327  consistent gets
          0  physical reads
          0  redo size
    1178619  bytes sent via SQL*Net to client
        937  bytes received via SQL*Net from client
         40  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
      38462  rows processed

The version that was hinted to use the RULE based optimizer completed in 0.31 seconds (nearly twice as fast as the unhinted version), and also used a full table scan.

—-

SQL> SELECT /*+ __FAST=TRUE */
  2    *
  3  FROM
  4    T5
  5  WHERE
  6    LOWER(C10)=LPAD('a',50,'a');

38462 rows selected.

Elapsed: 00:00:00.28

Execution Plan
----------------------------------------------------------
Plan hash value: 2002323537

--------------------------------------------------------------------------
| Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |      | 38462 |  6911K|  5247   (1)| 00:01:03 |
|*  1 |  TABLE ACCESS FULL| T5   | 38462 |  6911K|  5247   (1)| 00:01:03 |
--------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------
   1 - filter(LOWER("C10")='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
              aaaaaa')

Statistics
----------------------------------------------------------
          1  recursive calls
          0  db block gets
      19326  consistent gets
          0  physical reads
          0  redo size
    1178619  bytes sent via SQL*Net to client
        937  bytes received via SQL*Net from client
         40  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
      38462  rows processed 

The version hinted with __FAST=TRUE (a completely fake hint) completed in 0.28 seconds (0.03 seconds faster than the RULE hinted version) and also used a full table scan.

—-

SQL> SELECT /*+ INDEX(T5 IND_T5_C10_F) */
  2    *
  3  FROM
  4    T5
  5  WHERE
  6    LOWER(C10)=LPAD('a',50,'a');

38462 rows selected.

Elapsed: 00:00:00.17

Execution Plan
----------------------------------------------------------
Plan hash value: 1769636183

--------------------------------------------------------------------------------------------
| Id  | Operation                   | Name         | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT            |              | 38462 |  6911K| 20458   (1)| 00:04:06 |
|   1 |  TABLE ACCESS BY INDEX ROWID| T5           | 38462 |  6911K| 20458   (1)| 00:04:06 |
|*  2 |   INDEX RANGE SCAN          | IND_T5_C10_F | 40009 |       |   350   (0)| 00:00:05 |
--------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------
   2 - access(LOWER("C10")='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')

Statistics
----------------------------------------------------------
          1  recursive calls
          0  db block gets
      19576  consistent gets
        352  physical reads
          0  redo size
    1178628  bytes sent via SQL*Net to client
        937  bytes received via SQL*Net from client
         40  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
      38462  rows processed 

The index hinted version of the query completed in 0.17 seconds, which is about twice as fast as the query with the RULE hint and the unhinted version.

—-

With this knowledge, certain questions might come to mind:

  • Why was the first query slower than the third query?
  • Why did the optimizer not automatically select the index when that access path was faster? What do I need to check to see why the index was not selected?
  • Why didn’t the RULE based optimizer select the index access path?
  • How might the test script results change if we were to replace the number 50 in the script with either the number 20 or the number 10?
  • How might the test script results change if someone had altered the OPTIMIZER_INDEX_COST_ADJ parameter?

—-

The hypothetical question was essentially very simple.  How would you guide Oracle’s optimizer to find the optimal execution path?

—-

Edit January 10, 2011: Note that the phrase “How would you do to address this issue” in the initial paragraph is intentionally left undefined, and left for your interpretation.  “This issue” could very well have multiple intended meanings, depending on how you read the paragraph.





SELECT Statement is Fast, INSERT INTO Using the SELECT Statement is Brutally Slow 3

20 12 2010

December 20, 2010

(Back to the Previous Post in the Series)

The previous article in this series included a test case that demonstrated significantly different performance for a SELECT statement and an INSERT INTO statement that used the same SELECT statement as the data source.  This blog article includes the timing results and the execution plans that were generated from the script in the previous blog article.  At the end of this blog article is an unexpected twist – see if you are able to determine what caused the behavior.

———–

SELECT_10.1.0.4 (OPTIMIZER_FEATURES_ENABLE=’10.1.0.4′, OPTIMIZER_INDEX_CACHING=0, OPTIMIZER_INDEX_COST_ADJ=100), completed in 0.23 seconds when selecting 10,478 rows:

--------------------------------------------------+-----------------------------------+
| Id  | Operation                    | Name       | Rows  | Bytes | Cost  | Time      |
--------------------------------------------------+-----------------------------------+
| 0   | SELECT STATEMENT             |            |       |       |  1425 |           |
| 1   |  SORT GROUP BY               |            |   486 |   46K |  1425 |  00:00:12 |
| 2   |   FILTER                     |            |       |       |       |           |
| 3   |    HASH JOIN RIGHT OUTER     |            |   19K | 1882K |  1423 |  00:00:12 |
| 4   |     VIEW                     |            |   700 |   27K |   368 |  00:00:03 |
| 5   |      SORT GROUP BY           |            |   700 |   40K |   368 |  00:00:03 |
| 6   |       HASH JOIN              |            |  146K | 8452K |   362 |  00:00:03 |
| 7   |        TABLE ACCESS FULL     | T2         |   700 |   18K |     3 |  00:00:01 |
| 8   |        TABLE ACCESS FULL     | T2_LINES   |  146K | 4663K |   358 |  00:00:03 |
| 9   |     NESTED LOOPS             |            |   19K | 1126K |  1055 |  00:00:09 |
| 10  |      VIEW                    |            |   700 |   14K |    65 |  00:00:01 |
| 11  |       SORT GROUP BY          |            |   700 |   18K |    65 |  00:00:01 |
| 12  |        FILTER                |            |       |       |       |           |
| 13  |         INDEX FAST FULL SCAN | T1_PK      |  106K | 2755K |    60 |  00:00:01 |
| 14  |      INDEX RANGE SCAN        | T1_LINES_PK|    28 |  1036 |     3 |  00:00:01 |
--------------------------------------------------+-----------------------------------+
Predicate Information:
----------------------
2 - filter(("EL"."FCDUEDATE">COALESCE("CO"."DESIRED_SHIP_DATE",SYSDATE@!-365) AND COALESCE("CO"."DESIRED_SHIP_DATE",SYSDATE@!-365)<SYSDATE@!+1200))
3 - access("E"."CUSTPO"="CO"."CUSTOMER_PO_REF")
6 - access("CO"."ID"="COL"."CUST_ORDER_ID")
7 - filter("CUSTOMER_PO_REF" IS NOT NULL)
8 - filter("COL"."DESIRED_SHIP_DATE">=SYSDATE@!-365)
12 - filter(SYSDATE@!-365<=SYSDATE@!+1200)
14 - access("E"."CUSTPO"="EL"."CUSTPO" AND "E"."RELID"="EL"."RELID" AND "EL"."FCDUEDATE">=SYSDATE@!-365 AND "EL"."FCSTQTY">0 AND "EL"."FCDUEDATE"<=SYSDATE@!+1200)
14 - filter("EL"."FCSTQTY">0)

Statistics
----------------------------------------------------------                     
          1  recursive calls                                                   
          0  db block gets                                                     
       8303  consistent gets                                                   
          0  physical reads                                                    
      62292  redo size                                                         
     141157  bytes sent via SQL*Net to client                                  
        470  bytes received via SQL*Net from client                            
         12  SQL*Net roundtrips to/from client                                 
          3  sorts (memory)                                                    
          0  sorts (disk)                                                      
      10478  rows processed  

INSERT_10.1.0.4 (OPTIMIZER_FEATURES_ENABLE=’10.1.0.4′, OPTIMIZER_INDEX_CACHING=0, OPTIMIZER_INDEX_COST_ADJ=100), completed in… 30 minutes, 18.01 seconds when inserting 10,478 rows:

-------------------------------------------------+-----------------------------------+
| Id  | Operation                      | Name    | Rows  | Bytes | Cost  | Time      |
-------------------------------------------------+-----------------------------------+
| 0   | INSERT STATEMENT               |         |       |       | 4964K |           |
| 1   |  LOAD TABLE CONVENTIONAL       |         |       |       |       |           |
| 2   |   SORT GROUP BY                |         |   842 |   60K | 4964K |  11:18:45 |
| 3   |    FILTER                      |         |       |       |       |           |
| 4   |     HASH JOIN OUTER            |         |   842 |   60K | 4964K |  11:18:45 |
| 5   |      VIEW                      |         |   842 |   28K | 4964K |  11:18:42 |
| 6   |       FILTER                   |         |       |       |       |           |
| 7   |        SORT GROUP BY           |         |   842 |   53K | 4964K |  11:18:42 |
| 8   |         FILTER                 |         |       |       |       |           |
| 9   |          HASH JOIN             |         |  852M |   54G |  7031 |  00:00:57 |
| 10  |           INDEX FAST FULL SCAN | T1_PK   |  106K | 2755K |    60 |  00:00:01 |
| 11  |           TABLE ACCESS FULL    | T1_LINES| 5628K |  214M |  3388 |  00:00:28 |
| 12  |      VIEW                      |         |   700 |   27K |   368 |  00:00:03 |
| 13  |       SORT GROUP BY            |         |   700 |   40K |   368 |  00:00:03 |
| 14  |        HASH JOIN               |         |  146K | 8452K |   362 |  00:00:03 |
| 15  |         TABLE ACCESS FULL      | T2      |   700 |   18K |     3 |  00:00:01 |
| 16  |         TABLE ACCESS FULL      | T2_LINES|  146K | 4663K |   358 |  00:00:03 |
-------------------------------------------------+-----------------------------------+
Predicate Information:
----------------------
3 - filter("E"."FCDUEDATE">COALESCE("CO"."DESIRED_SHIP_DATE",SYSDATE@!-365))
4 - access("E"."CUSTPO"="CO"."CUSTOMER_PO_REF")
6 - filter("EL"."RELID"=MAX("RELID"))
8 - filter(SYSDATE@!-365<=SYSDATE@!+1200)
9 - access("E"."CUSTPO"="EL"."CUSTPO")
11 - filter(("EL"."FCDUEDATE">=SYSDATE@!-365 AND "EL"."FCDUEDATE"<=SYSDATE@!+1200 AND "EL"."FCSTQTY">0))
14 - access("CO"."ID"="COL"."CUST_ORDER_ID")
15 - filter("CUSTOMER_PO_REF" IS NOT NULL)
16 - filter("COL"."DESIRED_SHIP_DATE">=SYSDATE@!-365)

Statistics
----------------------------------------------------------                     
       1174  recursive calls                                                   
        454  db block gets                                                     
      84217  consistent gets                                                   
     214160  physical reads                                                    
     401488  redo size                                                         
        569  bytes sent via SQL*Net to client                                  
       1520  bytes received via SQL*Net from client                            
          3  SQL*Net roundtrips to/from client                                 
          6  sorts (memory)                                                    
          2  sorts (disk)                                                      
      10478  rows processed                                                     

SELECT_10.2.0.2 (OPTIMIZER_FEATURES_ENABLE=’10.2.0.2′, OPTIMIZER_INDEX_CACHING=0, OPTIMIZER_INDEX_COST_ADJ=100), completed in 0.20 seconds when selecting 10,478 rows:

--------------------------------------------------+-----------------------------------+
| Id  | Operation                    | Name       | Rows  | Bytes | Cost  | Time      |
--------------------------------------------------+-----------------------------------+
| 0   | SELECT STATEMENT             |            |       |       |  1425 |           |
| 1   |  SORT GROUP BY               |            |   486 |   46K |  1425 |  00:00:12 |
| 2   |   FILTER                     |            |       |       |       |           |
| 3   |    HASH JOIN RIGHT OUTER     |            |   19K | 1882K |  1423 |  00:00:12 |
| 4   |     VIEW                     |            |   700 |   27K |   368 |  00:00:03 |
| 5   |      HASH GROUP BY           |            |   700 |   40K |   368 |  00:00:03 |
| 6   |       HASH JOIN              |            |  146K | 8452K |   362 |  00:00:03 |
| 7   |        TABLE ACCESS FULL     | T2         |   700 |   18K |     3 |  00:00:01 |
| 8   |        TABLE ACCESS FULL     | T2_LINES   |  146K | 4663K |   358 |  00:00:03 |
| 9   |     NESTED LOOPS             |            |   19K | 1126K |  1055 |  00:00:09 |
| 10  |      VIEW                    |            |   700 |   14K |    65 |  00:00:01 |
| 11  |       HASH GROUP BY          |            |   700 |   18K |    65 |  00:00:01 |
| 12  |        FILTER                |            |       |       |       |           |
| 13  |         INDEX FAST FULL SCAN | T1_PK      |  106K | 2755K |    60 |  00:00:01 |
| 14  |      INDEX RANGE SCAN        | T1_LINES_PK|    28 |  1036 |     3 |  00:00:01 |
--------------------------------------------------+-----------------------------------+
Predicate Information:
----------------------
2 - filter(("EL"."FCDUEDATE">COALESCE("CO"."DESIRED_SHIP_DATE",SYSDATE@!-365) AND COALESCE("CO"."DESIRED_SHIP_DATE",SYSDATE@!-365)<SYSDATE@!+1200))
3 - access("E"."CUSTPO"="CO"."CUSTOMER_PO_REF")
6 - access("CO"."ID"="COL"."CUST_ORDER_ID")
7 - filter("CUSTOMER_PO_REF" IS NOT NULL)
8 - filter("COL"."DESIRED_SHIP_DATE">=SYSDATE@!-365)
12 - filter(SYSDATE@!-365<=SYSDATE@!+1200)
14 - access("E"."CUSTPO"="EL"."CUSTPO" AND "E"."RELID"="EL"."RELID" AND "EL"."FCDUEDATE">=SYSDATE@!-365 AND "EL"."FCSTQTY">0 AND "EL"."FCDUEDATE"<=SYSDATE@!+1200)
14 - filter("EL"."FCSTQTY">0)

Statistics
----------------------------------------------------------                     
          1  recursive calls                                                   
          0  db block gets                                                     
       7457  consistent gets                                                   
          0  physical reads                                                    
          0  redo size                                                         
     141157  bytes sent via SQL*Net to client                                  
        470  bytes received via SQL*Net from client                            
         12  SQL*Net roundtrips to/from client                                 
          1  sorts (memory)                                                    
          0  sorts (disk)                                                      
      10478  rows processed

INSERT_10.2.0.2 (OPTIMIZER_FEATURES_ENABLE=’10.2.0.2′, OPTIMIZER_INDEX_CACHING=0, OPTIMIZER_INDEX_COST_ADJ=100), completed in 0.23 seconds when inserting 10,478 rows:

---------------------------------------------------+-----------------------------------+
| Id  | Operation                     | Name       | Rows  | Bytes | Cost  | Time      |
---------------------------------------------------+-----------------------------------+
| 0   | INSERT STATEMENT              |            |       |       |  1425 |           |
| 1   |  LOAD TABLE CONVENTIONAL      |            |       |       |       |           |
| 2   |   SORT GROUP BY               |            |   486 |   46K |  1425 |  00:00:12 |
| 3   |    FILTER                     |            |       |       |       |           |
| 4   |     HASH JOIN RIGHT OUTER     |            |   19K | 1882K |  1423 |  00:00:12 |
| 5   |      VIEW                     |            |   700 |   27K |   368 |  00:00:03 |
| 6   |       SORT GROUP BY           |            |   700 |   40K |   368 |  00:00:03 |
| 7   |        HASH JOIN              |            |  146K | 8452K |   362 |  00:00:03 |
| 8   |         TABLE ACCESS FULL     | T2         |   700 |   18K |     3 |  00:00:01 |
| 9   |         TABLE ACCESS FULL     | T2_LINES   |  146K | 4663K |   358 |  00:00:03 |
| 10  |      NESTED LOOPS             |            |   19K | 1126K |  1055 |  00:00:09 |
| 11  |       VIEW                    |            |   700 |   14K |    65 |  00:00:01 |
| 12  |        SORT GROUP BY          |            |   700 |   18K |    65 |  00:00:01 |
| 13  |         FILTER                |            |       |       |       |           |
| 14  |          INDEX FAST FULL SCAN | T1_PK      |  106K | 2755K |    60 |  00:00:01 |
| 15  |       INDEX RANGE SCAN        | T1_LINES_PK|    28 |  1036 |     3 |  00:00:01 |
---------------------------------------------------+-----------------------------------+
Predicate Information:
----------------------
3 - filter(("EL"."FCDUEDATE">COALESCE("CO"."DESIRED_SHIP_DATE",SYSDATE@!-365) AND COALESCE("CO"."DESIRED_SHIP_DATE",SYSDATE@!-365)<SYSDATE@!+1200))
4 - access("E"."CUSTPO"="CO"."CUSTOMER_PO_REF")
7 - access("CO"."ID"="COL"."CUST_ORDER_ID")
8 - filter("CUSTOMER_PO_REF" IS NOT NULL)
9 - filter("COL"."DESIRED_SHIP_DATE">=SYSDATE@!-365)
13 - filter(SYSDATE@!-365<=SYSDATE@!+1200)
15 - access("E"."CUSTPO"="EL"."CUSTPO" AND "E"."RELID"="EL"."RELID" AND "EL"."FCDUEDATE">=SYSDATE@!-365 AND "EL"."FCSTQTY">0 AND "EL"."FCDUEDATE"<=SYSDATE@!+1200)
15 - filter("EL"."FCSTQTY">0)

Statistics
----------------------------------------------------------                     
        186  recursive calls                                                   
        341  db block gets                                                     
       7561  consistent gets                                                   
          0  physical reads                                                    
     397832  redo size                                                         
        569  bytes sent via SQL*Net to client                                  
       1520  bytes received via SQL*Net from client                            
          3  SQL*Net roundtrips to/from client                                 
          4  sorts (memory)                                                    
          0  sorts (disk)                                                      
      10478  rows processed

SELECT_11.1.0.7 (OPTIMIZER_FEATURES_ENABLE=’11.1.0.7′, OPTIMIZER_INDEX_CACHING=0, OPTIMIZER_INDEX_COST_ADJ=100), completed in 0.23 seconds when selecting 10,478 rows:

--------------------------------------------------+-----------------------------------+
| Id  | Operation                    | Name       | Rows  | Bytes | Cost  | Time      |
--------------------------------------------------+-----------------------------------+
| 0   | SELECT STATEMENT             |            |       |       |  1392 |           |
| 1   |  SORT GROUP BY               |            |   829 |   79K |  1392 |  00:00:12 |
| 2   |   FILTER                     |            |       |       |       |           |
| 3   |    HASH JOIN RIGHT OUTER     |            |   19K | 1882K |  1390 |  00:00:12 |
| 4   |     VIEW                     |            |   700 |   27K |   368 |  00:00:03 |
| 5   |      HASH GROUP BY           |            |   700 |   40K |   368 |  00:00:03 |
| 6   |       HASH JOIN              |            |  146K | 8452K |   362 |  00:00:03 |
| 7   |        TABLE ACCESS FULL     | T2         |   700 |   18K |     3 |  00:00:01 |
| 8   |        TABLE ACCESS FULL     | T2_LINES   |  146K | 4663K |   358 |  00:00:03 |
| 9   |     NESTED LOOPS             |            |   19K | 1126K |  1022 |  00:00:09 |
| 10  |      VIEW                    |            |   700 |   14K |    65 |  00:00:01 |
| 11  |       HASH GROUP BY          |            |   700 |   18K |    65 |  00:00:01 |
| 12  |        FILTER                |            |       |       |       |           |
| 13  |         INDEX FAST FULL SCAN | T1_PK      |  106K | 2755K |    60 |  00:00:01 |
| 14  |      INDEX RANGE SCAN        | T1_LINES_PK|    28 |  1036 |     3 |  00:00:01 |
--------------------------------------------------+-----------------------------------+
Predicate Information:
----------------------
2 - filter(("EL"."FCDUEDATE">COALESCE("CO"."DESIRED_SHIP_DATE",SYSDATE@!-365) AND COALESCE("CO"."DESIRED_SHIP_DATE",SYSDATE@!-365)<SYSDATE@!+1200))
3 - access("E"."CUSTPO"="CO"."CUSTOMER_PO_REF")
6 - access("CO"."ID"="COL"."CUST_ORDER_ID")
7 - filter("CUSTOMER_PO_REF" IS NOT NULL)
8 - filter("COL"."DESIRED_SHIP_DATE">=SYSDATE@!-365)
12 - filter(SYSDATE@!-365<=SYSDATE@!+1200)
14 - access("E"."CUSTPO"="EL"."CUSTPO" AND "E"."RELID"="EL"."RELID" AND "EL"."FCDUEDATE">=SYSDATE@!-365 AND "EL"."FCSTQTY">0 AND "EL"."FCDUEDATE"<=SYSDATE@!+1200)
14 - filter("EL"."FCSTQTY">0)

Statistics
----------------------------------------------------------                     
          1  recursive calls                                                   
          0  db block gets                                                     
       7457  consistent gets                                                   
          0  physical reads                                                    
          0  redo size                                                         
     141157  bytes sent via SQL*Net to client                                  
        470  bytes received via SQL*Net from client                            
         12  SQL*Net roundtrips to/from client                                 
          1  sorts (memory)                                                    
          0  sorts (disk)                                                      
      10478  rows processed

INSERT_11.1.0.7 (OPTIMIZER_FEATURES_ENABLE=’11.1.0.7′, OPTIMIZER_INDEX_CACHING=0, OPTIMIZER_INDEX_COST_ADJ=100), completed in 0.25 seconds when inserting 10,478 rows:

---------------------------------------------------+-----------------------------------+
| Id  | Operation                     | Name       | Rows  | Bytes | Cost  | Time      |
---------------------------------------------------+-----------------------------------+
| 0   | INSERT STATEMENT              |            |       |       |  1392 |           |
| 1   |  LOAD TABLE CONVENTIONAL      |            |       |       |       |           |
| 2   |   SORT GROUP BY               |            |   829 |   79K |  1392 |  00:00:12 |
| 3   |    FILTER                     |            |       |       |       |           |
| 4   |     HASH JOIN RIGHT OUTER     |            |   19K | 1882K |  1390 |  00:00:12 |
| 5   |      VIEW                     |            |   700 |   27K |   368 |  00:00:03 |
| 6   |       SORT GROUP BY           |            |   700 |   40K |   368 |  00:00:03 |
| 7   |        HASH JOIN              |            |  146K | 8452K |   362 |  00:00:03 |
| 8   |         TABLE ACCESS FULL     | T2         |   700 |   18K |     3 |  00:00:01 |
| 9   |         TABLE ACCESS FULL     | T2_LINES   |  146K | 4663K |   358 |  00:00:03 |
| 10  |      NESTED LOOPS             |            |   19K | 1126K |  1022 |  00:00:09 |
| 11  |       VIEW                    |            |   700 |   14K |    65 |  00:00:01 |
| 12  |        SORT GROUP BY          |            |   700 |   18K |    65 |  00:00:01 |
| 13  |         FILTER                |            |       |       |       |           |
| 14  |          INDEX FAST FULL SCAN | T1_PK      |  106K | 2755K |    60 |  00:00:01 |
| 15  |       INDEX RANGE SCAN        | T1_LINES_PK|    28 |  1036 |     3 |  00:00:01 |
---------------------------------------------------+-----------------------------------+
Predicate Information:
----------------------
3 - filter(("EL"."FCDUEDATE">COALESCE("CO"."DESIRED_SHIP_DATE",SYSDATE@!-365) AND COALESCE("CO"."DESIRED_SHIP_DATE",SYSDATE@!-365)<SYSDATE@!+1200))
4 - access("E"."CUSTPO"="CO"."CUSTOMER_PO_REF")
7 - access("CO"."ID"="COL"."CUST_ORDER_ID")
8 - filter("CUSTOMER_PO_REF" IS NOT NULL)
9 - filter("COL"."DESIRED_SHIP_DATE">=SYSDATE@!-365)
13 - filter(SYSDATE@!-365<=SYSDATE@!+1200)
15 - access("E"."CUSTPO"="EL"."CUSTPO" AND "E"."RELID"="EL"."RELID" AND "EL"."FCDUEDATE">=SYSDATE@!-365 AND "EL"."FCSTQTY">0 AND "EL"."FCDUEDATE"<=SYSDATE@!+1200)
15 - filter("EL"."FCSTQTY">0) 

Statistics
----------------------------------------------------------                     
        186  recursive calls                                                   
        341  db block gets                                                     
       7564  consistent gets                                                   
          0  physical reads                                                    
     397816  redo size                                                         
        569  bytes sent via SQL*Net to client                                  
       1520  bytes received via SQL*Net from client                            
          3  SQL*Net roundtrips to/from client                                 
          4  sorts (memory)                                                    
          0  sorts (disk)                                                      
      10478  rows processed

SELECT_11.2.0.1 (OPTIMIZER_FEATURES_ENABLE=’11.2.0.1′, OPTIMIZER_INDEX_CACHING=0, OPTIMIZER_INDEX_COST_ADJ=100), completed in 0.21 seconds when selecting 10,478 rows:

--------------------------------------------------+-----------------------------------+
| Id  | Operation                    | Name       | Rows  | Bytes | Cost  | Time      |
--------------------------------------------------+-----------------------------------+
| 0   | SELECT STATEMENT             |            |       |       |  1392 |           |
| 1   |  SORT GROUP BY               |            |   829 |   79K |  1392 |  00:00:12 |
| 2   |   FILTER                     |            |       |       |       |           |
| 3   |    HASH JOIN RIGHT OUTER     |            |   19K | 1882K |  1390 |  00:00:12 |
| 4   |     VIEW                     |            |   700 |   27K |   368 |  00:00:03 |
| 5   |      HASH GROUP BY           |            |   700 |   40K |   368 |  00:00:03 |
| 6   |       HASH JOIN              |            |  146K | 8452K |   362 |  00:00:03 |
| 7   |        TABLE ACCESS FULL     | T2         |   700 |   18K |     3 |  00:00:01 |
| 8   |        TABLE ACCESS FULL     | T2_LINES   |  146K | 4663K |   358 |  00:00:03 |
| 9   |     NESTED LOOPS             |            |   19K | 1126K |  1022 |  00:00:09 |
| 10  |      VIEW                    |            |   700 |   14K |    65 |  00:00:01 |
| 11  |       HASH GROUP BY          |            |   700 |   18K |    65 |  00:00:01 |
| 12  |        FILTER                |            |       |       |       |           |
| 13  |         INDEX FAST FULL SCAN | T1_PK      |  106K | 2755K |    60 |  00:00:01 |
| 14  |      INDEX RANGE SCAN        | T1_LINES_PK|    28 |  1036 |     3 |  00:00:01 |
--------------------------------------------------+-----------------------------------+
Predicate Information:
----------------------
2 - filter(("EL"."FCDUEDATE">COALESCE("CO"."DESIRED_SHIP_DATE",SYSDATE@!-365) AND COALESCE("CO"."DESIRED_SHIP_DATE",SYSDATE@!-365)<SYSDATE@!+1200))
3 - access("E"."CUSTPO"="CO"."CUSTOMER_PO_REF")
6 - access("CO"."ID"="COL"."CUST_ORDER_ID")
7 - filter("CUSTOMER_PO_REF" IS NOT NULL)
8 - filter("COL"."DESIRED_SHIP_DATE">=SYSDATE@!-365)
12 - filter(SYSDATE@!-365<=SYSDATE@!+1200)
14 - access("E"."CUSTPO"="EL"."CUSTPO" AND "E"."RELID"="EL"."RELID" AND "EL"."FCDUEDATE">=SYSDATE@!-365 AND "EL"."FCSTQTY">0 AND "EL"."FCDUEDATE"<=SYSDATE@!+1200)
14 - filter("EL"."FCSTQTY">0)

Statistics
----------------------------------------------------------                     
          1  recursive calls                                                   
          0  db block gets                                                     
       7457  consistent gets                                                   
          0  physical reads                                                    
          0  redo size                                                         
     141157  bytes sent via SQL*Net to client                                  
        470  bytes received via SQL*Net from client                            
         12  SQL*Net roundtrips to/from client                                 
          1  sorts (memory)                                                    
          0  sorts (disk)                                                      
      10478  rows processed

INSERT_11.2.0.1 (OPTIMIZER_FEATURES_ENABLE=’11.2.0.1′, OPTIMIZER_INDEX_CACHING=0, OPTIMIZER_INDEX_COST_ADJ=100), completed in 0.26 seconds when inserting 10,478 rows:

---------------------------------------------------+-----------------------------------+
| Id  | Operation                     | Name       | Rows  | Bytes | Cost  | Time      |
---------------------------------------------------+-----------------------------------+
| 0   | INSERT STATEMENT              |            |       |       |  1392 |           |
| 1   |  LOAD TABLE CONVENTIONAL      |            |       |       |       |           |
| 2   |   SORT GROUP BY               |            |   829 |   79K |  1392 |  00:00:12 |
| 3   |    FILTER                     |            |       |       |       |           |
| 4   |     HASH JOIN RIGHT OUTER     |            |   19K | 1882K |  1390 |  00:00:12 |
| 5   |      VIEW                     |            |   700 |   27K |   368 |  00:00:03 |
| 6   |       SORT GROUP BY           |            |   700 |   40K |   368 |  00:00:03 |
| 7   |        HASH JOIN              |            |  146K | 8452K |   362 |  00:00:03 |
| 8   |         TABLE ACCESS FULL     | T2         |   700 |   18K |     3 |  00:00:01 |
| 9   |         TABLE ACCESS FULL     | T2_LINES   |  146K | 4663K |   358 |  00:00:03 |
| 10  |      NESTED LOOPS             |            |   19K | 1126K |  1022 |  00:00:09 |
| 11  |       VIEW                    |            |   700 |   14K |    65 |  00:00:01 |
| 12  |        SORT GROUP BY          |            |   700 |   18K |    65 |  00:00:01 |
| 13  |         FILTER                |            |       |       |       |           |
| 14  |          INDEX FAST FULL SCAN | T1_PK      |  106K | 2755K |    60 |  00:00:01 |
| 15  |       INDEX RANGE SCAN        | T1_LINES_PK|    28 |  1036 |     3 |  00:00:01 |
---------------------------------------------------+-----------------------------------+
Predicate Information:
----------------------
3 - filter(("EL"."FCDUEDATE">COALESCE("CO"."DESIRED_SHIP_DATE",SYSDATE@!-365) AND COALESCE("CO"."DESIRED_SHIP_DATE",SYSDATE@!-365)<SYSDATE@!+1200))
4 - access("E"."CUSTPO"="CO"."CUSTOMER_PO_REF")
7 - access("CO"."ID"="COL"."CUST_ORDER_ID")
8 - filter("CUSTOMER_PO_REF" IS NOT NULL)
9 - filter("COL"."DESIRED_SHIP_DATE">=SYSDATE@!-365)
13 - filter(SYSDATE@!-365<=SYSDATE@!+1200)
15 - access("E"."CUSTPO"="EL"."CUSTPO" AND "E"."RELID"="EL"."RELID" AND "EL"."FCDUEDATE">=SYSDATE@!-365 AND "EL"."FCSTQTY">0 AND "EL"."FCDUEDATE"<=SYSDATE@!+1200)
15 - filter("EL"."FCSTQTY">0) 

Statistics
----------------------------------------------------------                     
        186  recursive calls                                                   
        341  db block gets                                                     
       7563  consistent gets                                                   
          0  physical reads                                                    
     397876  redo size                                                         
        569  bytes sent via SQL*Net to client                                  
       1520  bytes received via SQL*Net from client                            
          3  SQL*Net roundtrips to/from client                                 
          4  sorts (memory)                                                    
          0  sorts (disk)                                                      
      10478  rows processed

——————–

SELECT_10.1.0.4 (OPTIMIZER_FEATURES_ENABLE=’10.1.0.4′, OPTIMIZER_INDEX_CACHING=100, OPTIMIZER_INDEX_COST_ADJ=80), completed in 0.21 seconds when selecting 10,478 rows (execution plan is affected by the changes to OPTIMIZER_INDEX_CACHING and OPTIMIZER_INDEX_COST_ADJ):

--------------------------------------------------+-----------------------------------+
| Id  | Operation                    | Name       | Rows  | Bytes | Cost  | Time      |
--------------------------------------------------+-----------------------------------+
| 0   | SELECT STATEMENT             |            |       |       |   436 |           |
| 1   |  SORT GROUP BY               |            |   486 |   46K |   436 |  00:00:04 |
| 2   |   NESTED LOOPS               |            |   994 |   94K |   435 |  00:00:04 |
| 3   |    FILTER                    |            |       |       |       |           |
| 4   |     HASH JOIN OUTER          |            |   700 |   41K |   433 |  00:00:04 |
| 5   |      VIEW                    |            |   700 |   14K |    65 |  00:00:01 |
| 6   |       SORT GROUP BY          |            |   700 |   18K |    65 |  00:00:01 |
| 7   |        FILTER                |            |       |       |       |           |
| 8   |         INDEX FAST FULL SCAN | T1_PK      |  106K | 2755K |    60 |  00:00:01 |
| 9   |      VIEW                    |            |   700 |   27K |   368 |  00:00:03 |
| 10  |       SORT GROUP BY          |            |   700 |   40K |   368 |  00:00:03 |
| 11  |        HASH JOIN             |            |  146K | 8452K |   362 |  00:00:03 |
| 12  |         TABLE ACCESS FULL    | T2         |   700 |   18K |     3 |  00:00:01 |
| 13  |         TABLE ACCESS FULL    | T2_LINES   |  146K | 4663K |   358 |  00:00:03 |
| 14  |    INDEX RANGE SCAN          | T1_LINES_PK|     1 |    37 |     1 |  00:00:01 |
--------------------------------------------------+-----------------------------------+
Predicate Information:
----------------------
3 - filter(COALESCE("CO"."DESIRED_SHIP_DATE",SYSDATE@!-365)<SYSDATE@!+1200)
4 - access("E"."CUSTPO"="CO"."CUSTOMER_PO_REF")
7 - filter(SYSDATE@!-365<=SYSDATE@!+1200)
11 - access("CO"."ID"="COL"."CUST_ORDER_ID")
12 - filter("CUSTOMER_PO_REF" IS NOT NULL)
13 - filter("COL"."DESIRED_SHIP_DATE">=SYSDATE@!-365)
14 - access("E"."CUSTPO"="EL"."CUSTPO" AND "E"."RELID"="EL"."RELID" AND "EL"."FCDUEDATE">=SYSDATE@!-365 AND "EL"."FCSTQTY">0 AND "EL"."FCDUEDATE"<=SYSDATE@!+1200)
14 - filter(("EL"."FCSTQTY">0 AND "EL"."FCDUEDATE">COALESCE("CO"."DESIRED_SHIP_DATE",SYSDATE@!-365))) 

Statistics
----------------------------------------------------------                     
          1  recursive calls                                                   
          0  db block gets                                                     
       7457  consistent gets                                                   
          0  physical reads                                                    
          0  redo size                                                         
     141157  bytes sent via SQL*Net to client                                  
        470  bytes received via SQL*Net from client                            
         12  SQL*Net roundtrips to/from client                                 
          3  sorts (memory)                                                    
          0  sorts (disk)                                                      
      10478  rows processed

INSERT_10.1.0.4 (OPTIMIZER_FEATURES_ENABLE=’10.1.0.4′, OPTIMIZER_INDEX_CACHING=100, OPTIMIZER_INDEX_COST_ADJ=80), completed in… 15 minutes, 11.32 seconds when inserting 10,478 rows (execution plan is unaffected by the changes to OPTIMIZER_INDEX_CACHING and OPTIMIZER_INDEX_COST_ADJ, although the execution completed twice as fast):

-------------------------------------------------+-----------------------------------+
| Id  | Operation                      | Name    | Rows  | Bytes | Cost  | Time      |
-------------------------------------------------+-----------------------------------+
| 0   | INSERT STATEMENT               |         |       |       | 4964K |           |
| 1   |  LOAD TABLE CONVENTIONAL       |         |       |       |       |           |
| 2   |   SORT GROUP BY                |         |   842 |   60K | 4964K |  11:18:45 |
| 3   |    FILTER                      |         |       |       |       |           |
| 4   |     HASH JOIN OUTER            |         |   842 |   60K | 4964K |  11:18:45 |
| 5   |      VIEW                      |         |   842 |   28K | 4964K |  11:18:42 |
| 6   |       FILTER                   |         |       |       |       |           |
| 7   |        SORT GROUP BY           |         |   842 |   53K | 4964K |  11:18:42 |
| 8   |         FILTER                 |         |       |       |       |           |
| 9   |          HASH JOIN             |         |  852M |   54G |  7031 |  00:00:57 |
| 10  |           INDEX FAST FULL SCAN | T1_PK   |  106K | 2755K |    60 |  00:00:01 |
| 11  |           TABLE ACCESS FULL    | T1_LINES| 5628K |  214M |  3388 |  00:00:28 |
| 12  |      VIEW                      |         |   700 |   27K |   368 |  00:00:03 |
| 13  |       SORT GROUP BY            |         |   700 |   40K |   368 |  00:00:03 |
| 14  |        HASH JOIN               |         |  146K | 8452K |   362 |  00:00:03 |
| 15  |         TABLE ACCESS FULL      | T2      |   700 |   18K |     3 |  00:00:01 |
| 16  |         TABLE ACCESS FULL      | T2_LINES|  146K | 4663K |   358 |  00:00:03 |
-------------------------------------------------+-----------------------------------+
Predicate Information:
----------------------
3 - filter("E"."FCDUEDATE">COALESCE("CO"."DESIRED_SHIP_DATE",SYSDATE@!-365))
4 - access("E"."CUSTPO"="CO"."CUSTOMER_PO_REF")
6 - filter("EL"."RELID"=MAX("RELID"))
8 - filter(SYSDATE@!-365<=SYSDATE@!+1200)
9 - access("E"."CUSTPO"="EL"."CUSTPO")
11 - filter(("EL"."FCDUEDATE">=SYSDATE@!-365 AND "EL"."FCDUEDATE"<=SYSDATE@!+1200 AND "EL"."FCSTQTY">0))
14 - access("CO"."ID"="COL"."CUST_ORDER_ID")
15 - filter("CUSTOMER_PO_REF" IS NOT NULL)
16 - filter("COL"."DESIRED_SHIP_DATE">=SYSDATE@!-365)

Statistics
----------------------------------------------------------                     
        618  recursive calls                                                   
        388  db block gets                                                     
      42148  consistent gets                                                   
     107080  physical reads                                                    
     397876  redo size                                                         
        569  bytes sent via SQL*Net to client                                  
       1523  bytes received via SQL*Net from client                            
          3  SQL*Net roundtrips to/from client                                 
          3  sorts (memory)                                                    
          1  sorts (disk)                                                      
      10478  rows processed

SELECT_10.2.0.2 (OPTIMIZER_FEATURES_ENABLE=’10.2.0.2′, OPTIMIZER_INDEX_CACHING=100, OPTIMIZER_INDEX_COST_ADJ=80), completed in 0.20 seconds when selecting 10,478 rows (excution plans are identical for SELECT and INSERT INTO for the OPTIMIZER_FEATURES_ENABLE values 10.2.0.2, 11.1.0.7, and 11.2.0.1):

--------------------------------------------------+-----------------------------------+
| Id  | Operation                    | Name       | Rows  | Bytes | Cost  | Time      |
--------------------------------------------------+-----------------------------------+
| 0   | SELECT STATEMENT             |            |       |       |   436 |           |
| 1   |  SORT GROUP BY               |            |   486 |   46K |   436 |  00:00:04 |
| 2   |   NESTED LOOPS               |            |   994 |   94K |   435 |  00:00:04 |
| 3   |    FILTER                    |            |       |       |       |           |
| 4   |     HASH JOIN OUTER          |            |   700 |   41K |   433 |  00:00:04 |
| 5   |      VIEW                    |            |   700 |   14K |    65 |  00:00:01 |
| 6   |       HASH GROUP BY          |            |   700 |   18K |    65 |  00:00:01 |
| 7   |        FILTER                |            |       |       |       |           |
| 8   |         INDEX FAST FULL SCAN | T1_PK      |  106K | 2755K |    60 |  00:00:01 |
| 9   |      VIEW                    |            |   700 |   27K |   368 |  00:00:03 |
| 10  |       HASH GROUP BY          |            |   700 |   40K |   368 |  00:00:03 |
| 11  |        HASH JOIN             |            |  146K | 8452K |   362 |  00:00:03 |
| 12  |         TABLE ACCESS FULL    | T2         |   700 |   18K |     3 |  00:00:01 |
| 13  |         TABLE ACCESS FULL    | T2_LINES   |  146K | 4663K |   358 |  00:00:03 |
| 14  |    INDEX RANGE SCAN          | T1_LINES_PK|     1 |    37 |     1 |  00:00:01 |
--------------------------------------------------+-----------------------------------+
Predicate Information:
----------------------
3 - filter(COALESCE("CO"."DESIRED_SHIP_DATE",SYSDATE@!-365)<SYSDATE@!+1200)
4 - access("E"."CUSTPO"="CO"."CUSTOMER_PO_REF")
7 - filter(SYSDATE@!-365<=SYSDATE@!+1200)
11 - access("CO"."ID"="COL"."CUST_ORDER_ID")
12 - filter("CUSTOMER_PO_REF" IS NOT NULL)
13 - filter("COL"."DESIRED_SHIP_DATE">=SYSDATE@!-365)
14 - access("E"."CUSTPO"="EL"."CUSTPO" AND "E"."RELID"="EL"."RELID" AND "EL"."FCDUEDATE">=SYSDATE@!-365 AND "EL"."FCSTQTY">0 AND "EL"."FCDUEDATE"<=SYSDATE@!+1200)
14 - filter(("EL"."FCSTQTY">0 AND "EL"."FCDUEDATE">COALESCE("CO"."DESIRED_SHIP_DATE",SYSDATE@!-365)))

Statistics
----------------------------------------------------------                     
          1  recursive calls                                                   
          0  db block gets                                                     
       7457  consistent gets                                                   
          0  physical reads                                                    
          0  redo size                                                         
     141157  bytes sent via SQL*Net to client                                  
        470  bytes received via SQL*Net from client                            
         12  SQL*Net roundtrips to/from client                                 
          1  sorts (memory)                                                    
          0  sorts (disk)                                                      
      10478  rows processed

————————-

The odd twist… assume that you used either Oracle Database 11.2.0.1 or 11.2.0.2 for the test.  12 hours after your test completed, you executed the following SQL statements to pull the execution plans and non-default optimizer parameters for the test SQL statements from the server’s memory:

SET AUTOTRACE OFF
SET LINESIZE 150
SET PAGESIZE 1000
SET TRIMSPOOL ON
SPOOL MYSQL_PLANS.TXT

SELECT /*+ LEADING(S) USE_NL(S T) */
  T.PLAN_TABLE_OUTPUT
FROM
  (SELECT
    SQL_ID,
    CHILD_NUMBER,
    COUNT(*) OVER (PARTITION BY SQL_ID) C
  FROM
    V$SQL
  WHERE
    SQL_TEXT LIKE '%T2%'
    AND SQL_TEXT LIKE '%T1%'
    AND SQL_TEXT NOT LIKE '%MGMT_NOTIFY%'
  ORDER BY
    SQL_ID,
    CHILD_NUMBER) S,
  TABLE(DBMS_XPLAN.DISPLAY_CURSOR(S.SQL_ID,S.CHILD_NUMBER,'TYPICAL')) T
WHERE
  S.C>=1;

SPOOL OFF

SET LINESIZE 150
SET PAGESIZE 1000
SET TRIMSPOOL ON
SPOOL MYSQL_OPTIMIZER_ENV.TXT

SELECT /*+ LEADING(S) USE_NL(S T) */
  SOE.SQL_ID,
  SOE.CHILD_NUMBER,
  SOE.NAME,
  SOE.VALUE
FROM
  (SELECT
    SQL_ID,
    CHILD_NUMBER,
    COUNT(*) OVER (PARTITION BY SQL_ID) C
  FROM
    V$SQL
  WHERE
    SQL_TEXT LIKE '%T2%'
    AND SQL_TEXT LIKE '%T1%'
    AND SQL_TEXT NOT LIKE '%MGMT_NOTIFY%'
  ORDER BY
    SQL_ID,
    CHILD_NUMBER) S,
  V$SQL_OPTIMIZER_ENV SOE
WHERE
  S.SQL_ID=SOE.SQL_ID
  AND S.CHILD_NUMBER=SOE.CHILD_NUMBER
  AND SOE.ISDEFAULT='NO'
ORDER BY
  SOE.SQL_ID,
  SOE.CHILD_NUMBER,
  SOE.NAME;

SPOOL OFF 

Assume that you saw included in the output something like this following:

SQL_ID  4kkx042dnfuvf, child number 0
-------------------------------------
/* SQL Analyze(7,1) */ SELECT /*+ LEADING(E) */
COALESCE(CO.PART_ID,'NOT-IN-SYSTEM') PART_ID,   E.FCDUEDATE
REQUIRED_DATE,   SUM(E.FCSTQTY) QTY,   1 PLAN_LEVEL FROM   (SELECT /*+
LEADING(E) */     E.CUSTPO,     EL.FCSTQTY,     EL.FCDUEDATE   FROM
(SELECT /*+ _80 */       E.CUSTPO,       MAX(RELID) RELID     FROM
 T1 E     GROUP BY       E.CUSTPO) E,     T1_LINES EL   WHERE
E.CUSTPO=EL.CUSTPO     AND E.RELID=EL.RELID     AND EL.FCDUEDATE
BETWEEN SYSDATE-365 AND SYSDATE+1200     AND EL.FCSTQTY>0) E,   (SELECT
/*+  */     CO.CUSTOMER_PO_REF,     MAX(COL.DESIRED_SHIP_DATE)
DESIRED_SHIP_DATE,     MAX(COL.PART_ID) PART_ID   FROM     T2 CO,
T2_LINES COL   WHERE     CO.ID=COL.CUST_ORDER_ID     AND
CUSTOMER_PO_REF IS NOT NULL     AND COL.DESIRED_SHIP_DATE>=SYSDATE-365
 GROUP BY     CO.CUSTOMER_PO_REF) CO WHERE
E.CUSTPO=CO.CUSTOMER_PO_REF(+)   AND
E.FCDUEDATE>COALESCE(CO.DESIRED_SHIP_DATE,SYSDATE-365) GROUP BY
COALESCE(CO.PART_ID,'NOT-IN-SYSTEM'),   E.FCDUEDATE ORDER BY

Plan hash value: 1947245329

-------------------------------------------------------------------------------------------
| Id  | Operation                   | Name        | Rows  | Bytes | Cost (%CPU)| Time     |
-------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT            |             |       |       |   436 (100)|          |
|   1 |  SORT GROUP BY              |             |   829 | 80413 |   436   (7)| 00:00:04 |
|   2 |   NESTED LOOPS              |             |   994 | 96418 |   435   (6)| 00:00:04 |
|*  3 |    FILTER                   |             |       |       |            |          |
|*  4 |     HASH JOIN OUTER         |             |   700 | 42000 |   433   (6)| 00:00:04 |
|   5 |      VIEW                   |             |   700 | 14700 |    65  (10)| 00:00:01 |
|   6 |       HASH GROUP BY         |             |   700 | 18200 |    65  (10)| 00:00:01 |
|*  7 |        FILTER               |             |       |       |            |          |
|   8 |         INDEX FAST FULL SCAN| T1_PK       |   108K|  2754K|    60   (2)| 00:00:01 |
|   9 |      VIEW                   |             |   700 | 27300 |   368   (6)| 00:00:03 |
|  10 |       HASH GROUP BY         |             |   700 | 40600 |   368   (6)| 00:00:03 |
|* 11 |        HASH JOIN            |             |   149K|  8456K|   362   (4)| 00:00:03 |
|* 12 |         TABLE ACCESS FULL   | T2          |   700 | 18200 |     3   (0)| 00:00:01 |
|* 13 |         TABLE ACCESS FULL   | T2_LINES    |   149K|  4665K|   358   (4)| 00:00:03 |
|* 14 |    INDEX RANGE SCAN         | T1_LINES_PK |     1 |    37 |     1   (0)| 00:00:01 |
-------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------
   3 - filter(COALESCE("CO"."DESIRED_SHIP_DATE",SYSDATE@!-365)<SYSDATE@!+1200)
   4 - access("E"."CUSTPO"="CO"."CUSTOMER_PO_REF")
   7 - filter(SYSDATE@!-365<=SYSDATE@!+1200)
  11 - access("CO"."ID"="COL"."CUST_ORDER_ID")
  12 - filter("CUSTOMER_PO_REF" IS NOT NULL)
  13 - filter("COL"."DESIRED_SHIP_DATE">=SYSDATE@!-365)
  14 - access("E"."CUSTPO"="EL"."CUSTPO" AND "E"."RELID"="EL"."RELID" AND
              "EL"."FCDUEDATE">=SYSDATE@!-365 AND "EL"."FCSTQTY">0 AND
              "EL"."FCDUEDATE"<=SYSDATE@!+1200)
       filter(("EL"."FCSTQTY">0 AND "EL"."FCDUEDATE">COALESCE("CO"."DESIRED_SHIP_DA
              TE",SYSDATE@!-365))) 

 

SQL_ID  4kkx042dnfuvf, child number 1
-------------------------------------
/* SQL Analyze(7,1) */ SELECT /*+ LEADING(E) */
COALESCE(CO.PART_ID,'NOT-IN-SYSTEM') PART_ID,   E.FCDUEDATE
REQUIRED_DATE,   SUM(E.FCSTQTY) QTY,   1 PLAN_LEVEL FROM   (SELECT /*+
LEADING(E) */     E.CUSTPO,     EL.FCSTQTY,     EL.FCDUEDATE   FROM
(SELECT /*+ _80 */       E.CUSTPO,       MAX(RELID) RELID     FROM
 T1 E     GROUP BY       E.CUSTPO) E,     T1_LINES EL   WHERE
E.CUSTPO=EL.CUSTPO     AND E.RELID=EL.RELID     AND EL.FCDUEDATE
BETWEEN SYSDATE-365 AND SYSDATE+1200     AND EL.FCSTQTY>0) E,   (SELECT
/*+  */     CO.CUSTOMER_PO_REF,     MAX(COL.DESIRED_SHIP_DATE)
DESIRED_SHIP_DATE,     MAX(COL.PART_ID) PART_ID   FROM     T2 CO,
T2_LINES COL   WHERE     CO.ID=COL.CUST_ORDER_ID     AND
CUSTOMER_PO_REF IS NOT NULL     AND COL.DESIRED_SHIP_DATE>=SYSDATE-365
 GROUP BY     CO.CUSTOMER_PO_REF) CO WHERE
E.CUSTPO=CO.CUSTOMER_PO_REF(+)   AND
E.FCDUEDATE>COALESCE(CO.DESIRED_SHIP_DATE,SYSDATE-365) GROUP BY
COALESCE(CO.PART_ID,'NOT-IN-SYSTEM'),   E.FCDUEDATE ORDER BY

Plan hash value: 1232865634

---------------------------------------------------------------------------------------------------------
| Id  | Operation                        | Name         | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
---------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT                 |              |       |       |       |  5087K(100)|          |
|   1 |  SORT GROUP BY                   |              |   842 | 61466 |       |  5087K  (2)| 11:18:20 |
|*  2 |   FILTER                         |              |       |       |       |            |          |
|*  3 |    HASH JOIN OUTER               |              |   842 | 61466 |       |  5087K  (2)| 11:18:20 |
|   4 |     VIEW                         |              |   842 | 28628 |       |  5083K  (2)| 11:17:48 |
|*  5 |      FILTER                      |              |       |       |       |            |          |
|   6 |       SORT GROUP BY              |              |   842 | 54730 |    77G|  5083K  (2)| 11:17:48 |
|*  7 |        FILTER                    |              |       |       |       |            |          |
|   8 |         NESTED LOOPS             |              |   893M|    54G|       |  7225 (100)| 00:00:58 |
|   9 |          INDEX FAST FULL SCAN    | T1_PK        |   108K|  2754K|       |    59   (2)| 00:00:01 |
|* 10 |          INDEX RANGE SCAN        | T1_LINES_PK  |  8233 |   313K|       |     2  (50)| 00:00:01 |
|  11 |     VIEW                         |              |   700 | 27300 |       |  3939   (1)| 00:00:32 |
|  12 |      SORT GROUP BY               |              |   700 | 40600 |       |  3939   (1)| 00:00:32 |
|* 13 |       TABLE ACCESS BY INDEX ROWID| T2_LINES     |   213 |  6816 |       |     6   (0)| 00:00:01 |
|  14 |        NESTED LOOPS              |              |   149K|  8456K|       |  3933   (1)| 00:00:32 |
|* 15 |         TABLE ACCESS FULL        | T2           |   700 | 18200 |       |     3  (34)| 00:00:01 |
|* 16 |         INDEX RANGE SCAN         | SYS_C0027538 |   321 |       |       |     2  (50)| 00:00:01 |
---------------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------
   2 - filter("E"."FCDUEDATE">COALESCE("CO"."DESIRED_SHIP_DATE",SYSDATE@!-365))
   3 - access("E"."CUSTPO"="CO"."CUSTOMER_PO_REF")
   5 - filter("EL"."RELID"=MAX("RELID"))
   7 - filter(SYSDATE@!-365<=SYSDATE@!+1200)
  10 - access("E"."CUSTPO"="EL"."CUSTPO" AND "EL"."FCDUEDATE">=SYSDATE@!-365 AND
              "EL"."FCSTQTY">0 AND "EL"."FCDUEDATE"<=SYSDATE@!+1200)
       filter(("EL"."FCDUEDATE">=SYSDATE@!-365 AND "EL"."FCDUEDATE"<=SYSDATE@!+1200 AND
              "EL"."FCSTQTY">0))
  13 - filter("COL"."DESIRED_SHIP_DATE">=SYSDATE@!-365)
  15 - filter("CUSTOMER_PO_REF" IS NOT NULL)
  16 - access("CO"."ID"="COL"."CUST_ORDER_ID") 

 

SQL_ID  4kkx042dnfuvf, child number 2
-------------------------------------
/* SQL Analyze(7,1) */ SELECT /*+ LEADING(E) */
COALESCE(CO.PART_ID,'NOT-IN-SYSTEM') PART_ID,   E.FCDUEDATE
REQUIRED_DATE,   SUM(E.FCSTQTY) QTY,   1 PLAN_LEVEL FROM   (SELECT /*+
LEADING(E) */     E.CUSTPO,     EL.FCSTQTY,     EL.FCDUEDATE   FROM
(SELECT /*+ _80 */       E.CUSTPO,       MAX(RELID) RELID     FROM
 T1 E     GROUP BY       E.CUSTPO) E,     T1_LINES EL   WHERE
E.CUSTPO=EL.CUSTPO     AND E.RELID=EL.RELID     AND EL.FCDUEDATE
BETWEEN SYSDATE-365 AND SYSDATE+1200     AND EL.FCSTQTY>0) E,   (SELECT
/*+  */     CO.CUSTOMER_PO_REF,     MAX(COL.DESIRED_SHIP_DATE)
DESIRED_SHIP_DATE,     MAX(COL.PART_ID) PART_ID   FROM     T2 CO,
T2_LINES COL   WHERE     CO.ID=COL.CUST_ORDER_ID     AND
CUSTOMER_PO_REF IS NOT NULL     AND COL.DESIRED_SHIP_DATE>=SYSDATE-365
 GROUP BY     CO.CUSTOMER_PO_REF) CO WHERE
E.CUSTPO=CO.CUSTOMER_PO_REF(+)   AND
E.FCDUEDATE>COALESCE(CO.DESIRED_SHIP_DATE,SYSDATE-365) GROUP BY
COALESCE(CO.PART_ID,'NOT-IN-SYSTEM'),   E.FCDUEDATE ORDER BY

Plan hash value: 4293267978

----------------------------------------------------------------------------------------------------
| Id  | Operation                    | Name        | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
----------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT             |             |       |       |       |  5083K(100)|          |
|   1 |  SORT GROUP BY               |             |   842 | 61466 |       |  5083K  (2)| 11:17:51 |
|*  2 |   FILTER                     |             |       |       |       |            |          |
|*  3 |    HASH JOIN OUTER           |             |   842 | 61466 |       |  5083K  (2)| 11:17:51 |
|   4 |     VIEW                     |             |   842 | 28628 |       |  5083K  (2)| 11:17:48 |
|*  5 |      FILTER                  |             |       |       |       |            |          |
|   6 |       SORT GROUP BY          |             |   842 | 54730 |    77G|  5083K  (2)| 11:17:48 |
|*  7 |        FILTER                |             |       |       |       |            |          |
|   8 |         NESTED LOOPS         |             |   893M|    54G|       |  7226 (100)| 00:00:58 |
|   9 |          INDEX FAST FULL SCAN| T1_PK       |   108K|  2754K|       |    60   (2)| 00:00:01 |
|* 10 |          INDEX RANGE SCAN    | T1_LINES_PK |  8233 |   313K|       |     2  (50)| 00:00:01 |
|  11 |     VIEW                     |             |   700 | 27300 |       |   369   (6)| 00:00:03 |
|  12 |      SORT GROUP BY           |             |   700 | 40600 |       |   369   (6)| 00:00:03 |
|* 13 |       HASH JOIN              |             |   149K|  8456K|       |   362   (4)| 00:00:03 |
|* 14 |        TABLE ACCESS FULL     | T2          |   700 | 18200 |       |     4  (25)| 00:00:01 |
|* 15 |        TABLE ACCESS FULL     | T2_LINES    |   149K|  4665K|       |   358   (4)| 00:00:03 |
----------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------
   2 - filter("E"."FCDUEDATE">COALESCE("CO"."DESIRED_SHIP_DATE",SYSDATE@!-365))
   3 - access("E"."CUSTPO"="CO"."CUSTOMER_PO_REF")
   5 - filter("EL"."RELID"=MAX("RELID"))
   7 - filter(SYSDATE@!-365<=SYSDATE@!+1200)
  10 - access("E"."CUSTPO"="EL"."CUSTPO" AND "EL"."FCDUEDATE">=SYSDATE@!-365 AND
              "EL"."FCSTQTY">0 AND "EL"."FCDUEDATE"<=SYSDATE@!+1200)
       filter(("EL"."FCDUEDATE">=SYSDATE@!-365 AND "EL"."FCDUEDATE"<=SYSDATE@!+1200 AND
              "EL"."FCSTQTY">0))
  13 - access("CO"."ID"="COL"."CUST_ORDER_ID")
  14 - filter("CUSTOMER_PO_REF" IS NOT NULL)
  15 - filter("COL"."DESIRED_SHIP_DATE">=SYSDATE@!-365) 

 

SQL_ID  4kkx042dnfuvf, child number 3
-------------------------------------
/* SQL Analyze(7,1) */ SELECT /*+ LEADING(E) */
COALESCE(CO.PART_ID,'NOT-IN-SYSTEM') PART_ID,   E.FCDUEDATE
REQUIRED_DATE,   SUM(E.FCSTQTY) QTY,   1 PLAN_LEVEL FROM   (SELECT /*+
LEADING(E) */     E.CUSTPO,     EL.FCSTQTY,     EL.FCDUEDATE   FROM
(SELECT /*+ _80 */       E.CUSTPO,       MAX(RELID) RELID     FROM
 T1 E     GROUP BY       E.CUSTPO) E,     T1_LINES EL   WHERE
E.CUSTPO=EL.CUSTPO     AND E.RELID=EL.RELID     AND EL.FCDUEDATE
BETWEEN SYSDATE-365 AND SYSDATE+1200     AND EL.FCSTQTY>0) E,   (SELECT
/*+  */     CO.CUSTOMER_PO_REF,     MAX(COL.DESIRED_SHIP_DATE)
DESIRED_SHIP_DATE,     MAX(COL.PART_ID) PART_ID   FROM     T2 CO,
T2_LINES COL   WHERE     CO.ID=COL.CUST_ORDER_ID     AND
CUSTOMER_PO_REF IS NOT NULL     AND COL.DESIRED_SHIP_DATE>=SYSDATE-365
 GROUP BY     CO.CUSTOMER_PO_REF) CO WHERE
E.CUSTPO=CO.CUSTOMER_PO_REF(+)   AND
E.FCDUEDATE>COALESCE(CO.DESIRED_SHIP_DATE,SYSDATE-365) GROUP BY
COALESCE(CO.PART_ID,'NOT-IN-SYSTEM'),   E.FCDUEDATE ORDER BY

Plan hash value: 3038192993

-------------------------------------------------------------------------------------------
| Id  | Operation                   | Name        | Rows  | Bytes | Cost (%CPU)| Time     |
-------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT            |             |       |       |   436 (100)|          |
|   1 |  SORT GROUP BY              |             |   486 | 47142 |   436   (7)| 00:00:04 |
|   2 |   NESTED LOOPS              |             |   994 | 96418 |   435   (6)| 00:00:04 |
|*  3 |    FILTER                   |             |       |       |            |          |
|*  4 |     HASH JOIN OUTER         |             |   700 | 42000 |   433   (6)| 00:00:04 |
|   5 |      VIEW                   |             |   700 | 14700 |    65  (10)| 00:00:01 |
|   6 |       SORT GROUP BY         |             |   700 | 18200 |    65  (10)| 00:00:01 |
|*  7 |        FILTER               |             |       |       |            |          |
|   8 |         INDEX FAST FULL SCAN| T1_PK       |   108K|  2754K|    60   (2)| 00:00:01 |
|   9 |      VIEW                   |             |   700 | 27300 |   368   (6)| 00:00:03 |
|  10 |       SORT GROUP BY         |             |   700 | 40600 |   368   (6)| 00:00:03 |
|* 11 |        HASH JOIN            |             |   149K|  8456K|   362   (4)| 00:00:03 |
|* 12 |         TABLE ACCESS FULL   | T2          |   700 | 18200 |     3   (0)| 00:00:01 |
|* 13 |         TABLE ACCESS FULL   | T2_LINES    |   149K|  4665K|   358   (4)| 00:00:03 |
|* 14 |    INDEX RANGE SCAN         | T1_LINES_PK |     1 |    37 |     1   (0)| 00:00:01 |
-------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------
   3 - filter(COALESCE("CO"."DESIRED_SHIP_DATE",SYSDATE@!-365)<SYSDATE@!+1200)
   4 - access("E"."CUSTPO"="CO"."CUSTOMER_PO_REF")
   7 - filter(SYSDATE@!-365<=SYSDATE@!+1200)
  11 - access("CO"."ID"="COL"."CUST_ORDER_ID")
  12 - filter("CUSTOMER_PO_REF" IS NOT NULL)
  13 - filter("COL"."DESIRED_SHIP_DATE">=SYSDATE@!-365)
  14 - access("E"."CUSTPO"="EL"."CUSTPO" AND "E"."RELID"="EL"."RELID" AND
              "EL"."FCDUEDATE">=SYSDATE@!-365 AND "EL"."FCSTQTY">0 AND
              "EL"."FCDUEDATE"<=SYSDATE@!+1200)
       filter(("EL"."FCSTQTY">0 AND "EL"."FCDUEDATE">COALESCE("CO"."DESIRED_SHIP_DA
              TE",SYSDATE@!-365))) 

 

SQL_ID  bqsrv9mngjdfu, child number 0
-------------------------------------
/* SQL Analyze(7,1) */ SELECT /*+ LEADING(E) */
COALESCE(CO.PART_ID,'NOT-IN-SYSTEM') PART_ID,   E.FCDUEDATE
REQUIRED_DATE,   SUM(E.FCSTQTY) QTY,   1 PLAN_LEVEL FROM   (SELECT /*+
LEADING(E) */     E.CUSTPO,     EL.FCSTQTY,     EL.FCDUEDATE   FROM
(SELECT /*+  */       E.CUSTPO,       MAX(RELID) RELID     FROM
T1 E     GROUP BY       E.CUSTPO) E,     T1_LINES EL   WHERE
E.CUSTPO=EL.CUSTPO     AND E.RELID=EL.RELID     AND EL.FCDUEDATE
BETWEEN SYSDATE-365 AND SYSDATE+1200     AND EL.FCSTQTY>0) E,   (SELECT
/*+  */     CO.CUSTOMER_PO_REF,     MAX(COL.DESIRED_SHIP_DATE)
DESIRED_SHIP_DATE,     MAX(COL.PART_ID) PART_ID   FROM     T2 CO,
T2_LINES COL   WHERE     CO.ID=COL.CUST_ORDER_ID     AND
CUSTOMER_PO_REF IS NOT NULL     AND COL.DESIRED_SHIP_DATE>=SYSDATE-365
 GROUP BY     CO.CUSTOMER_PO_REF) CO WHERE
E.CUSTPO=CO.CUSTOMER_PO_REF(+)   AND
E.FCDUEDATE>COALESCE(CO.DESIRED_SHIP_DATE,SYSDATE-365) GROUP BY
COALESCE(CO.PART_ID,'NOT-IN-SYSTEM'),   E.FCDUEDATE ORDER BY   CO

Plan hash value: 1522673873

-------------------------------------------------------------------------------------------
| Id  | Operation                   | Name        | Rows  | Bytes | Cost (%CPU)| Time     |
-------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT            |             |       |       |  1392 (100)|          |
|   1 |  SORT GROUP BY              |             |   829 | 80413 |  1392   (3)| 00:00:12 |
|*  2 |   FILTER                    |             |       |       |            |          |
|*  3 |    HASH JOIN RIGHT OUTER    |             | 19874 |  1882K|  1390   (2)| 00:00:12 |
|   4 |     VIEW                    |             |   700 | 27300 |   368   (6)| 00:00:03 |
|   5 |      HASH GROUP BY          |             |   700 | 40600 |   368   (6)| 00:00:03 |
|*  6 |       HASH JOIN             |             |   149K|  8456K|   362   (4)| 00:00:03 |
|*  7 |        TABLE ACCESS FULL    | T2          |   700 | 18200 |     3   (0)| 00:00:01 |
|*  8 |        TABLE ACCESS FULL    | T2_LINES    |   149K|  4665K|   358   (4)| 00:00:03 |
|   9 |     NESTED LOOPS            |             | 19874 |  1125K|  1022   (1)| 00:00:09 |
|  10 |      VIEW                   |             |   700 | 14700 |    65  (10)| 00:00:01 |
|  11 |       HASH GROUP BY         |             |   700 | 18200 |    65  (10)| 00:00:01 |
|* 12 |        FILTER               |             |       |       |            |          |
|  13 |         INDEX FAST FULL SCAN| T1_PK       |   108K|  2754K|    60   (2)| 00:00:01 |
|* 14 |      INDEX RANGE SCAN       | T1_LINES_PK |    28 |  1036 |     3   (0)| 00:00:01 |
-------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------
   2 - filter(("EL"."FCDUEDATE">COALESCE("CO"."DESIRED_SHIP_DATE",SYSDATE@!-365)
              AND COALESCE("CO"."DESIRED_SHIP_DATE",SYSDATE@!-365)<SYSDATE@!+1200))
   3 - access("E"."CUSTPO"="CO"."CUSTOMER_PO_REF")
   6 - access("CO"."ID"="COL"."CUST_ORDER_ID")
   7 - filter("CUSTOMER_PO_REF" IS NOT NULL)
   8 - filter("COL"."DESIRED_SHIP_DATE">=SYSDATE@!-365)
  12 - filter(SYSDATE@!-365<=SYSDATE@!+1200)
  14 - access("E"."CUSTPO"="EL"."CUSTPO" AND "E"."RELID"="EL"."RELID" AND
              "EL"."FCDUEDATE">=SYSDATE@!-365 AND "EL"."FCSTQTY">0 AND
              "EL"."FCDUEDATE"<=SYSDATE@!+1200)
       filter("EL"."FCSTQTY">0) 

 

SQL_ID  bqsrv9mngjdfu, child number 1
-------------------------------------
/* SQL Analyze(7,1) */ SELECT /*+ LEADING(E) */
COALESCE(CO.PART_ID,'NOT-IN-SYSTEM') PART_ID,   E.FCDUEDATE
REQUIRED_DATE,   SUM(E.FCSTQTY) QTY,   1 PLAN_LEVEL FROM   (SELECT /*+
LEADING(E) */     E.CUSTPO,     EL.FCSTQTY,     EL.FCDUEDATE   FROM
(SELECT /*+  */       E.CUSTPO,       MAX(RELID) RELID     FROM
T1 E     GROUP BY       E.CUSTPO) E,     T1_LINES EL   WHERE
E.CUSTPO=EL.CUSTPO     AND E.RELID=EL.RELID     AND EL.FCDUEDATE
BETWEEN SYSDATE-365 AND SYSDATE+1200     AND EL.FCSTQTY>0) E,   (SELECT
/*+  */     CO.CUSTOMER_PO_REF,     MAX(COL.DESIRED_SHIP_DATE)
DESIRED_SHIP_DATE,     MAX(COL.PART_ID) PART_ID   FROM     T2 CO,
T2_LINES COL   WHERE     CO.ID=COL.CUST_ORDER_ID     AND
CUSTOMER_PO_REF IS NOT NULL     AND COL.DESIRED_SHIP_DATE>=SYSDATE-365
 GROUP BY     CO.CUSTOMER_PO_REF) CO WHERE
E.CUSTPO=CO.CUSTOMER_PO_REF(+)   AND
E.FCDUEDATE>COALESCE(CO.DESIRED_SHIP_DATE,SYSDATE-365) GROUP BY
COALESCE(CO.PART_ID,'NOT-IN-SYSTEM'),   E.FCDUEDATE ORDER BY   CO

Plan hash value: 1232865634

---------------------------------------------------------------------------------------------------------
| Id  | Operation                        | Name         | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
---------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT                 |              |       |       |       |    16M(100)|          |
|   1 |  SORT GROUP BY                   |              |   842 | 61466 |       |    16M  (1)| 35:51:03 |
|*  2 |   FILTER                         |              |       |       |       |            |          |
|*  3 |    HASH JOIN OUTER               |              |   842 | 61466 |       |    16M  (1)| 35:51:03 |
|   4 |     VIEW                         |              |   842 | 28628 |       |    16M  (1)| 35:50:07 |
|*  5 |      FILTER                      |              |       |       |       |            |          |
|   6 |       SORT GROUP BY              |              |   842 | 54730 |    77G|    16M  (1)| 35:50:07 |
|*  7 |        FILTER                    |              |       |       |       |            |          |
|   8 |         NESTED LOOPS             |              |   893M|    54G|       |    11M  (1)| 24:33:17 |
|   9 |          INDEX FAST FULL SCAN    | T1_PK        |   108K|  2754K|       |    59   (2)| 00:00:01 |
|* 10 |          INDEX RANGE SCAN        | T1_LINES_PK  |  8233 |   313K|       |   104   (1)| 00:00:01 |
|  11 |     VIEW                         |              |   700 | 27300 |       |  7023   (1)| 00:00:57 |
|  12 |      SORT GROUP BY               |              |   700 | 40600 |       |  7023   (1)| 00:00:57 |
|* 13 |       TABLE ACCESS BY INDEX ROWID| T2_LINES     |   213 |  6816 |       |    11  (10)| 00:00:01 |
|  14 |        NESTED LOOPS              |              |   149K|  8456K|       |  7016   (1)| 00:00:57 |
|* 15 |         TABLE ACCESS FULL        | T2           |   700 | 18200 |       |     3  (34)| 00:00:01 |
|* 16 |         INDEX RANGE SCAN         | SYS_C0027538 |   321 |       |       |     4  (25)| 00:00:01 |
---------------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------
   2 - filter("E"."FCDUEDATE">COALESCE("CO"."DESIRED_SHIP_DATE",SYSDATE@!-365))
   3 - access("E"."CUSTPO"="CO"."CUSTOMER_PO_REF")
   5 - filter("EL"."RELID"=MAX("RELID"))
   7 - filter(SYSDATE@!-365<=SYSDATE@!+1200)
  10 - access("E"."CUSTPO"="EL"."CUSTPO" AND "EL"."FCDUEDATE">=SYSDATE@!-365 AND
              "EL"."FCSTQTY">0 AND "EL"."FCDUEDATE"<=SYSDATE@!+1200)
       filter(("EL"."FCDUEDATE">=SYSDATE@!-365 AND "EL"."FCDUEDATE"<=SYSDATE@!+1200 AND
              "EL"."FCSTQTY">0))
  13 - filter("COL"."DESIRED_SHIP_DATE">=SYSDATE@!-365)
  15 - filter("CUSTOMER_PO_REF" IS NOT NULL)
  16 - access("CO"."ID"="COL"."CUST_ORDER_ID") 

 

SQL_ID  bqsrv9mngjdfu, child number 2
-------------------------------------
/* SQL Analyze(7,1) */ SELECT /*+ LEADING(E) */
COALESCE(CO.PART_ID,'NOT-IN-SYSTEM') PART_ID,   E.FCDUEDATE
REQUIRED_DATE,   SUM(E.FCSTQTY) QTY,   1 PLAN_LEVEL FROM   (SELECT /*+
LEADING(E) */     E.CUSTPO,     EL.FCSTQTY,     EL.FCDUEDATE   FROM
(SELECT /*+  */       E.CUSTPO,       MAX(RELID) RELID     FROM
T1 E     GROUP BY       E.CUSTPO) E,     T1_LINES EL   WHERE
E.CUSTPO=EL.CUSTPO     AND E.RELID=EL.RELID     AND EL.FCDUEDATE
BETWEEN SYSDATE-365 AND SYSDATE+1200     AND EL.FCSTQTY>0) E,   (SELECT
/*+  */     CO.CUSTOMER_PO_REF,     MAX(COL.DESIRED_SHIP_DATE)
DESIRED_SHIP_DATE,     MAX(COL.PART_ID) PART_ID   FROM     T2 CO,
T2_LINES COL   WHERE     CO.ID=COL.CUST_ORDER_ID     AND
CUSTOMER_PO_REF IS NOT NULL     AND COL.DESIRED_SHIP_DATE>=SYSDATE-365
 GROUP BY     CO.CUSTOMER_PO_REF) CO WHERE
E.CUSTPO=CO.CUSTOMER_PO_REF(+)   AND
E.FCDUEDATE>COALESCE(CO.DESIRED_SHIP_DATE,SYSDATE-365) GROUP BY
COALESCE(CO.PART_ID,'NOT-IN-SYSTEM'),   E.FCDUEDATE ORDER BY   CO

Plan hash value: 3881822961

-------------------------------------------------------------------------------------------------
| Id  | Operation                    | Name     | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
-------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT             |          |       |       |       |  5083K(100)|          |
|   1 |  SORT GROUP BY               |          |   842 | 61466 |       |  5083K  (2)| 11:17:50 |
|*  2 |   FILTER                     |          |       |       |       |            |          |
|*  3 |    HASH JOIN OUTER           |          |   842 | 61466 |       |  5083K  (2)| 11:17:50 |
|   4 |     VIEW                     |          |   842 | 28628 |       |  5083K  (2)| 11:17:47 |
|*  5 |      FILTER                  |          |       |       |       |            |          |
|   6 |       SORT GROUP BY          |          |   842 | 54730 |    77G|  5083K  (2)| 11:17:47 |
|*  7 |        FILTER                |          |       |       |       |            |          |
|*  8 |         HASH JOIN            |          |   893M|    54G|  4032K|  7033   (9)| 00:00:57 |
|   9 |          INDEX FAST FULL SCAN| T1_PK    |   108K|  2754K|       |    60   (2)| 00:00:01 |
|* 10 |          TABLE ACCESS FULL   | T1_LINES |  5763K|   214M|       |  3389  (16)| 00:00:28 |
|  11 |     VIEW                     |          |   700 | 27300 |       |   369   (6)| 00:00:03 |
|  12 |      SORT GROUP BY           |          |   700 | 40600 |       |   369   (6)| 00:00:03 |
|* 13 |       HASH JOIN              |          |   149K|  8456K|       |   362   (4)| 00:00:03 |
|* 14 |        TABLE ACCESS FULL     | T2       |   700 | 18200 |       |     4  (25)| 00:00:01 |
|* 15 |        TABLE ACCESS FULL     | T2_LINES |   149K|  4665K|       |   358   (4)| 00:00:03 |
-------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------
   2 - filter("E"."FCDUEDATE">COALESCE("CO"."DESIRED_SHIP_DATE",SYSDATE@!-365))
   3 - access("E"."CUSTPO"="CO"."CUSTOMER_PO_REF")
   5 - filter("EL"."RELID"=MAX("RELID"))
   7 - filter(SYSDATE@!-365<=SYSDATE@!+1200)
   8 - access("E"."CUSTPO"="EL"."CUSTPO")
  10 - filter(("EL"."FCDUEDATE">=SYSDATE@!-365 AND "EL"."FCDUEDATE"<=SYSDATE@!+1200 AND
              "EL"."FCSTQTY">0))
  13 - access("CO"."ID"="COL"."CUST_ORDER_ID")
  14 - filter("CUSTOMER_PO_REF" IS NOT NULL)
  15 - filter("COL"."DESIRED_SHIP_DATE">=SYSDATE@!-365) 

 

SQL_ID  bqsrv9mngjdfu, child number 3
-------------------------------------
/* SQL Analyze(7,1) */ SELECT /*+ LEADING(E) */
COALESCE(CO.PART_ID,'NOT-IN-SYSTEM') PART_ID,   E.FCDUEDATE
REQUIRED_DATE,   SUM(E.FCSTQTY) QTY,   1 PLAN_LEVEL FROM   (SELECT /*+
LEADING(E) */     E.CUSTPO,     EL.FCSTQTY,     EL.FCDUEDATE   FROM
(SELECT /*+  */       E.CUSTPO,       MAX(RELID) RELID     FROM
T1 E     GROUP BY       E.CUSTPO) E,     T1_LINES EL   WHERE
E.CUSTPO=EL.CUSTPO     AND E.RELID=EL.RELID     AND EL.FCDUEDATE
BETWEEN SYSDATE-365 AND SYSDATE+1200     AND EL.FCSTQTY>0) E,   (SELECT
/*+  */     CO.CUSTOMER_PO_REF,     MAX(COL.DESIRED_SHIP_DATE)
DESIRED_SHIP_DATE,     MAX(COL.PART_ID) PART_ID   FROM     T2 CO,
T2_LINES COL   WHERE     CO.ID=COL.CUST_ORDER_ID     AND
CUSTOMER_PO_REF IS NOT NULL     AND COL.DESIRED_SHIP_DATE>=SYSDATE-365
 GROUP BY     CO.CUSTOMER_PO_REF) CO WHERE
E.CUSTPO=CO.CUSTOMER_PO_REF(+)   AND
E.FCDUEDATE>COALESCE(CO.DESIRED_SHIP_DATE,SYSDATE-365) GROUP BY
COALESCE(CO.PART_ID,'NOT-IN-SYSTEM'),   E.FCDUEDATE ORDER BY   CO

Plan hash value: 4176222027

-------------------------------------------------------------------------------------------
| Id  | Operation                   | Name        | Rows  | Bytes | Cost (%CPU)| Time     |
-------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT            |             |       |       |  1425 (100)|          |
|   1 |  SORT GROUP BY              |             |   486 | 47142 |  1425   (2)| 00:00:12 |
|*  2 |   FILTER                    |             |       |       |            |          |
|*  3 |    HASH JOIN RIGHT OUTER    |             | 19874 |  1882K|  1423   (2)| 00:00:12 |
|   4 |     VIEW                    |             |   700 | 27300 |   368   (6)| 00:00:03 |
|   5 |      SORT GROUP BY          |             |   700 | 40600 |   368   (6)| 00:00:03 |
|*  6 |       HASH JOIN             |             |   149K|  8456K|   362   (4)| 00:00:03 |
|*  7 |        TABLE ACCESS FULL    | T2          |   700 | 18200 |     3   (0)| 00:00:01 |
|*  8 |        TABLE ACCESS FULL    | T2_LINES    |   149K|  4665K|   358   (4)| 00:00:03 |
|   9 |     NESTED LOOPS            |             | 19874 |  1125K|  1055   (1)| 00:00:09 |
|  10 |      VIEW                   |             |   700 | 14700 |    65  (10)| 00:00:01 |
|  11 |       SORT GROUP BY         |             |   700 | 18200 |    65  (10)| 00:00:01 |
|* 12 |        FILTER               |             |       |       |            |          |
|  13 |         INDEX FAST FULL SCAN| T1_PK       |   108K|  2754K|    60   (2)| 00:00:01 |
|* 14 |      INDEX RANGE SCAN       | T1_LINES_PK |    28 |  1036 |     3   (0)| 00:00:01 |
-------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------
   2 - filter(("EL"."FCDUEDATE">COALESCE("CO"."DESIRED_SHIP_DATE",SYSDATE@!-365)
              AND COALESCE("CO"."DESIRED_SHIP_DATE",SYSDATE@!-365)<SYSDATE@!+1200))
   3 - access("E"."CUSTPO"="CO"."CUSTOMER_PO_REF")
   6 - access("CO"."ID"="COL"."CUST_ORDER_ID")
   7 - filter("CUSTOMER_PO_REF" IS NOT NULL)
   8 - filter("COL"."DESIRED_SHIP_DATE">=SYSDATE@!-365)
  12 - filter(SYSDATE@!-365<=SYSDATE@!+1200)
  14 - access("E"."CUSTPO"="EL"."CUSTPO" AND "E"."RELID"="EL"."RELID" AND
              "EL"."FCDUEDATE">=SYSDATE@!-365 AND "EL"."FCSTQTY">0 AND
              "EL"."FCDUEDATE"<=SYSDATE@!+1200)
       filter("EL"."FCSTQTY">0) 

 

SQL_ID  bqsrv9mngjdfu, child number 4
-------------------------------------
/* SQL Analyze(7,1) */ SELECT /*+ LEADING(E) */
COALESCE(CO.PART_ID,'NOT-IN-SYSTEM') PART_ID,   E.FCDUEDATE
REQUIRED_DATE,   SUM(E.FCSTQTY) QTY,   1 PLAN_LEVEL FROM   (SELECT /*+
LEADING(E) */     E.CUSTPO,     EL.FCSTQTY,     EL.FCDUEDATE   FROM
(SELECT /*+  */       E.CUSTPO,       MAX(RELID) RELID     FROM
T1 E     GROUP BY       E.CUSTPO) E,     T1_LINES EL   WHERE
E.CUSTPO=EL.CUSTPO     AND E.RELID=EL.RELID     AND EL.FCDUEDATE
BETWEEN SYSDATE-365 AND SYSDATE+1200     AND EL.FCSTQTY>0) E,   (SELECT
/*+  */     CO.CUSTOMER_PO_REF,     MAX(COL.DESIRED_SHIP_DATE)
DESIRED_SHIP_DATE,     MAX(COL.PART_ID) PART_ID   FROM     T2 CO,
T2_LINES COL   WHERE     CO.ID=COL.CUST_ORDER_ID     AND
CUSTOMER_PO_REF IS NOT NULL     AND COL.DESIRED_SHIP_DATE>=SYSDATE-365
 GROUP BY     CO.CUSTOMER_PO_REF) CO WHERE
E.CUSTPO=CO.CUSTOMER_PO_REF(+)   AND
E.FCDUEDATE>COALESCE(CO.DESIRED_SHIP_DATE,SYSDATE-365) GROUP BY
COALESCE(CO.PART_ID,'NOT-IN-SYSTEM'),   E.FCDUEDATE ORDER BY   CO

Plan hash value: 1232865634

---------------------------------------------------------------------------------------------------------
| Id  | Operation                        | Name         | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
---------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT                 |              |       |       |       |    16M(100)|          |
|   1 |  SORT GROUP BY                   |              |   842 | 61466 |       |    16M  (1)| 35:51:03 |
|*  2 |   FILTER                         |              |       |       |       |            |          |
|*  3 |    HASH JOIN OUTER               |              |   842 | 61466 |       |    16M  (1)| 35:51:03 |
|   4 |     VIEW                         |              |   842 | 28628 |       |    16M  (1)| 35:50:07 |
|*  5 |      FILTER                      |              |       |       |       |            |          |
|   6 |       SORT GROUP BY              |              |   842 | 54730 |    77G|    16M  (1)| 35:50:07 |
|*  7 |        FILTER                    |              |       |       |       |            |          |
|   8 |         NESTED LOOPS             |              |   893M|    54G|       |    11M  (1)| 24:33:17 |
|   9 |          INDEX FAST FULL SCAN    | T1_PK        |   108K|  2754K|       |    59   (2)| 00:00:01 |
|* 10 |          INDEX RANGE SCAN        | T1_LINES_PK  |  8233 |   313K|       |   104   (1)| 00:00:01 |
|  11 |     VIEW                         |              |   700 | 27300 |       |  7023   (1)| 00:00:57 |
|  12 |      SORT GROUP BY               |              |   700 | 40600 |       |  7023   (1)| 00:00:57 |
|* 13 |       TABLE ACCESS BY INDEX ROWID| T2_LINES     |   213 |  6816 |       |    11  (10)| 00:00:01 |
|  14 |        NESTED LOOPS              |              |   149K|  8456K|       |  7016   (1)| 00:00:57 |
|* 15 |         TABLE ACCESS FULL        | T2           |   700 | 18200 |       |     3  (34)| 00:00:01 |
|* 16 |         INDEX RANGE SCAN         | SYS_C0027538 |   321 |       |       |     4  (25)| 00:00:01 |
---------------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------
   2 - filter("E"."FCDUEDATE">COALESCE("CO"."DESIRED_SHIP_DATE",SYSDATE@!-365))
   3 - access("E"."CUSTPO"="CO"."CUSTOMER_PO_REF")
   5 - filter("EL"."RELID"=MAX("RELID"))
   7 - filter(SYSDATE@!-365<=SYSDATE@!+1200)
  10 - access("E"."CUSTPO"="EL"."CUSTPO" AND "EL"."FCDUEDATE">=SYSDATE@!-365 AND
              "EL"."FCSTQTY">0 AND "EL"."FCDUEDATE"<=SYSDATE@!+1200)
       filter(("EL"."FCDUEDATE">=SYSDATE@!-365 AND "EL"."FCDUEDATE"<=SYSDATE@!+1200 AND
              "EL"."FCSTQTY">0))
  13 - filter("COL"."DESIRED_SHIP_DATE">=SYSDATE@!-365)
  15 - filter("CUSTOMER_PO_REF" IS NOT NULL)
  16 - access("CO"."ID"="COL"."CUST_ORDER_ID") 

 SQL_ID  bqsrv9mngjdfu, child number 5
-------------------------------------
/* SQL Analyze(7,1) */ SELECT /*+ LEADING(E) */
COALESCE(CO.PART_ID,'NOT-IN-SYSTEM') PART_ID,   E.FCDUEDATE
REQUIRED_DATE,   SUM(E.FCSTQTY) QTY,   1 PLAN_LEVEL FROM   (SELECT /*+
LEADING(E) */     E.CUSTPO,     EL.FCSTQTY,     EL.FCDUEDATE   FROM
(SELECT /*+  */       E.CUSTPO,       MAX(RELID) RELID     FROM
T1 E     GROUP BY       E.CUSTPO) E,     T1_LINES EL   WHERE
E.CUSTPO=EL.CUSTPO     AND E.RELID=EL.RELID     AND EL.FCDUEDATE
BETWEEN SYSDATE-365 AND SYSDATE+1200     AND EL.FCSTQTY>0) E,   (SELECT
/*+  */     CO.CUSTOMER_PO_REF,     MAX(COL.DESIRED_SHIP_DATE)
DESIRED_SHIP_DATE,     MAX(COL.PART_ID) PART_ID   FROM     T2 CO,
T2_LINES COL   WHERE     CO.ID=COL.CUST_ORDER_ID     AND
CUSTOMER_PO_REF IS NOT NULL     AND COL.DESIRED_SHIP_DATE>=SYSDATE-365
 GROUP BY     CO.CUSTOMER_PO_REF) CO WHERE
E.CUSTPO=CO.CUSTOMER_PO_REF(+)   AND
E.FCDUEDATE>COALESCE(CO.DESIRED_SHIP_DATE,SYSDATE-365) GROUP BY
COALESCE(CO.PART_ID,'NOT-IN-SYSTEM'),   E.FCDUEDATE ORDER BY   CO

Plan hash value: 3881822961

-------------------------------------------------------------------------------------------------
| Id  | Operation                    | Name     | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
-------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT             |          |       |       |       |  5083K(100)|          |
|   1 |  SORT GROUP BY               |          |   842 | 61466 |       |  5083K  (2)| 11:17:50 |
|*  2 |   FILTER                     |          |       |       |       |            |          |
|*  3 |    HASH JOIN OUTER           |          |   842 | 61466 |       |  5083K  (2)| 11:17:50 |
|   4 |     VIEW                     |          |   842 | 28628 |       |  5083K  (2)| 11:17:47 |
|*  5 |      FILTER                  |          |       |       |       |            |          |
|   6 |       SORT GROUP BY          |          |   842 | 54730 |    77G|  5083K  (2)| 11:17:47 |
|*  7 |        FILTER                |          |       |       |       |            |          |
|*  8 |         HASH JOIN            |          |   893M|    54G|  4032K|  7033   (9)| 00:00:57 |
|   9 |          INDEX FAST FULL SCAN| T1_PK    |   108K|  2754K|       |    60   (2)| 00:00:01 |
|* 10 |          TABLE ACCESS FULL   | T1_LINES |  5763K|   214M|       |  3389  (16)| 00:00:28 |
|  11 |     VIEW                     |          |   700 | 27300 |       |   369   (6)| 00:00:03 |
|  12 |      SORT GROUP BY           |          |   700 | 40600 |       |   369   (6)| 00:00:03 |
|* 13 |       HASH JOIN              |          |   149K|  8456K|       |   362   (4)| 00:00:03 |
|* 14 |        TABLE ACCESS FULL     | T2       |   700 | 18200 |       |     4  (25)| 00:00:01 |
|* 15 |        TABLE ACCESS FULL     | T2_LINES |   149K|  4665K|       |   358   (4)| 00:00:03 |
-------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------
   2 - filter("E"."FCDUEDATE">COALESCE("CO"."DESIRED_SHIP_DATE",SYSDATE@!-365))
   3 - access("E"."CUSTPO"="CO"."CUSTOMER_PO_REF")
   5 - filter("EL"."RELID"=MAX("RELID"))
   7 - filter(SYSDATE@!-365<=SYSDATE@!+1200)
   8 - access("E"."CUSTPO"="EL"."CUSTPO")
  10 - filter(("EL"."FCDUEDATE">=SYSDATE@!-365 AND "EL"."FCDUEDATE"<=SYSDATE@!+1200 AND
              "EL"."FCSTQTY">0))
  13 - access("CO"."ID"="COL"."CUST_ORDER_ID")
  14 - filter("CUSTOMER_PO_REF" IS NOT NULL)
  15 - filter("COL"."DESIRED_SHIP_DATE">=SYSDATE@!-365) 

Assume that the second script produced the following (the blue text is directly related to the SQL statements that were executed by the script):

SQL_ID        CHILD_NUMBER NAME                                     VALUE
------------- ------------ ---------------------------------------- -------------------------
33n2n2z5a330f            0 _pga_max_size                            409600 KB
33n2n2z5a330f            0 optimizer_features_enable                10.1.0.4
-
33n2n2z5a330f            1 _pga_max_size                            409600 KB
33n2n2z5a330f            1 optimizer_features_enable                10.2.0.2
-
33n2n2z5a330f            2 _pga_max_size                            409600 KB
33n2n2z5a330f            2 optimizer_features_enable                11.1.0.7
-
33n2n2z5a330f            3 _pga_max_size                            409600 KB
------------------------------------------------------------------------------
4kkx042dnfuvf            0 _pga_max_size                            409600 KB
4kkx042dnfuvf            0 is_recur_flags                           72
4kkx042dnfuvf            0 optimizer_features_hinted                11.2.0.1
4kkx042dnfuvf            0 optimizer_index_caching                  100
4kkx042dnfuvf            0 optimizer_index_cost_adj                 80
4kkx042dnfuvf            0 optimizer_mode_hinted                    true
-
4kkx042dnfuvf            1 _pga_max_size                            409600 KB
4kkx042dnfuvf            1 is_recur_flags                           72
4kkx042dnfuvf            1 optimizer_dynamic_sampling               0
4kkx042dnfuvf            1 optimizer_features_hinted                9.0.0
4kkx042dnfuvf            1 optimizer_index_caching                  100
4kkx042dnfuvf            1 optimizer_index_cost_adj                 80
4kkx042dnfuvf            1 optimizer_mode_hinted                    true
4kkx042dnfuvf            1 query_rewrite_enabled                    false
4kkx042dnfuvf            1 skip_unusable_indexes                    false
-
4kkx042dnfuvf            2 _pga_max_size                            409600 KB
4kkx042dnfuvf            2 is_recur_flags                           72
4kkx042dnfuvf            2 optimizer_dynamic_sampling               1
4kkx042dnfuvf            2 optimizer_features_hinted                9.2.0.8
4kkx042dnfuvf            2 optimizer_index_caching                  100
4kkx042dnfuvf            2 optimizer_index_cost_adj                 80
4kkx042dnfuvf            2 optimizer_mode_hinted                    true
4kkx042dnfuvf            2 query_rewrite_enabled                    false
4kkx042dnfuvf            2 skip_unusable_indexes                    false
-
4kkx042dnfuvf            3 _pga_max_size                            409600 KB
4kkx042dnfuvf            3 is_recur_flags                           72
4kkx042dnfuvf            3 optimizer_features_hinted                10.1.0.5
4kkx042dnfuvf            3 optimizer_index_caching                  100
4kkx042dnfuvf            3 optimizer_index_cost_adj                 80
4kkx042dnfuvf            3 optimizer_mode_hinted                    true
------------------------------------------------------------------------------
bqsrv9mngjdfu            0 _pga_max_size                            409600 KB
bqsrv9mngjdfu            0 is_recur_flags                           72
bqsrv9mngjdfu            0 optimizer_features_hinted                11.2.0.1
bqsrv9mngjdfu            0 optimizer_mode_hinted                    true
-
bqsrv9mngjdfu            1 _pga_max_size                            409600 KB
bqsrv9mngjdfu            1 is_recur_flags                           72
bqsrv9mngjdfu            1 optimizer_dynamic_sampling               0
bqsrv9mngjdfu            1 optimizer_features_hinted                9.0.0
bqsrv9mngjdfu            1 optimizer_mode_hinted                    true
bqsrv9mngjdfu            1 query_rewrite_enabled                    false
bqsrv9mngjdfu            1 skip_unusable_indexes                    false
-
bqsrv9mngjdfu            2 _pga_max_size                            409600 KB
bqsrv9mngjdfu            2 is_recur_flags                           72
bqsrv9mngjdfu            2 optimizer_dynamic_sampling               1
bqsrv9mngjdfu            2 optimizer_features_hinted                9.2.0.8
bqsrv9mngjdfu            2 optimizer_mode_hinted                    true
bqsrv9mngjdfu            2 query_rewrite_enabled                    false
bqsrv9mngjdfu            2 skip_unusable_indexes                    false
-
bqsrv9mngjdfu            3 _pga_max_size                            409600 KB
bqsrv9mngjdfu            3 is_recur_flags                           72
bqsrv9mngjdfu            3 optimizer_features_hinted                10.1.0.5
bqsrv9mngjdfu            3 optimizer_mode_hinted                    true
-
bqsrv9mngjdfu            4 _pga_max_size                            409600 KB
bqsrv9mngjdfu            4 is_recur_flags                           72
bqsrv9mngjdfu            4 optimizer_dynamic_sampling               0
bqsrv9mngjdfu            4 optimizer_features_hinted                9.0.0
bqsrv9mngjdfu            4 optimizer_mode_hinted                    true
bqsrv9mngjdfu            4 query_rewrite_enabled                    false
bqsrv9mngjdfu            4 skip_unusable_indexes                    false
-
bqsrv9mngjdfu            5 _pga_max_size                            409600 KB
bqsrv9mngjdfu            5 is_recur_flags                           72
bqsrv9mngjdfu            5 optimizer_dynamic_sampling               1
bqsrv9mngjdfu            5 optimizer_features_hinted                9.2.0.8
bqsrv9mngjdfu            5 optimizer_mode_hinted                    true
bqsrv9mngjdfu            5 query_rewrite_enabled                    false
bqsrv9mngjdfu            5 skip_unusable_indexes                    false
------------------------------------------------------------------------------
gfb3g0axbj17z            0 _pga_max_size                            409600 KB
gfb3g0axbj17z            0 optimizer_features_enable                10.1.0.4
gfb3g0axbj17z            0 optimizer_index_caching                  100
gfb3g0axbj17z            0 optimizer_index_cost_adj                 80
-
gfb3g0axbj17z            1 _pga_max_size                            409600 KB
gfb3g0axbj17z            1 optimizer_features_enable                10.2.0.2
gfb3g0axbj17z            1 optimizer_index_caching                  100
gfb3g0axbj17z            1 optimizer_index_cost_adj                 80
-
gfb3g0axbj17z            2 _pga_max_size                            409600 KB
gfb3g0axbj17z            2 optimizer_features_enable                11.1.0.7
gfb3g0axbj17z            2 optimizer_index_caching                  100
gfb3g0axbj17z            2 optimizer_index_cost_adj                 80
-
gfb3g0axbj17z            3 _pga_max_size                            409600 KB
gfb3g0axbj17z            3 optimizer_index_caching                  100
gfb3g0axbj17z            3 optimizer_index_cost_adj                 80  

—————————————————————————————————————————–
—————————————————————————————————————————–

Just to put a slightly different spin on the test results, I repeated the test case on Oracle Database 10.2.0.5 Standard Edition (also Enterprise Edition) with an 8,000M SGA_TARGET and 1,800M PGA_AGGREGATE_TARGET.  The results?

SELECT_10.1.0.4 (OPTIMIZER_FEATURES_ENABLE=’10.1.0.4′, OPTIMIZER_INDEX_CACHING=0, OPTIMIZER_INDEX_COST_ADJ=100), completed in 0.34 seconds when selecting 10,478 rows (same execution plan for OPTIMIZER_FEATURES_ENABLE=’10.2.0.2′):

--------------------------------------------------+-----------------------------------+
| Id  | Operation                    | Name       | Rows  | Bytes | Cost  | Time      |
--------------------------------------------------+-----------------------------------+
| 0   | SELECT STATEMENT             |            |       |       |  1368 |           |
| 1   |  SORT GROUP BY               |            |   489 |   46K |  1368 |  00:00:11 |
| 2   |   FILTER                     |            |       |       |       |           |
| 3   |    HASH JOIN RIGHT OUTER     |            |   20K | 1906K |  1367 |  00:00:11 |
| 4   |     VIEW                     |            |   700 |   27K |   375 |  00:00:03 |
| 5   |      SORT GROUP BY           |            |   700 |   40K |   375 |  00:00:03 |
| 6   |       HASH JOIN              |            |  146K | 8454K |   368 |  00:00:03 |
| 7   |        TABLE ACCESS FULL     | T2         |   700 |   18K |     3 |  00:00:01 |
| 8   |        TABLE ACCESS FULL     | T2_LINES   |  146K | 4664K |   364 |  00:00:03 |
| 9   |     NESTED LOOPS             |            |   20K | 1140K |   992 |  00:00:08 |
| 10  |      VIEW                    |            |   671 |   14K |    65 |  00:00:01 |
| 11  |       SORT GROUP BY          |            |   671 |   17K |    65 |  00:00:01 |
| 12  |        FILTER                |            |       |       |       |           |
| 13  |         INDEX FAST FULL SCAN | T1_PK      |  107K | 2773K |    60 |  00:00:01 |
| 14  |      INDEX RANGE SCAN        | T1_LINES_PK|    30 |  1110 |     3 |  00:00:01 |
--------------------------------------------------+-----------------------------------+
Predicate Information:
----------------------
2 - filter(("EL"."FCDUEDATE">COALESCE("CO"."DESIRED_SHIP_DATE",SYSDATE@!-365) AND COALESCE("CO"."DESIRED_SHIP_DATE",SYSDATE@!-365)<SYSDATE@!+1200))
3 - access("E"."CUSTPO"="CO"."CUSTOMER_PO_REF")
6 - access("CO"."ID"="COL"."CUST_ORDER_ID")
7 - filter("CUSTOMER_PO_REF" IS NOT NULL)
8 - filter("COL"."DESIRED_SHIP_DATE">=SYSDATE@!-365)
12 - filter(SYSDATE@!-365<=SYSDATE@!+1200)
14 - access("E"."CUSTPO"="EL"."CUSTPO" AND "E"."RELID"="EL"."RELID" AND "EL"."FCDUEDATE">=SYSDATE@!-365 AND "EL"."FCSTQTY">0 AND "EL"."FCDUEDATE"<=SYSDATE@!+1200)
14 - filter("EL"."FCSTQTY">0)

Statistics
----------------------------------------------------------                     
       1434  recursive calls                                                   
          0  db block gets                                                     
       7818  consistent gets                                                   
          0  physical reads                                                    
          0  redo size                                                         
     104015  bytes sent via SQL*Net to client                                  
        549  bytes received via SQL*Net from client                            
          9  SQL*Net roundtrips to/from client                                 
         36  sorts (memory)                                                    
          0  sorts (disk)                                                      
       7604  rows processed

INSERT_10.1.0.4 (OPTIMIZER_FEATURES_ENABLE=’10.1.0.4′, OPTIMIZER_INDEX_CACHING=0, OPTIMIZER_INDEX_COST_ADJ=100), completed in… 0.34 seconds when inserting 10,478 rows (same execution plan for OPTIMIZER_FEATURES_ENABLE=’10.2.0.2′):

--------------------------------------------------+-----------------------------------+
| Id  | Operation                    | Name       | Rows  | Bytes | Cost  | Time      |
--------------------------------------------------+-----------------------------------+
| 0   | INSERT STATEMENT             |            |       |       |  1368 |           |
| 1   |  SORT GROUP BY               |            |   489 |   46K |  1368 |  00:00:11 |
| 2   |   FILTER                     |            |       |       |       |           |
| 3   |    HASH JOIN RIGHT OUTER     |            |   20K | 1906K |  1367 |  00:00:11 |
| 4   |     VIEW                     |            |   700 |   27K |   375 |  00:00:03 |
| 5   |      SORT GROUP BY           |            |   700 |   40K |   375 |  00:00:03 |
| 6   |       HASH JOIN              |            |  146K | 8454K |   368 |  00:00:03 |
| 7   |        TABLE ACCESS FULL     | T2         |   700 |   18K |     3 |  00:00:01 |
| 8   |        TABLE ACCESS FULL     | T2_LINES   |  146K | 4664K |   364 |  00:00:03 |
| 9   |     NESTED LOOPS             |            |   20K | 1140K |   992 |  00:00:08 |
| 10  |      VIEW                    |            |   671 |   14K |    65 |  00:00:01 |
| 11  |       SORT GROUP BY          |            |   671 |   17K |    65 |  00:00:01 |
| 12  |        FILTER                |            |       |       |       |           |
| 13  |         INDEX FAST FULL SCAN | T1_PK      |  107K | 2773K |    60 |  00:00:01 |
| 14  |      INDEX RANGE SCAN        | T1_LINES_PK|    30 |  1110 |     3 |  00:00:01 |
--------------------------------------------------+-----------------------------------+
Predicate Information:
----------------------
2 - filter(("EL"."FCDUEDATE">COALESCE("CO"."DESIRED_SHIP_DATE",SYSDATE@!-365) AND COALESCE("CO"."DESIRED_SHIP_DATE",SYSDATE@!-365)<SYSDATE@!+1200))
3 - access("E"."CUSTPO"="CO"."CUSTOMER_PO_REF")
6 - access("CO"."ID"="COL"."CUST_ORDER_ID")
7 - filter("CUSTOMER_PO_REF" IS NOT NULL)
8 - filter("COL"."DESIRED_SHIP_DATE">=SYSDATE@!-365)
12 - filter(SYSDATE@!-365<=SYSDATE@!+1200)
14 - access("E"."CUSTPO"="EL"."CUSTPO" AND "E"."RELID"="EL"."RELID" AND "EL"."FCDUEDATE">=SYSDATE@!-365 AND "EL"."FCSTQTY">0 AND "EL"."FCDUEDATE"<=SYSDATE@!+1200)
14 - filter("EL"."FCSTQTY">0)

Statistics
----------------------------------------------------------                     
       1350  recursive calls                                                   
        468  db block gets                                                     
       7981  consistent gets                                                   
          0  physical reads                                                    
     293716  redo size                                                         
        817  bytes sent via SQL*Net to client                                  
       1709  bytes received via SQL*Net from client                            
          3  SQL*Net roundtrips to/from client                                 
         21  sorts (memory)                                                    
          0  sorts (disk)                                                      
       7604  rows processed

Notice in the above that the execution plan is the same for both the SELECT and INSERT INTO SQL statements, unlike what happened in Oracle Database 11.2.0.1 with the same OPTIMIZER_FEATURES_ENABLE setting.

————

SELECT_10.1.0.4 (OPTIMIZER_FEATURES_ENABLE=’10.1.0.4′, OPTIMIZER_INDEX_CACHING=100, OPTIMIZER_INDEX_COST_ADJ=80), completed in 0.34 seconds when selecting 10,478 rows (same execution plan for OPTIMIZER_FEATURES_ENABLE=’10.2.0.2′):

--------------------------------------------------+-----------------------------------+
| Id  | Operation                    | Name       | Rows  | Bytes | Cost  | Time      |
--------------------------------------------------+-----------------------------------+
| 0   | SELECT STATEMENT             |            |       |       |   442 |           |
| 1   |  SORT GROUP BY               |            |   489 |   46K |   442 |  00:00:04 |
| 2   |   NESTED LOOPS               |            |  1006 |   95K |   441 |  00:00:04 |
| 3   |    FILTER                    |            |       |       |       |           |
| 4   |     HASH JOIN OUTER          |            |   671 |   39K |   440 |  00:00:04 |
| 5   |      VIEW                    |            |   671 |   14K |    65 |  00:00:01 |
| 6   |       SORT GROUP BY          |            |   671 |   17K |    65 |  00:00:01 |
| 7   |        FILTER                |            |       |       |       |           |
| 8   |         INDEX FAST FULL SCAN | T1_PK      |  107K | 2773K |    60 |  00:00:01 |
| 9   |      VIEW                    |            |   700 |   27K |   375 |  00:00:03 |
| 10  |       SORT GROUP BY          |            |   700 |   40K |   375 |  00:00:03 |
| 11  |        HASH JOIN             |            |  146K | 8454K |   368 |  00:00:03 |
| 12  |         TABLE ACCESS FULL    | T2         |   700 |   18K |     3 |  00:00:01 |
| 13  |         TABLE ACCESS FULL    | T2_LINES   |  146K | 4664K |   364 |  00:00:03 |
| 14  |    INDEX RANGE SCAN          | T1_LINES_PK|     1 |    37 |     1 |  00:00:01 |
--------------------------------------------------+-----------------------------------+
Predicate Information:
----------------------
3 - filter(COALESCE("CO"."DESIRED_SHIP_DATE",SYSDATE@!-365)<SYSDATE@!+1200)
4 - access("E"."CUSTPO"="CO"."CUSTOMER_PO_REF")
7 - filter(SYSDATE@!-365<=SYSDATE@!+1200)
11 - access("CO"."ID"="COL"."CUST_ORDER_ID")
12 - filter("CUSTOMER_PO_REF" IS NOT NULL)
13 - filter("COL"."DESIRED_SHIP_DATE">=SYSDATE@!-365)
14 - access("E"."CUSTPO"="EL"."CUSTPO" AND "E"."RELID"="EL"."RELID" AND "EL"."FCDUEDATE">COALESCE("CO"."DESIRED_SHIP_DATE",SYSDATE@!-365) AND "EL"."FCSTQTY">0 AND "EL"."FCDUEDATE"<=SYSDATE@!+1200)
14 - filter(("EL"."FCDUEDATE">=SYSDATE@!-365 AND "EL"."FCSTQTY">0))

Statistics
----------------------------------------------------------                     
          1  recursive calls                                                   
          0  db block gets                                                     
       7508  consistent gets                                                   
          0  physical reads                                                    
          0  redo size                                                         
     104015  bytes sent via SQL*Net to client                                  
        549  bytes received via SQL*Net from client                            
          9  SQL*Net roundtrips to/from client                                 
          3  sorts (memory)                                                    
          0  sorts (disk)                                                      
       7604  rows processed

INSERT_10.1.0.4 (OPTIMIZER_FEATURES_ENABLE=’10.1.0.4′, OPTIMIZER_INDEX_CACHING=0, OPTIMIZER_INDEX_COST_ADJ=100), completed in… 0.35 seconds when inserting 10,478 rows (same execution plan for OPTIMIZER_FEATURES_ENABLE=’10.2.0.2′):

--------------------------------------------------+-----------------------------------+
| Id  | Operation                    | Name       | Rows  | Bytes | Cost  | Time      |
--------------------------------------------------+-----------------------------------+
| 0   | INSERT STATEMENT             |            |       |       |   442 |           |
| 1   |  SORT GROUP BY               |            |   489 |   46K |   442 |  00:00:04 |
| 2   |   NESTED LOOPS               |            |  1006 |   95K |   441 |  00:00:04 |
| 3   |    FILTER                    |            |       |       |       |           |
| 4   |     HASH JOIN OUTER          |            |   671 |   39K |   440 |  00:00:04 |
| 5   |      VIEW                    |            |   671 |   14K |    65 |  00:00:01 |
| 6   |       SORT GROUP BY          |            |   671 |   17K |    65 |  00:00:01 |
| 7   |        FILTER                |            |       |       |       |           |
| 8   |         INDEX FAST FULL SCAN | T1_PK      |  107K | 2773K |    60 |  00:00:01 |
| 9   |      VIEW                    |            |   700 |   27K |   375 |  00:00:03 |
| 10  |       SORT GROUP BY          |            |   700 |   40K |   375 |  00:00:03 |
| 11  |        HASH JOIN             |            |  146K | 8454K |   368 |  00:00:03 |
| 12  |         TABLE ACCESS FULL    | T2         |   700 |   18K |     3 |  00:00:01 |
| 13  |         TABLE ACCESS FULL    | T2_LINES   |  146K | 4664K |   364 |  00:00:03 |
| 14  |    INDEX RANGE SCAN          | T1_LINES_PK|     1 |    37 |     1 |  00:00:01 |
--------------------------------------------------+-----------------------------------+
Predicate Information:
----------------------
3 - filter(COALESCE("CO"."DESIRED_SHIP_DATE",SYSDATE@!-365)<SYSDATE@!+1200)
4 - access("E"."CUSTPO"="CO"."CUSTOMER_PO_REF")
7 - filter(SYSDATE@!-365<=SYSDATE@!+1200)
11 - access("CO"."ID"="COL"."CUST_ORDER_ID")
12 - filter("CUSTOMER_PO_REF" IS NOT NULL)
13 - filter("COL"."DESIRED_SHIP_DATE">=SYSDATE@!-365)
14 - access("E"."CUSTPO"="EL"."CUSTPO" AND "E"."RELID"="EL"."RELID" AND "EL"."FCDUEDATE">COALESCE("CO"."DESIRED_SHIP_DATE",SYSDATE@!-365) AND "EL"."FCSTQTY">0 AND "EL"."FCDUEDATE"<=SYSDATE@!+1200)
14 - filter(("EL"."FCDUEDATE">=SYSDATE@!-365 AND "EL"."FCSTQTY">0))

Statistics
----------------------------------------------------------                     
        183  recursive calls                                                   
        495  db block gets                                                     
       7702  consistent gets                                                   
          2  physical reads                                                    
     294848  redo size                                                         
        830  bytes sent via SQL*Net to client                                  
       1712  bytes received via SQL*Net from client                            
          3  SQL*Net roundtrips to/from client                                 
          4  sorts (memory)                                                    
          0  sorts (disk)                                                      
       7604  rows processed

Again, notice that the execution plan remained the same for the SELECT and INSERT INTO SQL statements.  Is this a bug in 11.2.0.1 that does not exist in 10.2.0.5, or was a bug introduced in 10.2.0.5?  Let’s take a look at a portion of the 10053 trace file from Oracle Database 11.2.0.1, comparing the output for the two settings of OPTIMIZER_FEATURES_ENABLE where a change in the execution plan was identified in 11.2.0.1.  With the setting at 10.2.0.2 we see that the complex view merge was prevented due to a CBQT (cost-based query transformation) directive, while that did not happen with the setting at 10.1.0.4:


11.2.0.1 

OPTIMIZER_FEATURES_ENABLE=’10.1.0.4′

OPTIMIZER_FEATURES_ENABLE=’10.2.0.2′

 

JE:   Considering Join Elimination on query block SEL$4 (#0)

JE:   Considering Join Elimination on query block SEL$4 (#0)

 

*************************

*************************

 

Join Elimination (JE)   

Join Elimination (JE)   

 

*************************

*************************

 

SQL:******* UNPARSED QUERY IS *******

SQL:******* UNPARSED QUERY IS *******

 

SELECT “CO”.”CUSTOMER_PO_REF” “CUSTOMER_PO_REF”,MAX(“COL”.”DESIRED_SHIP_DATE”) “DESIRED_SHIP_DATE”,MAX(“COL”.”PART_ID”) “PART_ID” FROM “TESTUSER”.”T2″ “CO”,”TESTUSER”.”T2_LINES” “COL” WHERE “CO”.”ID”=”COL”.”CUST_ORDER_ID” AND “CO”.”CUSTOMER_PO_REF” IS NOT NULL AND “COL”.”DESIRED_SHIP_DATE”>=SYSDATE@!-365 GROUP BY “CO”.”CUSTOMER_PO_REF”

SELECT “CO”.”CUSTOMER_PO_REF” “CUSTOMER_PO_REF”,MAX(“COL”.”DESIRED_SHIP_DATE”) “DESIRED_SHIP_DATE”,MAX(“COL”.”PART_ID”) “PART_ID” FROM “TESTUSER”.”T2″ “CO”,”TESTUSER”.”T2_LINES” “COL” WHERE “CO”.”ID”=”COL”.”CUST_ORDER_ID” AND “CO”.”CUSTOMER_PO_REF” IS NOT NULL AND “COL”.”DESIRED_SHIP_DATE”>=SYSDATE@!-365 GROUP BY “CO”.”CUSTOMER_PO_REF”

 

SQL:******* UNPARSED QUERY IS *******

SQL:******* UNPARSED QUERY IS *******

 

SELECT “CO”.”CUSTOMER_PO_REF” “CUSTOMER_PO_REF”,MAX(“COL”.”DESIRED_SHIP_DATE”) “DESIRED_SHIP_DATE”,MAX(“COL”.”PART_ID”) “PART_ID” FROM “TESTUSER”.”T2″ “CO”,”TESTUSER”.”T2_LINES” “COL” WHERE “CO”.”ID”=”COL”.”CUST_ORDER_ID” AND “CO”.”CUSTOMER_PO_REF” IS NOT NULL AND “COL”.”DESIRED_SHIP_DATE”>=SYSDATE@!-365 GROUP BY “CO”.”CUSTOMER_PO_REF”

SELECT “CO”.”CUSTOMER_PO_REF” “CUSTOMER_PO_REF”,MAX(“COL”.”DESIRED_SHIP_DATE”) “DESIRED_SHIP_DATE”,MAX(“COL”.”PART_ID”) “PART_ID” FROM “TESTUSER”.”T2″ “CO”,”TESTUSER”.”T2_LINES” “COL” WHERE “CO”.”ID”=”COL”.”CUST_ORDER_ID” AND “CO”.”CUSTOMER_PO_REF” IS NOT NULL AND “COL”.”DESIRED_SHIP_DATE”>=SYSDATE@!-365 GROUP BY “CO”.”CUSTOMER_PO_REF”

 

Query block SEL$4 (#0) unchanged

Query block SEL$4 (#0) unchanged

Different

CVM:   Checking validity of merging in query block SEL$2 (#0)

CVM:     CVM bypassed: view on right side of Outer Join + MuLTiple TABle.

Different

CVM: Considering view merge in query block SEL$2 (#0)

 

Different

CVM:   Checking validity of merging in query block SEL$3 (#0)

 

Different

CVM: Considering view merge in query block SEL$3 (#0)

 

 

CNT:   Considering count(col) to count(*) on query block SEL$3 (#0)

CNT:   Considering count(col) to count(*) on query block SEL$3 (#0)

 

*************************

*************************

 

Count(col) to Count(*) (CNT)

Count(col) to Count(*) (CNT)

 

*************************

*************************

 

CNT:     COUNT() to COUNT(*) not done.

CNT:     COUNT() to COUNT(*) not done.

Different

 

CVM: CBQT Marking query block SEL$3 (#0) as valid for CVM.

Different

CVM:   Merging complex view SEL$3 (#0) into SEL$2 (#0).

CVM:   Not Merging SEL$3 (#0) into SEL$2 (#0) due to CBQT directive.

Different

qbcp:******* UNPARSED QUERY IS *******

 

Different

SELECT /*+ LEADING (“E”) */ “E”.”CUSTPO” “CUSTPO”,”EL”.”FCSTQTY” “FCSTQTY”,”EL”.”FCDUEDATE” “FCDUEDATE” FROM  (SELECT “E”.”CUSTPO” “CUSTPO”,MAX(“E”.”RELID”) “RELID” FROM “TESTUSER”.”T1″ “E” GROUP BY “E”.”CUSTPO”) “E”,”TESTUSER”.”T1_LINES” “EL” WHERE “E”.”CUSTPO”=”EL”.”CUSTPO” AND “E”.”RELID”=”EL”.”RELID” AND “EL”.”FCDUEDATE”>=SYSDATE@!-365 AND “EL”.”FCDUEDATE”<=SYSDATE@!+1200 AND “EL”.”FCSTQTY”>0

 

Different

vqbcp:******* UNPARSED QUERY IS *******

 

Different

SELECT “E”.”CUSTPO” “CUSTPO”,MAX(“E”.”RELID”) “RELID” FROM “TESTUSER”.”T1″ “E” GROUP BY “E”.”CUSTPO”

 

Different

CVM: result SEL$2 (#0)

 

Different

******* UNPARSED QUERY IS *******

 

Different

SELECT /*+ LEADING (“E”) */ “E”.”CUSTPO” “CUSTPO”,”EL”.”FCSTQTY” “FCSTQTY”,”EL”.”FCDUEDATE” “FCDUEDATE” FROM “TESTUSER”.”T1″ “E”,”TESTUSER”.”T1_LINES” “EL” WHERE “E”.”CUSTPO”=”EL”.”CUSTPO” AND “EL”.”FCDUEDATE”>=SYSDATE@!-365 AND “EL”.”FCDUEDATE”<=SYSDATE@!+1200 AND “EL”.”FCSTQTY”>0 GROUP BY “E”.”CUSTPO”,”EL”.ROWID,”EL”.”RELID”,”EL”.”FCDUEDATE”,”EL”.”FCSTQTY” HAVING MAX(“E”.”RELID”)=”EL”.”RELID”

 

 

JE:   Considering Join Elimination on query block SEL$2 (#0)

JE:   Considering Join Elimination on query block SEL$2 (#0)

 

*************************

*************************

 

Join Elimination (JE)   

Join Elimination (JE)   

 

*************************

*************************

 

SQL:******* UNPARSED QUERY IS *******

SQL:******* UNPARSED QUERY IS *******

Different

SELECT /*+ LEADING (“E”) */ “E”.”CUSTPO” “CUSTPO”,”EL”.”FCSTQTY” “FCSTQTY”,”EL”.”FCDUEDATE” “FCDUEDATE” FROM “TESTUSER”.”T1″ “E”,”TESTUSER”.”T1_LINES” “EL” WHERE “E”.”CUSTPO”=”EL”.”CUSTPO” AND “EL”.”FCDUEDATE”>=SYSDATE@!-365 AND “EL”.”FCDUEDATE”<=SYSDATE@!+1200 AND “EL”.”FCSTQTY”>0 GROUP BY “E”.”CUSTPO”,”EL”.ROWID,”EL”.”RELID”,”EL”.”FCDUEDATE”,”EL”.”FCSTQTY” HAVING MAX(“E”.”RELID”)=”EL”.”RELID”

SELECT /*+ LEADING (“E”) */ “E”.”CUSTPO” “CUSTPO”,”EL”.”FCSTQTY” “FCSTQTY”,”EL”.”FCDUEDATE” “FCDUEDATE” FROM  (SELECT “E”.”CUSTPO” “CUSTPO”,MAX(“E”.”RELID”) “RELID” FROM “TESTUSER”.”T1″ “E” GROUP BY “E”.”CUSTPO”) “E”,”TESTUSER”.”T1_LINES” “EL” WHERE “E”.”CUSTPO”=”EL”.”CUSTPO” AND “E”.”RELID”=”EL”.”RELID” AND “EL”.”FCDUEDATE”>=SYSDATE@!-365 AND “EL”.”FCDUEDATE”<=SYSDATE@!+1200 AND “EL”.”FCSTQTY”>0

 ——————-

Let’s take a look at a portion of the 10053 trace file on Oracle Database 10.2.0.5, comparing the output for the two settings of OPTIMIZER_FEATURES_ENABLE where a change in the execution plan was identified.  With the setting at 10.2.0.2 we see that the complex view merge was prevented due to a CBQT (cost-based query transformation) directive, and that also happened with the setting at 10.1.0.4:

10.2.0.5

OPTIMIZER_FEATURES_ENABLE=’10.1.0.4′

OPTIMIZER_FEATURES_ENABLE=’10.2.0.2′

 

**************************

**************************

 

Predicate Move-Around (PM)

Predicate Move-Around (PM)

 

**************************

**************************

 

PM: Considering predicate move-around in INS$1 (#0).

PM: Considering predicate move-around in INS$1 (#0).

 

PM:   Checking validity of predicate move-around in INS$1 (#0).

PM:   Checking validity of predicate move-around in INS$1 (#0).

 

CBQT: Validity checks passed for 2bxr3x54dk7nq.

CBQT: Validity checks passed for 2bxr3x54dk7nq.

 

voptcojrj: logp:0000000012312FF8

voptcojrj: logp:0000000012312FF8

 

voptcojrj:”E”.”CUSTPO”=”CO”.”CUSTOMER_PO_REF”(+)

voptcojrj:”E”.”CUSTPO”=”CO”.”CUSTOMER_PO_REF”(+)

 

rejected

rejected

 

voptcojrj:”E”.”FCDUEDATE”>COALESCE(“CO”.”DESIRED_SHIP_DATE”,SYSDATE@!-365)

voptcojrj:”E”.”FCDUEDATE”>COALESCE(“CO”.”DESIRED_SHIP_DATE”,SYSDATE@!-365)

 

rejected

rejected

Different

 

Query block (0000000012314D80) before join elimination:

Different

 

SQL:******* UNPARSED QUERY IS *******

Different

 

SELECT “CO”.”CUSTOMER_PO_REF” “CUSTOMER_PO_REF”,MAX(“COL”.”DESIRED_SHIP_DATE”) “DESIRED_SHIP_DATE”,MAX(“COL”.”PART_ID”) “PART_ID” FROM “TESTUSER”.”T2″ “CO”,”TESTUSER”.”T2_LINES” “COL” WHERE “CO”.”ID”=”COL”.”CUST_ORDER_ID” AND “CO”.”CUSTOMER_PO_REF” IS NOT NULL AND “COL”.”DESIRED_SHIP_DATE”>=SYSDATE@!-365 GROUP BY “CO”.”CUSTOMER_PO_REF”

Different

 

Query block (0000000012314D80) unchanged

 

CVM: CBQT Marking query block SEL$3 (#0)as valid for CVM.

CVM: CBQT Marking query block SEL$3 (#0)as valid for CVM.

 

CVM:  Not merging SEL$3 (#0) into SEL$2 (#0) due to CBQT directive.

CVM:  Not merging SEL$3 (#0) into SEL$2 (#0) due to CBQT directive.

Different

CVM:   Merging SPJ view SEL$2 (#0) into SEL$1 (#0)

Query block (000000001231DE28) before join elimination:

Different

 

SQL:******* UNPARSED QUERY IS *******

Different

 

SELECT /*+ LEADING (“E”) */ “E”.”CUSTPO” “CUSTPO”,”EL”.”FCSTQTY” “FCSTQTY”,”EL”.”FCDUEDATE” “FCDUEDATE” FROM  (SELECT “E”.”CUSTPO” “CUSTPO”,MAX(“E”.”RELID”) “RELID” FROM “TESTUSER”.”T1″ “E” GROUP BY “E”.”CUSTPO”) “E”,”TESTUSER”.”T1_LINES” “EL” WHERE “E”.”CUSTPO”=”EL”.”CUSTPO” AND “E”.”RELID”=”EL”.”RELID” AND “EL”.”FCDUEDATE”>=SYSDATE@!-365 AND “EL”.”FCDUEDATE”<=SYSDATE@!+1200 AND “EL”.”FCSTQTY”>0

Different

 

Query block (000000001231DE28) unchanged

Different

 

CVM:   Merging SPJ view SEL$2 (#0) into SEL$1 (#0)

 

voptcojrj: logp:0000000012312FF8

voptcojrj: logp:0000000012312FF8

 

voptcojrj:”E”.”CUSTPO”=”CO”.”CUSTOMER_PO_REF”(+)

voptcojrj:”E”.”CUSTPO”=”CO”.”CUSTOMER_PO_REF”(+)

 

rejected

rejected

 

voptcojrj:”EL”.”FCDUEDATE”>COALESCE(“CO”.”DESIRED_SHIP_DATE”,SYSDATE@!-365)

voptcojrj:”EL”.”FCDUEDATE”>COALESCE(“CO”.”DESIRED_SHIP_DATE”,SYSDATE@!-365)

 

rejected

rejected

 

voptcojrj:”E”.”CUSTPO”=”EL”.”CUSTPO”

voptcojrj:”E”.”CUSTPO”=”EL”.”CUSTPO”

 

rejected

rejected

 

voptcojrj:”E”.”RELID”=”EL”.”RELID”

voptcojrj:”E”.”RELID”=”EL”.”RELID”

 

rejected

rejected

 

voptcojrj:”EL”.”FCDUEDATE”>=SYSDATE@!-365

voptcojrj:”EL”.”FCDUEDATE”>=SYSDATE@!-365

 

rejected

rejected

 

voptcojrj:”EL”.”FCDUEDATE”<=SYSDATE@!+1200

voptcojrj:”EL”.”FCDUEDATE”<=SYSDATE@!+1200

 

rejected

rejected

 

voptcojrj:”EL”.”FCSTQTY”>0

voptcojrj:”EL”.”FCSTQTY”>0

 

rejected

rejected

Different

 

Query block (000000001231ED68) before join elimination:

Different

 

SQL:******* UNPARSED QUERY IS *******

Different

 

SELECT /*+ LEADING (“E”) LEADING (“E”) */ COALESCE(“CO”.”PART_ID”,’NOT-IN-SYSTEM’) “PART_ID”,”EL”.”FCDUEDATE” “REQUIRED_DATE”,SUM(“EL”.”FCSTQTY”) “QTY”,1 “PLAN_LEVEL” FROM  (SELECT “E”.”CUSTPO” “CUSTPO”,MAX(“E”.”RELID”) “RELID” FROM “TESTUSER”.”T1″ “E” GROUP BY “E”.”CUSTPO”) “E”,”TESTUSER”.”T1_LINES” “EL”, (SELECT “CO”.”CUSTOMER_PO_REF” “CUSTOMER_PO_REF”,MAX(“COL”.”DESIRED_SHIP_DATE”) “DESIRED_SHIP_DATE”,MAX(“COL”.”PART_ID”) “PART_ID” FROM “TESTUSER”.”T2″ “CO”,”TESTUSER”.”T2_LINES” “COL” WHERE “CO”.”ID”=”COL”.”CUST_ORDER_ID” AND “CO”.”CUSTOMER_PO_REF” IS NOT NULL AND “COL”.”DESIRED_SHIP_DATE”>=SYSDATE@!-365 GROUP BY “CO”.”CUSTOMER_PO_REF”) “CO” WHERE “E”.”CUSTPO”=”CO”.”CUSTOMER_PO_REF”(+) AND “EL”.”FCDUEDATE”>COALESCE(“CO”.”DESIRED_SHIP_DATE”,SYSDATE@!-365) AND “E”.”CUSTPO”=”EL”.”CUSTPO” AND “E”.”RELID”=”EL”.”RELID” AND “EL”.”FCDUEDATE”>=SYSDATE@!-365 AND “EL”.”FCDUEDATE”<=SYSDATE@!+1200 AND “EL”.”FCSTQTY”>0 GROUP BY COALESCE(“CO”.”PART_ID”,’NOT-IN-SYSTEM’),”EL”.”FCDUEDATE” ORDER BY COALESCE(“CO”.”PART_ID”,’NOT-IN-SYSTEM’),”EL”.”FCDUEDATE”

Different

 

Query block (000000001231ED68) unchanged

 

Registered qb: SEL$F5BB74E1 0x1231ed68 (VIEW MERGE SEL$1; SEL$2)

Registered qb: SEL$F5BB74E1 0x1231ed68 (VIEW MERGE SEL$1; SEL$2)

 

  signature (): qb_name=SEL$F5BB74E1 nbfros=3 flg=0

  signature (): qb_name=SEL$F5BB74E1 nbfros=3 flg=0

 

    fro(0): flg=1 objn=0 hint_alias=”CO”@”SEL$1″

    fro(0): flg=1 objn=0 hint_alias=”CO”@”SEL$1″

 

    fro(1): flg=1 objn=0 hint_alias=”E”@”SEL$2″

    fro(1): flg=1 objn=0 hint_alias=”E”@”SEL$2″

 

    fro(2): flg=0 objn=47930 hint_alias=”EL”@”SEL$2″

    fro(2): flg=0 objn=47930 hint_alias=”EL”@”SEL$2″

 

Now what?  Is it considered a bug if Oracle Database 11.2.0.1 behaves similar to 10.2.0.2, but not similar to 10.2.0.5, when the OPTIMIZER_FEATURES_ENABLE parameter is set to 10.1.0.4?





SELECT Statement is Fast, INSERT INTO Using the SELECT Statement is Brutally Slow 2

18 12 2010

December 18, 2010 (Modified December 19, 2010)

(Back to the Previous Post in the Series) (Forward to the Next Post in the Series)

The previous blog article in this series resulted in several interesting comments with very useful advice.  But was the performance issue just an isolated case, one that only happens in one database, with one Oracle Database release version?  We need a test case to determine how frequently this problem may occur.  First, we will create two tables, table T1 will emulate table EDI830 from the previous blog article, and table T1_LINES will emulate the EDI830_LINES table.  A PADDING column will be used to make the average row length roughly equivalent to that of the original tables:

CREATE TABLE T1(
  CUSTPO VARCHAR2(12) NOT NULL,
  RELID VARCHAR2(12) NOT NULL,
  PADDING VARCHAR2(40),
  CONSTRAINT T1_PK PRIMARY KEY (CUSTPO,RELID));

CREATE TABLE T1_LINES(
  CUSTPO VARCHAR2(12) NOT NULL,
  RELID VARCHAR2(12) NOT NULL,
  FCSTQTY NUMBER NOT NULL,
  FC VARCHAR2(1),
  FCDUEDATE DATE NOT NULL,
  CONSTRAINT T1_LINES_PK PRIMARY KEY (CUSTPO,RELID,FCDUEDATE,FCSTQTY)); 

Next, the table T1 is populated in a repeatable way that as best as possible simulates how the original table was actually populated in production:

INSERT INTO T1
SELECT
  RPAD(CHR(MOD(ROWNUM-1,26)+65)||TO_CHAR(ROWNUM),12,'A') CUSTPO,
  LPAD('1',12,'0') RELID,
  LPAD('A',40,'A') PADDING
FROM
  DUAL
CONNECT BY
  LEVEL<=700;

INSERT INTO
  T1
SELECT
  CUSTPO,
  LPAD(TO_CHAR(V2.RN+1),12,'0') RELID,
  LPAD('A',40,'A') PADDING
FROM
  (SELECT /*+ NO_MERGE */
    CUSTPO,
    PADDING,
    MOD(ROWNUM,10)*30+19 RN
  FROM
    (SELECT /*+ NO_MERGE */
      CUSTPO,
      PADDING
    FROM
      T1
    ORDER BY
      CUSTPO)) V1,
  (SELECT /*+ NO_MERGE */
    ROWNUM RN
  FROM
    DUAL
  CONNECT BY
    LEVEL<=319) V2
WHERE
  V2.RN<=V1.RN; 

If we select from table T1, we are able to see how the row counts are distributed in an unequal, yet repeatable way, with 700 distinct customer purchase order numbers: 

SELECT
  CUSTPO,
  MIN(RELID),
  MAX(RELID)
FROM
  T1
GROUP BY
  CUSTPO
ORDER BY
  CUSTPO;

CUSTPO       MIN(RELID)   MAX(RELID)
------------ ------------ ------------
A105AAAAAAAA 000000000001 000000000050
A131AAAAAAAA 000000000001 000000000080
A157AAAAAAAA 000000000001 000000000110
A183AAAAAAAA 000000000001 000000000140
A1AAAAAAAAAA 000000000001 000000000170
A209AAAAAAAA 000000000001 000000000200
A235AAAAAAAA 000000000001 000000000230
A261AAAAAAAA 000000000001 000000000260
...

Z624AAAAAAAA 000000000001 000000000230
Z650AAAAAAAA 000000000001 000000000260
Z676AAAAAAAA 000000000001 000000000290
Z78AAAAAAAAA 000000000001 000000000020

700 rows selected. 

Just as a quick experiment, let’s take a look at the output of the SQL statement that will be used to populate the line detail table (T1_LINES) for the customer POs:

SELECT
  CUSTPO,
  RELID,
  10 FCSTQTY,
  'A' FC,
  TO_DATE('01-JAN-2011','DD-MON-YYYY') + (V2.RN*3 - V1.REL*2) FCDUEDATE
FROM
  (SELECT /*+ NO_MERGE */
    CUSTPO,
    RELID,
    ROW_NUMBER() OVER (PARTITION BY RELID ORDER BY CUSTPO) RN,
    ROW_NUMBER() OVER (PARTITION BY CUSTPO ORDER BY RELID DESC) REL
  FROM
    T1
  WHERE
    CUSTPO IN ('Z78AAAAAAAAA','Y155AAAAAAAA')) V1,
  (SELECT /*+ NO_MERGE */
    ROWNUM RN
  FROM
    DUAL
  CONNECT BY
    LEVEL<=100) V2
WHERE
  V2.RN < (MOD(V1.RN,100)+10)
ORDER BY
  CUSTPO,
  RELID,
  5;

CUSTPO       RELID           FCSTQTY F FCDUEDATE
------------ ------------ ---------- - ---------
Y155AAAAAAAA 000000000001         10 A 26-SEP-10
Y155AAAAAAAA 000000000001         10 A 29-SEP-10
Y155AAAAAAAA 000000000001         10 A 02-OCT-10
Y155AAAAAAAA 000000000001         10 A 05-OCT-10
Y155AAAAAAAA 000000000001         10 A 08-OCT-10
Y155AAAAAAAA 000000000001         10 A 11-OCT-10
Y155AAAAAAAA 000000000001         10 A 14-OCT-10
Y155AAAAAAAA 000000000001         10 A 17-OCT-10
Y155AAAAAAAA 000000000001         10 A 20-OCT-10
Y155AAAAAAAA 000000000001         10 A 23-OCT-10
Y155AAAAAAAA 000000000002         10 A 28-SEP-10
Y155AAAAAAAA 000000000002         10 A 01-OCT-10
...

Z78AAAAAAAAA 000000000020         10 A 17-JAN-11
Z78AAAAAAAAA 000000000020         10 A 20-JAN-11
Z78AAAAAAAAA 000000000020         10 A 23-JAN-11
Z78AAAAAAAAA 000000000020         10 A 26-JAN-11
Z78AAAAAAAAA 000000000020         10 A 29-JAN-11
Z78AAAAAAAAA 000000000020         10 A 01-FEB-11

720 rows selected.

In the above, you can see how the dates will automatically shift from one release of a customer PO to the next, as well as the order in which the rows will be inserted.  The actual dates and number of rows for these two customer POs will actually be a bit different when the rows are inserted into the table, so use the above as just an illustration.

Next, let’s insert 6,079,050 rows into the line detail table in a repeatable way:

INSERT INTO
  T1_LINES
SELECT
  CUSTPO,
  RELID,
  10 FCSTQTY,
  'A' FC,
  TO_DATE('01-JAN-2011','DD-MON-YYYY') + (V2.RN*3 - V1.REL*2) FCDUEDATE
FROM
  (SELECT /*+ NO_MERGE */
    CUSTPO,
    RELID,
    ROW_NUMBER() OVER (PARTITION BY RELID ORDER BY CUSTPO) RN,
    ROW_NUMBER() OVER (PARTITION BY CUSTPO ORDER BY RELID DESC) REL
  FROM
    T1) V1,
  (SELECT /*+ NO_MERGE */
    ROWNUM RN
  FROM
    DUAL
  CONNECT BY
    LEVEL<=100) V2
WHERE
  V2.RN < (MOD(V1.RN,100)+10)
ORDER BY
  RELID,
  CUSTPO,
  5; 

COMMIT;

Now let’s create table T2 (simulates table CUSTOMER_ORDER) and table T2_LINES (simulates table CUST_ORDER_LINE).  Table T2_LINES will be populated with 224,700 rows:

CREATE TABLE T2(
  ID VARCHAR2(15),
  CUSTOMER_ID VARCHAR2(15),
  CUSTOMER_PO_REF VARCHAR2(40),
  PADDING VARCHAR2(150),
  PRIMARY KEY(ID));

CREATE TABLE T2_LINES(
  CUST_ORDER_ID VARCHAR2(15),
  LINE_NO NUMBER,
  PART_ID VARCHAR2(30),
  DESIRED_SHIP_DATE DATE,
  PADDING VARCHAR2(100),
  PRIMARY KEY(CUST_ORDER_ID,LINE_NO)); 

INSERT INTO
  T2
SELECT DISTINCT
  CUSTPO ID,
  'AAAAAAAAAA' CUSTOMER_ID,
  CUSTPO CUSTOMER_PO_REF,
  RPAD('A',150,'A') PADDING
FROM
  T1
ORDER BY
  DBMS_RANDOM.VALUE;

INSERT INTO
  T2_LINES
SELECT
  CUST_ORDER_ID,
  ROW_NUMBER() OVER (PARTITION BY CUST_ORDER_ID ORDER BY DESIRED_SHIP_DATE) LINE_NO,
  RPAD(TO_CHAR((MOD(ROWNUM,3000)+1) * 33)||'PART',10,'A') PART_ID,
  DESIRED_SHIP_DATE,
  RPAD('A',100,'A') PADDING
FROM 
  (SELECT DISTINCT
    CUSTPO CUST_ORDER_ID,
    FCDUEDATE DESIRED_SHIP_DATE   
  FROM
    T1_LINES
  WHERE
    FCDUEDATE<= TO_DATE('15-JAN-2011','DD-MON-YYYY')) V1;

COMMIT;

Finally, we will gather statistics for the tables and the primary key indexes:

EXEC DBMS_STATS.GATHER_TABLE_STATS(OWNNAME=>USER,TABNAME=>'T1',CASCADE=>TRUE)
EXEC DBMS_STATS.GATHER_TABLE_STATS(OWNNAME=>USER,TABNAME=>'T1_LINES',CASCADE=>TRUE)
EXEC DBMS_STATS.GATHER_TABLE_STATS(OWNNAME=>USER,TABNAME=>'T2',CASCADE=>TRUE)
EXEC DBMS_STATS.GATHER_TABLE_STATS(OWNNAME=>USER,TABNAME=>'T2_LINES',CASCADE=>TRUE) 

We are now able to start transforming the original query sections, these sections will be listed one at a time, as they were in the earlier article:

    (SELECT
      E.CUSTPO,
      MAX(RELID) RELID
    FROM
      T1 E
    GROUP BY
      E.CUSTPO) E 

 The inline view that uses the above inline view: 

  (SELECT /*+ LEADING(E) */
    E.CUSTPO,
    EL.FCSTQTY,
    EL.FCDUEDATE
  FROM
    (SELECT
      E.CUSTPO,
      MAX(RELID) RELID
    FROM
      T1 E
    GROUP BY
      E.CUSTPO) E,
    T1_LINES EL
  WHERE
    E.CUSTPO=EL.CUSTPO
    AND E.RELID=EL.RELID
    AND EL.FCDUEDATE BETWEEN TO_DATE('01-JAN-2011','DD-MON-YYYY')-365 AND TO_DATE('01-JAN-2011','DD-MON-YYYY')+1200
    AND EL.FCSTQTY>0) E 

The inline view for the customer orders:

  (SELECT
    CO.CUSTOMER_PO_REF,
    MAX(COL.DESIRED_SHIP_DATE) DESIRED_SHIP_DATE,
    MAX(COL.PART_ID) PART_ID
  FROM
    T2 CO,
    T2_LINES COL
  WHERE
    CO.ID=COL.CUST_ORDER_ID
    AND CUSTOMER_PO_REF IS NOT NULL
    AND COL.DESIRED_SHIP_DATE>=SYSDATE-365
  GROUP BY
    CO.CUSTOMER_PO_REF) CO 

Finally, the full SQL statement with all of the inline views joined:

SELECT /*+ LEADING(E) */
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM') PART_ID,
  E.FCDUEDATE REQUIRED_DATE,
  SUM(E.FCSTQTY) QTY,
  1 PLAN_LEVEL
FROM
  (SELECT /*+ LEADING(E) */
    E.CUSTPO,
    EL.FCSTQTY,
    EL.FCDUEDATE
  FROM
    (SELECT
      E.CUSTPO,
      MAX(RELID) RELID
    FROM
      T1 E
    GROUP BY
      E.CUSTPO) E,
    T1_LINES EL
  WHERE
    E.CUSTPO=EL.CUSTPO
    AND E.RELID=EL.RELID
    AND EL.FCDUEDATE BETWEEN SYSDATE-365 AND SYSDATE+1200
    AND EL.FCSTQTY>0) E,
  (SELECT
    CO.CUSTOMER_PO_REF,
    MAX(COL.DESIRED_SHIP_DATE) DESIRED_SHIP_DATE,
    MAX(COL.PART_ID) PART_ID
  FROM
    T2 CO,
    T2_LINES COL
  WHERE
    CO.ID=COL.CUST_ORDER_ID
    AND CUSTOMER_PO_REF IS NOT NULL
    AND COL.DESIRED_SHIP_DATE>=SYSDATE-365
  GROUP BY
    CO.CUSTOMER_PO_REF) CO
WHERE
  E.CUSTPO=CO.CUSTOMER_PO_REF(+)
  AND E.FCDUEDATE>COALESCE(CO.DESIRED_SHIP_DATE,SYSDATE-365)
GROUP BY
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM'),
  E.FCDUEDATE
ORDER BY
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM'),
  E.FCDUEDATE; 

Next, we need a simple table to hold the contents of the INSERT INTO… SELECT statement:

CREATE TABLE T1_DEST (
  PART_ID VARCHAR2(30),
  REQUIRED_DATE DATE,
  QTY NUMBER,
  PLAN_LEVEL NUMBER); 

Now the script that will actually perform the test with different values for OPTIMIZER_FEATURES_ENABLE, OPTIMIZER_INDEX_COST_ADJ, and OPTIMIZER_INDEX_CACHING (Edit Dec 19, 2010: the original version of the script set the TRACEFILE_IDENTIFIER value identically for the SELECT and the INSERT INTO versions of the SQL statement when the OPTIMIZER_FEATURES_ENABLED parameter was greater than 10.1.0.4, and that error resulted in the SELECT and the INSERT INTO execution plans appearing in the same trace file, rather than in separate trace files – the script below has been corrected):


SET TIMING ON
SET ARRAYSIZE 1000
SET AUTOTRACE TRACEONLY STATISTICS

SPOOL Capture_Results.txt

ALTER SESSION SET OPTIMIZER_INDEX_CACHING=0;
ALTER SESSION SET OPTIMIZER_INDEX_COST_ADJ=100;

ALTER SESSION SET OPTIMIZER_FEATURES_ENABLE='10.1.0.4';
ALTER SESSION SET TRACEFILE_IDENTIFIER = 'SELECT_10.1.0.4';
ALTER SESSION SET EVENTS '10053 TRACE NAME CONTEXT FOREVER, LEVEL 1';

SELECT /*+ LEADING(E) */
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM') PART_ID,
  E.FCDUEDATE REQUIRED_DATE,
  SUM(E.FCSTQTY) QTY,
  1 PLAN_LEVEL
FROM
  (SELECT /*+ LEADING(E) */
    E.CUSTPO,
    EL.FCSTQTY,
    EL.FCDUEDATE
  FROM
    (SELECT /*+  */
      E.CUSTPO,
      MAX(RELID) RELID
    FROM
      T1 E
    GROUP BY
      E.CUSTPO) E,
    T1_LINES EL
  WHERE
    E.CUSTPO=EL.CUSTPO
    AND E.RELID=EL.RELID
    AND EL.FCDUEDATE BETWEEN SYSDATE-365 AND SYSDATE+1200
    AND EL.FCSTQTY>0) E,
  (SELECT /*+  */
    CO.CUSTOMER_PO_REF,
    MAX(COL.DESIRED_SHIP_DATE) DESIRED_SHIP_DATE,
    MAX(COL.PART_ID) PART_ID
  FROM
    T2 CO,
    T2_LINES COL
  WHERE
    CO.ID=COL.CUST_ORDER_ID
    AND CUSTOMER_PO_REF IS NOT NULL
    AND COL.DESIRED_SHIP_DATE>=SYSDATE-365
  GROUP BY
    CO.CUSTOMER_PO_REF) CO
WHERE
  E.CUSTPO=CO.CUSTOMER_PO_REF(+)
  AND E.FCDUEDATE>COALESCE(CO.DESIRED_SHIP_DATE,SYSDATE-365)
GROUP BY
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM'),
  E.FCDUEDATE
ORDER BY
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM'),
  E.FCDUEDATE;

ALTER SESSION SET EVENTS '10053 TRACE NAME CONTEXT OFF';

ALTER SESSION SET TRACEFILE_IDENTIFIER = 'INSERT_10.1.0.4';
ALTER SESSION SET EVENTS '10053 TRACE NAME CONTEXT FOREVER, LEVEL 1';

INSERT INTO T1_DEST
SELECT /*+ LEADING(E) */
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM') PART_ID,
  E.FCDUEDATE REQUIRED_DATE,
  SUM(E.FCSTQTY) QTY,
  1 PLAN_LEVEL
FROM
  (SELECT /*+ LEADING(E) */
    E.CUSTPO,
    EL.FCSTQTY,
    EL.FCDUEDATE
  FROM
    (SELECT /*+  */
      E.CUSTPO,
      MAX(RELID) RELID
    FROM
      T1 E
    GROUP BY
      E.CUSTPO) E,
    T1_LINES EL
  WHERE
    E.CUSTPO=EL.CUSTPO
    AND E.RELID=EL.RELID
    AND EL.FCDUEDATE BETWEEN SYSDATE-365 AND SYSDATE+1200
    AND EL.FCSTQTY>0) E,
  (SELECT /*+  */
    CO.CUSTOMER_PO_REF,
    MAX(COL.DESIRED_SHIP_DATE) DESIRED_SHIP_DATE,
    MAX(COL.PART_ID) PART_ID
  FROM
    T2 CO,
    T2_LINES COL
  WHERE
    CO.ID=COL.CUST_ORDER_ID
    AND CUSTOMER_PO_REF IS NOT NULL
    AND COL.DESIRED_SHIP_DATE>=SYSDATE-365
  GROUP BY
    CO.CUSTOMER_PO_REF) CO
WHERE
  E.CUSTPO=CO.CUSTOMER_PO_REF(+)
  AND E.FCDUEDATE>COALESCE(CO.DESIRED_SHIP_DATE,SYSDATE-365)
GROUP BY
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM'),
  E.FCDUEDATE
ORDER BY
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM'),
  E.FCDUEDATE;

ALTER SESSION SET EVENTS '10053 TRACE NAME CONTEXT OFF';

TRUNCATE TABLE T1_DEST;

ALTER SESSION SET OPTIMIZER_FEATURES_ENABLE='10.2.0.2';
ALTER SESSION SET TRACEFILE_IDENTIFIER = 'SELECT_10.2.0.2';
ALTER SESSION SET EVENTS '10053 TRACE NAME CONTEXT FOREVER, LEVEL 1';

SELECT /*+ LEADING(E) */
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM') PART_ID,
  E.FCDUEDATE REQUIRED_DATE,
  SUM(E.FCSTQTY) QTY,
  1 PLAN_LEVEL
FROM
  (SELECT /*+ LEADING(E) */
    E.CUSTPO,
    EL.FCSTQTY,
    EL.FCDUEDATE
  FROM
    (SELECT /*+  */
      E.CUSTPO,
      MAX(RELID) RELID
    FROM
      T1 E
    GROUP BY
      E.CUSTPO) E,
    T1_LINES EL
  WHERE
    E.CUSTPO=EL.CUSTPO
    AND E.RELID=EL.RELID
    AND EL.FCDUEDATE BETWEEN SYSDATE-365 AND SYSDATE+1200
    AND EL.FCSTQTY>0) E,
  (SELECT /*+  */
    CO.CUSTOMER_PO_REF,
    MAX(COL.DESIRED_SHIP_DATE) DESIRED_SHIP_DATE,
    MAX(COL.PART_ID) PART_ID
  FROM
    T2 CO,
    T2_LINES COL
  WHERE
    CO.ID=COL.CUST_ORDER_ID
    AND CUSTOMER_PO_REF IS NOT NULL
    AND COL.DESIRED_SHIP_DATE>=SYSDATE-365
  GROUP BY
    CO.CUSTOMER_PO_REF) CO
WHERE
  E.CUSTPO=CO.CUSTOMER_PO_REF(+)
  AND E.FCDUEDATE>COALESCE(CO.DESIRED_SHIP_DATE,SYSDATE-365)
GROUP BY
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM'),
  E.FCDUEDATE
ORDER BY
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM'),
  E.FCDUEDATE;

ALTER SESSION SET EVENTS '10053 TRACE NAME CONTEXT OFF';

ALTER SESSION SET TRACEFILE_IDENTIFIER = 'INSERT_10.2.0.2';
ALTER SESSION SET EVENTS '10053 TRACE NAME CONTEXT FOREVER, LEVEL 1';

INSERT INTO T1_DEST
SELECT /*+ LEADING(E) */
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM') PART_ID,
  E.FCDUEDATE REQUIRED_DATE,
  SUM(E.FCSTQTY) QTY,
  1 PLAN_LEVEL
FROM
  (SELECT /*+ LEADING(E) */
    E.CUSTPO,
    EL.FCSTQTY,
    EL.FCDUEDATE
  FROM
    (SELECT /*+  */
      E.CUSTPO,
      MAX(RELID) RELID
    FROM
      T1 E
    GROUP BY
      E.CUSTPO) E,
    T1_LINES EL
  WHERE
    E.CUSTPO=EL.CUSTPO
    AND E.RELID=EL.RELID
    AND EL.FCDUEDATE BETWEEN SYSDATE-365 AND SYSDATE+1200
    AND EL.FCSTQTY>0) E,
  (SELECT /*+  */
    CO.CUSTOMER_PO_REF,
    MAX(COL.DESIRED_SHIP_DATE) DESIRED_SHIP_DATE,
    MAX(COL.PART_ID) PART_ID
  FROM
    T2 CO,
    T2_LINES COL
  WHERE
    CO.ID=COL.CUST_ORDER_ID
    AND CUSTOMER_PO_REF IS NOT NULL
    AND COL.DESIRED_SHIP_DATE>=SYSDATE-365
  GROUP BY
    CO.CUSTOMER_PO_REF) CO
WHERE
  E.CUSTPO=CO.CUSTOMER_PO_REF(+)
  AND E.FCDUEDATE>COALESCE(CO.DESIRED_SHIP_DATE,SYSDATE-365)
GROUP BY
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM'),
  E.FCDUEDATE
ORDER BY
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM'),
  E.FCDUEDATE;

ALTER SESSION SET EVENTS '10053 TRACE NAME CONTEXT OFF';

TRUNCATE TABLE T1_DEST;

ALTER SESSION SET OPTIMIZER_FEATURES_ENABLE='11.1.0.7';
ALTER SESSION SET TRACEFILE_IDENTIFIER = 'SELECT_11.1.0.7';
ALTER SESSION SET EVENTS '10053 TRACE NAME CONTEXT FOREVER, LEVEL 1';

SELECT /*+ LEADING(E) */
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM') PART_ID,
  E.FCDUEDATE REQUIRED_DATE,
  SUM(E.FCSTQTY) QTY,
  1 PLAN_LEVEL
FROM
  (SELECT /*+ LEADING(E) */
    E.CUSTPO,
    EL.FCSTQTY,
    EL.FCDUEDATE
  FROM
    (SELECT /*+  */
      E.CUSTPO,
      MAX(RELID) RELID
    FROM
      T1 E
    GROUP BY
      E.CUSTPO) E,
    T1_LINES EL
  WHERE
    E.CUSTPO=EL.CUSTPO
    AND E.RELID=EL.RELID
    AND EL.FCDUEDATE BETWEEN SYSDATE-365 AND SYSDATE+1200
    AND EL.FCSTQTY>0) E,
  (SELECT /*+  */
    CO.CUSTOMER_PO_REF,
    MAX(COL.DESIRED_SHIP_DATE) DESIRED_SHIP_DATE,
    MAX(COL.PART_ID) PART_ID
  FROM
    T2 CO,
    T2_LINES COL
  WHERE
    CO.ID=COL.CUST_ORDER_ID
    AND CUSTOMER_PO_REF IS NOT NULL
    AND COL.DESIRED_SHIP_DATE>=SYSDATE-365
  GROUP BY
    CO.CUSTOMER_PO_REF) CO
WHERE
  E.CUSTPO=CO.CUSTOMER_PO_REF(+)
  AND E.FCDUEDATE>COALESCE(CO.DESIRED_SHIP_DATE,SYSDATE-365)
GROUP BY
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM'),
  E.FCDUEDATE
ORDER BY
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM'),
  E.FCDUEDATE;

ALTER SESSION SET EVENTS '10053 TRACE NAME CONTEXT OFF';

ALTER SESSION SET TRACEFILE_IDENTIFIER = 'INSERT_11.1.0.7';
ALTER SESSION SET EVENTS '10053 TRACE NAME CONTEXT FOREVER, LEVEL 1';
INSERT INTO T1_DEST
SELECT /*+ LEADING(E) */
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM') PART_ID,
  E.FCDUEDATE REQUIRED_DATE,
  SUM(E.FCSTQTY) QTY,
  1 PLAN_LEVEL
FROM
  (SELECT /*+ LEADING(E) */
    E.CUSTPO,
    EL.FCSTQTY,
    EL.FCDUEDATE
  FROM
    (SELECT /*+  */
      E.CUSTPO,
      MAX(RELID) RELID
    FROM
      T1 E
    GROUP BY
      E.CUSTPO) E,
    T1_LINES EL
  WHERE
    E.CUSTPO=EL.CUSTPO
    AND E.RELID=EL.RELID
    AND EL.FCDUEDATE BETWEEN SYSDATE-365 AND SYSDATE+1200
    AND EL.FCSTQTY>0) E,
  (SELECT /*+  */
    CO.CUSTOMER_PO_REF,
    MAX(COL.DESIRED_SHIP_DATE) DESIRED_SHIP_DATE,
    MAX(COL.PART_ID) PART_ID
  FROM
    T2 CO,
    T2_LINES COL
  WHERE
    CO.ID=COL.CUST_ORDER_ID
    AND CUSTOMER_PO_REF IS NOT NULL
    AND COL.DESIRED_SHIP_DATE>=SYSDATE-365
  GROUP BY
    CO.CUSTOMER_PO_REF) CO
WHERE
  E.CUSTPO=CO.CUSTOMER_PO_REF(+)
  AND E.FCDUEDATE>COALESCE(CO.DESIRED_SHIP_DATE,SYSDATE-365)
GROUP BY
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM'),
  E.FCDUEDATE
ORDER BY
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM'),
  E.FCDUEDATE;

ALTER SESSION SET EVENTS '10053 TRACE NAME CONTEXT OFF';

TRUNCATE TABLE T1_DEST;

ALTER SESSION SET OPTIMIZER_FEATURES_ENABLE='11.2.0.1';
ALTER SESSION SET TRACEFILE_IDENTIFIER = 'SELECT_11.2.0.1';
ALTER SESSION SET EVENTS '10053 TRACE NAME CONTEXT FOREVER, LEVEL 1';

SELECT /*+ LEADING(E) */
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM') PART_ID,
  E.FCDUEDATE REQUIRED_DATE,
  SUM(E.FCSTQTY) QTY,
  1 PLAN_LEVEL
FROM
  (SELECT /*+ LEADING(E) */
    E.CUSTPO,
    EL.FCSTQTY,
    EL.FCDUEDATE
  FROM
    (SELECT /*+  */
      E.CUSTPO,
      MAX(RELID) RELID
    FROM
      T1 E
    GROUP BY
      E.CUSTPO) E,
    T1_LINES EL
  WHERE
    E.CUSTPO=EL.CUSTPO
    AND E.RELID=EL.RELID
    AND EL.FCDUEDATE BETWEEN SYSDATE-365 AND SYSDATE+1200
    AND EL.FCSTQTY>0) E,
  (SELECT /*+  */
    CO.CUSTOMER_PO_REF,
    MAX(COL.DESIRED_SHIP_DATE) DESIRED_SHIP_DATE,
    MAX(COL.PART_ID) PART_ID
  FROM
    T2 CO,
    T2_LINES COL
  WHERE
    CO.ID=COL.CUST_ORDER_ID
    AND CUSTOMER_PO_REF IS NOT NULL
    AND COL.DESIRED_SHIP_DATE>=SYSDATE-365
  GROUP BY
    CO.CUSTOMER_PO_REF) CO
WHERE
  E.CUSTPO=CO.CUSTOMER_PO_REF(+)
  AND E.FCDUEDATE>COALESCE(CO.DESIRED_SHIP_DATE,SYSDATE-365)
GROUP BY
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM'),
  E.FCDUEDATE
ORDER BY
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM'),
  E.FCDUEDATE;

ALTER SESSION SET EVENTS '10053 TRACE NAME CONTEXT OFF';

ALTER SESSION SET TRACEFILE_IDENTIFIER = 'INSERT_11.2.0.1';
ALTER SESSION SET EVENTS '10053 TRACE NAME CONTEXT FOREVER, LEVEL 1';

INSERT INTO T1_DEST
SELECT /*+ LEADING(E) */
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM') PART_ID,
  E.FCDUEDATE REQUIRED_DATE,
  SUM(E.FCSTQTY) QTY,
  1 PLAN_LEVEL
FROM
  (SELECT /*+ LEADING(E) */
    E.CUSTPO,
    EL.FCSTQTY,
    EL.FCDUEDATE
  FROM
    (SELECT /*+  */
      E.CUSTPO,
      MAX(RELID) RELID
    FROM
      T1 E
    GROUP BY
      E.CUSTPO) E,
    T1_LINES EL
  WHERE
    E.CUSTPO=EL.CUSTPO
    AND E.RELID=EL.RELID
    AND EL.FCDUEDATE BETWEEN SYSDATE-365 AND SYSDATE+1200
    AND EL.FCSTQTY>0) E,
  (SELECT /*+  */
    CO.CUSTOMER_PO_REF,
    MAX(COL.DESIRED_SHIP_DATE) DESIRED_SHIP_DATE,
    MAX(COL.PART_ID) PART_ID
  FROM
    T2 CO,
    T2_LINES COL
  WHERE
    CO.ID=COL.CUST_ORDER_ID
    AND CUSTOMER_PO_REF IS NOT NULL
    AND COL.DESIRED_SHIP_DATE>=SYSDATE-365
  GROUP BY
    CO.CUSTOMER_PO_REF) CO
WHERE
  E.CUSTPO=CO.CUSTOMER_PO_REF(+)
  AND E.FCDUEDATE>COALESCE(CO.DESIRED_SHIP_DATE,SYSDATE-365)
GROUP BY
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM'),
  E.FCDUEDATE
ORDER BY
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM'),
  E.FCDUEDATE;

ALTER SESSION SET EVENTS '10053 TRACE NAME CONTEXT OFF';

SPOOL Capture_Results80.txt

TRUNCATE TABLE T1_DEST;

ALTER SESSION SET OPTIMIZER_INDEX_CACHING=100;
ALTER SESSION SET OPTIMIZER_INDEX_COST_ADJ=80;

ALTER SESSION SET OPTIMIZER_FEATURES_ENABLE='10.1.0.4';
ALTER SESSION SET TRACEFILE_IDENTIFIER = 'SELECT_10.1.0.4_80';
ALTER SESSION SET EVENTS '10053 TRACE NAME CONTEXT FOREVER, LEVEL 1';

SELECT /*+ LEADING(E) */
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM') PART_ID,
  E.FCDUEDATE REQUIRED_DATE,
  SUM(E.FCSTQTY) QTY,
  1 PLAN_LEVEL
FROM
  (SELECT /*+ LEADING(E) */
    E.CUSTPO,
    EL.FCSTQTY,
    EL.FCDUEDATE
  FROM
    (SELECT /*+ _80 */
      E.CUSTPO,
      MAX(RELID) RELID
    FROM
      T1 E
    GROUP BY
      E.CUSTPO) E,
    T1_LINES EL
  WHERE
    E.CUSTPO=EL.CUSTPO
    AND E.RELID=EL.RELID
    AND EL.FCDUEDATE BETWEEN SYSDATE-365 AND SYSDATE+1200
    AND EL.FCSTQTY>0) E,
  (SELECT /*+  */
    CO.CUSTOMER_PO_REF,
    MAX(COL.DESIRED_SHIP_DATE) DESIRED_SHIP_DATE,
    MAX(COL.PART_ID) PART_ID
  FROM
    T2 CO,
    T2_LINES COL
  WHERE
    CO.ID=COL.CUST_ORDER_ID
    AND CUSTOMER_PO_REF IS NOT NULL
    AND COL.DESIRED_SHIP_DATE>=SYSDATE-365
  GROUP BY
    CO.CUSTOMER_PO_REF) CO
WHERE
  E.CUSTPO=CO.CUSTOMER_PO_REF(+)
  AND E.FCDUEDATE>COALESCE(CO.DESIRED_SHIP_DATE,SYSDATE-365)
GROUP BY
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM'),
  E.FCDUEDATE
ORDER BY
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM'),
  E.FCDUEDATE;

ALTER SESSION SET EVENTS '10053 TRACE NAME CONTEXT OFF';

ALTER SESSION SET TRACEFILE_IDENTIFIER = 'INSERT_10.1.0.4_80';
ALTER SESSION SET EVENTS '10053 TRACE NAME CONTEXT FOREVER, LEVEL 1';

INSERT INTO T1_DEST
SELECT /*+ LEADING(E) */
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM') PART_ID,
  E.FCDUEDATE REQUIRED_DATE,
  SUM(E.FCSTQTY) QTY,
  1 PLAN_LEVEL
FROM
  (SELECT /*+ LEADING(E) */
    E.CUSTPO,
    EL.FCSTQTY,
    EL.FCDUEDATE
  FROM
    (SELECT /*+ _80 */
      E.CUSTPO,
      MAX(RELID) RELID
    FROM
      T1 E
    GROUP BY
      E.CUSTPO) E,
    T1_LINES EL
  WHERE
    E.CUSTPO=EL.CUSTPO
    AND E.RELID=EL.RELID
    AND EL.FCDUEDATE BETWEEN SYSDATE-365 AND SYSDATE+1200
    AND EL.FCSTQTY>0) E,
  (SELECT /*+  */
    CO.CUSTOMER_PO_REF,
    MAX(COL.DESIRED_SHIP_DATE) DESIRED_SHIP_DATE,
    MAX(COL.PART_ID) PART_ID
  FROM
    T2 CO,
    T2_LINES COL
  WHERE
    CO.ID=COL.CUST_ORDER_ID
    AND CUSTOMER_PO_REF IS NOT NULL
    AND COL.DESIRED_SHIP_DATE>=SYSDATE-365
  GROUP BY
    CO.CUSTOMER_PO_REF) CO
WHERE
  E.CUSTPO=CO.CUSTOMER_PO_REF(+)
  AND E.FCDUEDATE>COALESCE(CO.DESIRED_SHIP_DATE,SYSDATE-365)
GROUP BY
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM'),
  E.FCDUEDATE
ORDER BY
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM'),
  E.FCDUEDATE;

ALTER SESSION SET EVENTS '10053 TRACE NAME CONTEXT OFF';

TRUNCATE TABLE T1_DEST;

ALTER SESSION SET OPTIMIZER_FEATURES_ENABLE='10.2.0.2';
ALTER SESSION SET TRACEFILE_IDENTIFIER = 'SELECT_10.2.0.2_80';
ALTER SESSION SET EVENTS '10053 TRACE NAME CONTEXT FOREVER, LEVEL 1';

SELECT /*+ LEADING(E) */
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM') PART_ID,
  E.FCDUEDATE REQUIRED_DATE,
  SUM(E.FCSTQTY) QTY,
  1 PLAN_LEVEL
FROM
  (SELECT /*+ LEADING(E) */
    E.CUSTPO,
    EL.FCSTQTY,
    EL.FCDUEDATE
  FROM
    (SELECT /*+ _80 */
      E.CUSTPO,
      MAX(RELID) RELID
    FROM
      T1 E
    GROUP BY
      E.CUSTPO) E,
    T1_LINES EL
  WHERE
    E.CUSTPO=EL.CUSTPO
    AND E.RELID=EL.RELID
    AND EL.FCDUEDATE BETWEEN SYSDATE-365 AND SYSDATE+1200
    AND EL.FCSTQTY>0) E,
  (SELECT /*+  */
    CO.CUSTOMER_PO_REF,
    MAX(COL.DESIRED_SHIP_DATE) DESIRED_SHIP_DATE,
    MAX(COL.PART_ID) PART_ID
  FROM
    T2 CO,
    T2_LINES COL
  WHERE
    CO.ID=COL.CUST_ORDER_ID
    AND CUSTOMER_PO_REF IS NOT NULL
    AND COL.DESIRED_SHIP_DATE>=SYSDATE-365
  GROUP BY
    CO.CUSTOMER_PO_REF) CO
WHERE
  E.CUSTPO=CO.CUSTOMER_PO_REF(+)
  AND E.FCDUEDATE>COALESCE(CO.DESIRED_SHIP_DATE,SYSDATE-365)
GROUP BY
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM'),
  E.FCDUEDATE
ORDER BY
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM'),
  E.FCDUEDATE;

ALTER SESSION SET EVENTS '10053 TRACE NAME CONTEXT OFF';

ALTER SESSION SET TRACEFILE_IDENTIFIER = 'INSERT_10.2.0.2_80';
ALTER SESSION SET EVENTS '10053 TRACE NAME CONTEXT FOREVER, LEVEL 1';

INSERT INTO T1_DEST
SELECT /*+ LEADING(E) */
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM') PART_ID,
  E.FCDUEDATE REQUIRED_DATE,
  SUM(E.FCSTQTY) QTY,
  1 PLAN_LEVEL
FROM
  (SELECT /*+ LEADING(E) */
    E.CUSTPO,
    EL.FCSTQTY,
    EL.FCDUEDATE
  FROM
    (SELECT /*+ _80 */
      E.CUSTPO,
      MAX(RELID) RELID
    FROM
      T1 E
    GROUP BY
      E.CUSTPO) E,
    T1_LINES EL
  WHERE
    E.CUSTPO=EL.CUSTPO
    AND E.RELID=EL.RELID
    AND EL.FCDUEDATE BETWEEN SYSDATE-365 AND SYSDATE+1200
    AND EL.FCSTQTY>0) E,
  (SELECT /*+  */
    CO.CUSTOMER_PO_REF,
    MAX(COL.DESIRED_SHIP_DATE) DESIRED_SHIP_DATE,
    MAX(COL.PART_ID) PART_ID
  FROM
    T2 CO,
    T2_LINES COL
  WHERE
    CO.ID=COL.CUST_ORDER_ID
    AND CUSTOMER_PO_REF IS NOT NULL
    AND COL.DESIRED_SHIP_DATE>=SYSDATE-365
  GROUP BY
    CO.CUSTOMER_PO_REF) CO
WHERE
  E.CUSTPO=CO.CUSTOMER_PO_REF(+)
  AND E.FCDUEDATE>COALESCE(CO.DESIRED_SHIP_DATE,SYSDATE-365)
GROUP BY
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM'),
  E.FCDUEDATE
ORDER BY
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM'),
  E.FCDUEDATE;

ALTER SESSION SET EVENTS '10053 TRACE NAME CONTEXT OFF';

TRUNCATE TABLE T1_DEST;

ALTER SESSION SET OPTIMIZER_FEATURES_ENABLE='11.1.0.7';
ALTER SESSION SET TRACEFILE_IDENTIFIER = 'SELECT_11.1.0.7_80';
ALTER SESSION SET EVENTS '10053 TRACE NAME CONTEXT FOREVER, LEVEL 1';

SELECT /*+ LEADING(E) */
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM') PART_ID,
  E.FCDUEDATE REQUIRED_DATE,
  SUM(E.FCSTQTY) QTY,
  1 PLAN_LEVEL
FROM
  (SELECT /*+ LEADING(E) */
    E.CUSTPO,
    EL.FCSTQTY,
    EL.FCDUEDATE
  FROM
    (SELECT /*+ _80 */
      E.CUSTPO,
      MAX(RELID) RELID
    FROM
      T1 E
    GROUP BY
      E.CUSTPO) E,
    T1_LINES EL
  WHERE
    E.CUSTPO=EL.CUSTPO
    AND E.RELID=EL.RELID
    AND EL.FCDUEDATE BETWEEN SYSDATE-365 AND SYSDATE+1200
    AND EL.FCSTQTY>0) E,
  (SELECT /*+  */
    CO.CUSTOMER_PO_REF,
    MAX(COL.DESIRED_SHIP_DATE) DESIRED_SHIP_DATE,
    MAX(COL.PART_ID) PART_ID
  FROM
    T2 CO,
    T2_LINES COL
  WHERE
    CO.ID=COL.CUST_ORDER_ID
    AND CUSTOMER_PO_REF IS NOT NULL
    AND COL.DESIRED_SHIP_DATE>=SYSDATE-365
  GROUP BY
    CO.CUSTOMER_PO_REF) CO
WHERE
  E.CUSTPO=CO.CUSTOMER_PO_REF(+)
  AND E.FCDUEDATE>COALESCE(CO.DESIRED_SHIP_DATE,SYSDATE-365)
GROUP BY
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM'),
  E.FCDUEDATE
ORDER BY
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM'),
  E.FCDUEDATE;

ALTER SESSION SET EVENTS '10053 TRACE NAME CONTEXT OFF';

ALTER SESSION SET TRACEFILE_IDENTIFIER = 'INSERT_11.1.0.7_80';
ALTER SESSION SET EVENTS '10053 TRACE NAME CONTEXT FOREVER, LEVEL 1';

INSERT INTO T1_DEST
SELECT /*+ LEADING(E) */
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM') PART_ID,
  E.FCDUEDATE REQUIRED_DATE,
  SUM(E.FCSTQTY) QTY,
  1 PLAN_LEVEL
FROM
  (SELECT /*+ LEADING(E) */
    E.CUSTPO,
    EL.FCSTQTY,
    EL.FCDUEDATE
  FROM
    (SELECT /*+ _80 */
      E.CUSTPO,
      MAX(RELID) RELID
    FROM
      T1 E
    GROUP BY
      E.CUSTPO) E,
    T1_LINES EL
  WHERE
    E.CUSTPO=EL.CUSTPO
    AND E.RELID=EL.RELID
    AND EL.FCDUEDATE BETWEEN SYSDATE-365 AND SYSDATE+1200
    AND EL.FCSTQTY>0) E,
  (SELECT /*+  */
    CO.CUSTOMER_PO_REF,
    MAX(COL.DESIRED_SHIP_DATE) DESIRED_SHIP_DATE,
    MAX(COL.PART_ID) PART_ID
  FROM
    T2 CO,
    T2_LINES COL
  WHERE
    CO.ID=COL.CUST_ORDER_ID
    AND CUSTOMER_PO_REF IS NOT NULL
    AND COL.DESIRED_SHIP_DATE>=SYSDATE-365
  GROUP BY
    CO.CUSTOMER_PO_REF) CO
WHERE
  E.CUSTPO=CO.CUSTOMER_PO_REF(+)
  AND E.FCDUEDATE>COALESCE(CO.DESIRED_SHIP_DATE,SYSDATE-365)
GROUP BY
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM'),
  E.FCDUEDATE
ORDER BY
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM'),
  E.FCDUEDATE;

ALTER SESSION SET EVENTS '10053 TRACE NAME CONTEXT OFF';

TRUNCATE TABLE T1_DEST;

ALTER SESSION SET OPTIMIZER_FEATURES_ENABLE='11.2.0.1';
ALTER SESSION SET TRACEFILE_IDENTIFIER = 'SELECT_11.2.0.1_80';
ALTER SESSION SET EVENTS '10053 TRACE NAME CONTEXT FOREVER, LEVEL 1';

SELECT /*+ LEADING(E) */
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM') PART_ID,
  E.FCDUEDATE REQUIRED_DATE,
  SUM(E.FCSTQTY) QTY,
  1 PLAN_LEVEL
FROM
  (SELECT /*+ LEADING(E) */
    E.CUSTPO,
    EL.FCSTQTY,
    EL.FCDUEDATE
  FROM
    (SELECT /*+ _80 */
      E.CUSTPO,
      MAX(RELID) RELID
    FROM
      T1 E
    GROUP BY
      E.CUSTPO) E,
    T1_LINES EL
  WHERE
    E.CUSTPO=EL.CUSTPO
    AND E.RELID=EL.RELID
    AND EL.FCDUEDATE BETWEEN SYSDATE-365 AND SYSDATE+1200
    AND EL.FCSTQTY>0) E,
  (SELECT /*+  */
    CO.CUSTOMER_PO_REF,
    MAX(COL.DESIRED_SHIP_DATE) DESIRED_SHIP_DATE,
    MAX(COL.PART_ID) PART_ID
  FROM
    T2 CO,
    T2_LINES COL
  WHERE
    CO.ID=COL.CUST_ORDER_ID
    AND CUSTOMER_PO_REF IS NOT NULL
    AND COL.DESIRED_SHIP_DATE>=SYSDATE-365
  GROUP BY
    CO.CUSTOMER_PO_REF) CO
WHERE
  E.CUSTPO=CO.CUSTOMER_PO_REF(+)
  AND E.FCDUEDATE>COALESCE(CO.DESIRED_SHIP_DATE,SYSDATE-365)
GROUP BY
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM'),
  E.FCDUEDATE
ORDER BY
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM'),
  E.FCDUEDATE;

ALTER SESSION SET EVENTS '10053 TRACE NAME CONTEXT OFF';

ALTER SESSION SET TRACEFILE_IDENTIFIER = 'INSERT_11.2.0.1_80';
ALTER SESSION SET EVENTS '10053 TRACE NAME CONTEXT FOREVER, LEVEL 1';

INSERT INTO T1_DEST
SELECT /*+ LEADING(E) */
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM') PART_ID,
  E.FCDUEDATE REQUIRED_DATE,
  SUM(E.FCSTQTY) QTY,
  1 PLAN_LEVEL
FROM
  (SELECT /*+ LEADING(E) */
    E.CUSTPO,
    EL.FCSTQTY,
    EL.FCDUEDATE
  FROM
    (SELECT /*+ _80 */
      E.CUSTPO,
      MAX(RELID) RELID
    FROM
      T1 E
    GROUP BY
      E.CUSTPO) E,
    T1_LINES EL
  WHERE
    E.CUSTPO=EL.CUSTPO
    AND E.RELID=EL.RELID
    AND EL.FCDUEDATE BETWEEN SYSDATE-365 AND SYSDATE+1200
    AND EL.FCSTQTY>0) E,
  (SELECT /*+  */
    CO.CUSTOMER_PO_REF,
    MAX(COL.DESIRED_SHIP_DATE) DESIRED_SHIP_DATE,
    MAX(COL.PART_ID) PART_ID
  FROM
    T2 CO,
    T2_LINES COL
  WHERE
    CO.ID=COL.CUST_ORDER_ID
    AND CUSTOMER_PO_REF IS NOT NULL
    AND COL.DESIRED_SHIP_DATE>=SYSDATE-365
  GROUP BY
    CO.CUSTOMER_PO_REF) CO
WHERE
  E.CUSTPO=CO.CUSTOMER_PO_REF(+)
  AND E.FCDUEDATE>COALESCE(CO.DESIRED_SHIP_DATE,SYSDATE-365)
GROUP BY
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM'),
  E.FCDUEDATE
ORDER BY
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM'),
  E.FCDUEDATE;

ALTER SESSION SET EVENTS '10053 TRACE NAME CONTEXT OFF';

SPOOL OFF

For this blog article, I decided to use the Enterprise Edition of Oracle Database 11.2.0.1, with the following manually set system (CPU) statistics (as printed in the 10053 trace files):

SYSTEM STATISTICS INFORMATION
-----------------------------
  Using WORKLOAD Stats
  CPUSPEED: 2664 millions instructions/sec
  SREADTIM: 8.000000 milliseconds
  MREADTIM: 10.000000 millisecons
  MBRC: 16 blocks
  MAXTHR: 19181568 bytes/sec
  SLAVETHR: -1 bytes/sec 

The tablespace used for the test case uses ASSM with auto-allocated extent sizes, and the following instance-wide parameters specified: 

SGA_TARGET =          12000M
PGA_AGGREGATE_TARGET = 2000M
OPTIMIZER_MODE =    ALL_ROWS

Just for fun, for now I will show you only the first two execution plans from the 10053 trace files:

SELECT_10.1.0.4 (OPTIMIZER_FEATURES_ENABLE=’10.1.0.4′, OPTIMIZER_INDEX_CACHING=0, OPTIMIZER_INDEX_COST_ADJ=100), completed in 0.23 seconds when selecting 10,478 rows:

--------------------------------------------------+-----------------------------------+
| Id  | Operation                    | Name       | Rows  | Bytes | Cost  | Time      |
--------------------------------------------------+-----------------------------------+
| 0   | SELECT STATEMENT             |            |       |       |  1425 |           |
| 1   |  SORT GROUP BY               |            |   487 |   46K |  1425 |  00:00:12 |
| 2   |   FILTER                     |            |       |       |       |           |
| 3   |    HASH JOIN RIGHT OUTER     |            |   19K | 1884K |  1423 |  00:00:12 |
| 4   |     VIEW                     |            |   700 |   27K |   368 |  00:00:03 |
| 5   |      SORT GROUP BY           |            |   700 |   40K |   368 |  00:00:03 |
| 6   |       HASH JOIN              |            |  146K | 8475K |   362 |  00:00:03 |
| 7   |        TABLE ACCESS FULL     | T2         |   700 |   18K |     3 |  00:00:01 |
| 8   |        TABLE ACCESS FULL     | T2_LINES   |  146K | 4676K |   358 |  00:00:03 |
| 9   |     NESTED LOOPS             |            |   19K | 1126K |  1055 |  00:00:09 |
| 10  |      VIEW                    |            |   700 |   14K |    65 |  00:00:01 |
| 11  |       SORT GROUP BY          |            |   700 |   18K |    65 |  00:00:01 |
| 12  |        FILTER                |            |       |       |       |           |
| 13  |         INDEX FAST FULL SCAN | T1_PK      |  106K | 2755K |    60 |  00:00:01 |
| 14  |      INDEX RANGE SCAN        | T1_LINES_PK|    28 |  1036 |     3 |  00:00:01 |
--------------------------------------------------+-----------------------------------+
Predicate Information:
----------------------
2 - filter(("EL"."FCDUEDATE">COALESCE("CO"."DESIRED_SHIP_DATE",SYSDATE@!-365) AND COALESCE("CO"."DESIRED_SHIP_DATE",SYSDATE@!-365)<SYSDATE@!+1200))
3 - access("E"."CUSTPO"="CO"."CUSTOMER_PO_REF")
6 - access("CO"."ID"="COL"."CUST_ORDER_ID")
7 - filter("CUSTOMER_PO_REF" IS NOT NULL)
8 - filter("COL"."DESIRED_SHIP_DATE">=SYSDATE@!-365)
12 - filter(SYSDATE@!-365<=SYSDATE@!+1200)
14 - access("E"."CUSTPO"="EL"."CUSTPO" AND "E"."RELID"="EL"."RELID" AND "EL"."FCDUEDATE">=SYSDATE@!-365 AND "EL"."FCSTQTY">0 AND "EL"."FCDUEDATE"<=SYSDATE@!+1200)
14 - filter("EL"."FCSTQTY">0) 

INSERT_10.1.0.4 (OPTIMIZER_FEATURES_ENABLE=’10.1.0.4′, OPTIMIZER_INDEX_CACHING=0, OPTIMIZER_INDEX_COST_ADJ=100), completed in… 30 minutes, 18.01 seconds when inserting 10,478 rows:

-------------------------------------------------+-----------------------------------+
| Id  | Operation                      | Name    | Rows  | Bytes | Cost  | Time      |
-------------------------------------------------+-----------------------------------+
| 0   | INSERT STATEMENT               |         |       |       | 4967K |           |
| 1   |  LOAD TABLE CONVENTIONAL       |         |       |       |       |           |
| 2   |   SORT GROUP BY                |         |   842 |   60K | 4967K |  11:18:11 |
| 3   |    FILTER                      |         |       |       |       |           |
| 4   |     HASH JOIN OUTER            |         |   842 |   60K | 4967K |  11:18:11 |
| 5   |      VIEW                      |         |   842 |   28K | 4967K |  11:18:08 |
| 6   |       FILTER                   |         |       |       |       |           |
| 7   |        SORT GROUP BY           |         |   842 |   53K | 4967K |  11:18:08 |
| 8   |         FILTER                 |         |       |       |       |           |
| 9   |          HASH JOIN             |         |  852M |   54G |  7035 |  00:00:57 |
| 10  |           INDEX FAST FULL SCAN | T1_PK   |  106K | 2755K |    60 |  00:00:01 |
| 11  |           TABLE ACCESS FULL    | T1_LINES| 5631K |  214M |  3388 |  00:00:28 |
| 12  |      VIEW                      |         |   700 |   27K |   368 |  00:00:03 |
| 13  |       SORT GROUP BY            |         |   700 |   40K |   368 |  00:00:03 |
| 14  |        HASH JOIN               |         |  146K | 8475K |   362 |  00:00:03 |
| 15  |         TABLE ACCESS FULL      | T2      |   700 |   18K |     3 |  00:00:01 |
| 16  |         TABLE ACCESS FULL      | T2_LINES|  146K | 4676K |   358 |  00:00:03 |
-------------------------------------------------+-----------------------------------+
Predicate Information:
----------------------
3 - filter("E"."FCDUEDATE">COALESCE("CO"."DESIRED_SHIP_DATE",SYSDATE@!-365))
4 - access("E"."CUSTPO"="CO"."CUSTOMER_PO_REF")
6 - filter("EL"."RELID"=MAX("RELID"))
8 - filter(SYSDATE@!-365<=SYSDATE@!+1200)
9 - access("E"."CUSTPO"="EL"."CUSTPO")
11 - filter(("EL"."FCDUEDATE">=SYSDATE@!-365 AND "EL"."FCDUEDATE"<=SYSDATE@!+1200 AND "EL"."FCSTQTY">0))
14 - access("CO"."ID"="COL"."CUST_ORDER_ID")
15 - filter("CUSTOMER_PO_REF" IS NOT NULL)
16 - filter("COL"."DESIRED_SHIP_DATE">=SYSDATE@!-365) 

——————-

Just one more example of the value of test cases.  By the way, make certain that the air conditioning is working well in the room where your test server is located – your test server could be swamped for a couple of hours while the table creation scripts run and the actual test script is executed.  So, what is ahead in part three of this blog article series?

(P.S. Did anyone’s test result for the first INSERT INTO statement complete in less than 30 minutes?)





SELECT Statement is Fast, INSERT INTO Using the SELECT Statement is Brutally Slow 1

15 12 2010

December 15, 2010 

(Forward to the Next Post in the Series)

I am impressed with the responses that were received from the most recent set of blog articles.  I recently encountered an interesting problem with an Oracle database that had the OPTIMIZER_FEATURES_ENABLE parameter set to 10.1.0.4 and the OPTIMIZER_MODE set to ALL_ROWS.  A somewhat complex SQL statement was written like the following, using LEADING hints to help control the join order (to work around a potential problem related to join order when inline views are used):

SELECT /*+ LEADING(E) */
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM') PART_ID,
  E.FCDUEDATE REQUIRED_DATE,
  SUM(E.FCSTQTY) QTY,
  1 PLAN_LEVEL
FROM
  (SELECT /*+ LEADING(E) */
    E.CUSTPO,
    EL.FCSTQTY,
    EL.FCDUEDATE
  FROM
    (SELECT
      E.CUSTPO,
      MAX(RELID) RELID
    FROM
      EDI830 E
    GROUP BY
      E.CUSTPO) E,
    EDI830_LINES EL
  WHERE 
    E.CUSTPO=EL.CUSTPO
    AND E.RELID=EL.RELID
    AND EL.FCDUEDATE BETWEEN SYSDATE-365 AND SYSDATE+1200
    AND EL.FCSTQTY>0) E,
  (SELECT
    CO.CUSTOMER_PO_REF,
    MAX(COL.DESIRED_SHIP_DATE) DESIRED_SHIP_DATE,
    MAX(COL.PART_ID) PART_ID
  FROM
    CUSTOMER_ORDER CO,
    CUST_ORDER_LINE COL
  WHERE
    CO.ID=COL.CUST_ORDER_ID
    AND CUSTOMER_PO_REF IS NOT NULL
    AND COL.DESIRED_SHIP_DATE>=SYSDATE-365
  GROUP BY
    CO.CUSTOMER_PO_REF) CO
WHERE
  E.CUSTPO=CO.CUSTOMER_PO_REF(+)
  AND E.FCDUEDATE>COALESCE(CO.DESIRED_SHIP_DATE,SYSDATE-365)
GROUP BY
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM'),
  E.FCDUEDATE
ORDER BY
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM'),
  E.FCDUEDATE; 

The above query executes very quickly (a second or less), and the execution plan for the above query looks like this:

Execution Plan
----------------------------------------------------------
Plan hash value: 3426513411

-----------------------------------------------------------------------------------------------
| Id  | Operation                   | Name            | Rows  | Bytes | Cost (%CPU)| Time     |
-----------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT            |                 |   205 | 17425 |   157  (21)| 00:00:01 |
|   1 |  SORT GROUP BY              |                 |   205 | 17425 |   157  (21)| 00:00:01 |
|*  2 |   FILTER                    |                 |       |       |            |          |
|*  3 |    HASH JOIN OUTER          |                 |   384 | 32640 |   156  (20)| 00:00:01 |
|   4 |     NESTED LOOPS            |                 |   194 |  9506 |    47  (35)| 00:00:01 |
|   5 |      VIEW                   |                 |  1993 | 35874 |    46  (35)| 00:00:01 |
|   6 |       SORT GROUP BY         |                 |  1993 | 39860 |    46  (35)| 00:00:01 |
|*  7 |        FILTER               |                 |       |       |            |          |
|   8 |         INDEX FAST FULL SCAN| EDI830_PK       |   107K|  2092K|    33  (10)| 00:00:01 |
|*  9 |      INDEX RANGE SCAN       | EDI830_LINES_PK |     1 |    31 |     1   (0)| 00:00:01 |
|  10 |     VIEW                    |                 |  6254 |   219K|   108  (13)| 00:00:01 |
|  11 |      SORT GROUP BY          |                 |  6254 |   250K|   108  (13)| 00:00:01 |
|* 12 |       HASH JOIN             |                 |  8213 |   328K|   106  (12)| 00:00:01 |
|* 13 |        TABLE ACCESS FULL    | CUSTOMER_ORDER  |  7554 |   125K|    14   (8)| 00:00:01 |
|* 14 |        TABLE ACCESS FULL    | CUST_ORDER_LINE |  8582 |   201K|    92  (12)| 00:00:01 |
-----------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------
   2 - filter("EL"."FCDUEDATE">COALESCE("CO"."DESIRED_SHIP_DATE",SYSDATE@!-365) AND
              COALESCE("CO"."DESIRED_SHIP_DATE",SYSDATE@!-365)<SYSDATE@!+1200)
   3 - access("E"."CUSTPO"="CO"."CUSTOMER_PO_REF"(+))
   7 - filter(SYSDATE@!-365<=SYSDATE@!+1200)
   9 - access("E"."CUSTPO"="EL"."CUSTPO" AND "E"."RELID"="EL"."RELID" AND
              "EL"."FCDUEDATE">=SYSDATE@!-365 AND "EL"."FCSTQTY">0 AND
              "EL"."FCDUEDATE"<=SYSDATE@!+1200)
       filter("EL"."FCSTQTY">0)
  12 - access("CO"."ID"="COL"."CUST_ORDER_ID")
  13 - filter("CUSTOMER_PO_REF" IS NOT NULL)
  14 - filter("COL"."DESIRED_SHIP_DATE">=SYSDATE@!-365) 

Now, assume that we have a very simple table that currently contains no rows (the table was TRUNCATEd) and no indexes, and we would like to insert the rows returned by the above SQL statement into the table:

INSERT INTO
  T1
SELECT /*+ LEADING(E) */
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM') PART_ID,
...
ORDER BY
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM'),
  E.FCDUEDATE; 

The INSERT INTO SQL statement required 20 to 30 minutes to complete.  Using SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY_CURSOR(NULL,NULL,’TYPICAL’)); the following execution plan is displayed:

--------------------------------------------------------------------------------------------------------
| Id  | Operation                    | Name            | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
--------------------------------------------------------------------------------------------------------
|   0 | INSERT STATEMENT             |                 |       |       |       |   279K(100)|          |
|   1 |  SORT GROUP BY               |                 |   205 | 13735 |       |   279K  (9)| 00:22:11 |
|*  2 |   FILTER                     |                 |       |       |       |            |          |
|   3 |    MERGE JOIN OUTER          |                 | 81363 |  5323K|       |   279K  (9)| 00:22:11 |
|   4 |     VIEW                     |                 | 70658 |  2139K|       |   279K  (9)| 00:22:10 |
|*  5 |      FILTER                  |                 |       |       |       |            |          |
|   6 |       SORT GROUP BY          |                 | 70658 |  3519K|  7169M|   279K  (9)| 00:22:10 |
|*  7 |        FILTER                |                 |       |       |       |            |          |
|*  8 |         HASH JOIN            |                 |   109M|  5343M|  3352K|   1154 (30)| 00:00:06 |
|   9 |          INDEX FAST FULL SCAN| EDI830_PK       |   107K|  2092K|       |     33 (10)| 00:00:01 |
|* 10 |          TABLE ACCESS FULL   | EDI830_LINES    |   242K|  7334K|       |    941 (35)| 00:00:05 |
|* 11 |     SORT JOIN                |                 |  6254 |   219K|       |    110 (15)| 00:00:01 |
|  12 |      VIEW                    |                 |  6254 |   219K|       |    108 (13)| 00:00:01 |
|  13 |       SORT GROUP BY          |                 |  6254 |   250K|       |    108 (13)| 00:00:01 |
|* 14 |        HASH JOIN             |                 |  8213 |   328K|       |    106 (12)| 00:00:01 |
|* 15 |         TABLE ACCESS FULL    | CUSTOMER_ORDER  |  7554 |   125K|       |     14  (8)| 00:00:01 |
|* 16 |         TABLE ACCESS FULL    | CUST_ORDER_LINE |  8582 |   201K|       |     92 (12)| 00:00:01 |
--------------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
   2 - filter("E"."FCDUEDATE">COALESCE("CO"."DESIRED_SHIP_DATE",SYSDATE@!-365))
   5 - filter("EL"."RELID"=MAX("RELID"))
   7 - filter(SYSDATE@!-365<=SYSDATE@!+1200)
   8 - access("E"."CUSTPO"="EL"."CUSTPO")
  10 - filter(("EL"."FCDUEDATE">=SYSDATE@!-365 AND "EL"."FCSTQTY">0 AND
       "EL"."FCDUEDATE"<=SYSDATE@!+1200))
  11 - access("E"."CUSTPO"="CO"."CUSTOMER_PO_REF")
       filter("E"."CUSTPO"="CO"."CUSTOMER_PO_REF")
  14 - access("CO"."ID"="COL"."CUST_ORDER_ID")
  15 - filter("CUSTOMER_PO_REF" IS NOT NULL)
  16 - filter("COL"."DESIRED_SHIP_DATE">=SYSDATE@!-365) 

What happened, how would you investigate the problem, and how would you correct the problem?  Think about that for a couple of minutes before scrolling down.

Assume that I was able to obtain an execution plan for the INSERT INTO SQL statement that looked like this:

-------------------------------------------------------+-----------------------------------+
| Id  | Operation                     | Name           | Rows  | Bytes | Cost  | Time      |
-------------------------------------------------------+-----------------------------------+
| 0   | INSERT STATEMENT              |                |       |       |   157 |           |
| 1   |  SORT GROUP BY                |                |   194 |   13K |   157 |  00:00:01 |
| 2   |   FILTER                      |                |       |       |       |           |
| 3   |    HASH JOIN OUTER            |                |   223 |   15K |   156 |  00:00:01 |
| 4   |     VIEW                      |                |   194 |  6014 |    47 |  00:00:01 |
| 5   |      NESTED LOOPS             |                |   194 |  9118 |    47 |  00:00:01 |
| 6   |       VIEW                    |                |  1993 |   31K |    46 |  00:00:01 |
| 7   |        SORT GROUP BY          |                |  1993 |   39K |    46 |  00:00:01 |
| 8   |         FILTER                |                |       |       |       |           |
| 9   |          INDEX FAST FULL SCAN | EDI830_PK      |  105K | 2092K |    33 |  00:00:01 |
| 10  |       INDEX RANGE SCAN        | EDI830_LINES_PK|     1 |    31 |     1 |  00:00:01 |
| 11  |     VIEW                      |                |  6254 |  220K |   108 |  00:00:01 |
| 12  |      SORT GROUP BY            |                |  6254 |  250K |   108 |  00:00:01 |
| 13  |       HASH JOIN               |                |  8213 |  329K |   106 |  00:00:01 |
| 14  |        TABLE ACCESS FULL      | CUSTOMER_ORDER |  7554 |  125K |    14 |  00:00:01 |
| 15  |        TABLE ACCESS FULL      | CUST_ORDER_LINE|  8582 |  201K |    92 |  00:00:01 |
-------------------------------------------------------+-----------------------------------+
Predicate Information:
----------------------
2 - filter("E"."FCDUEDATE">COALESCE("CO"."DESIRED_SHIP_DATE",SYSDATE@!-365))
3 - access("E"."CUSTPO"="CO"."CUSTOMER_PO_REF")
8 - filter(SYSDATE@!-365<=SYSDATE@!+1200)
10 - access("E"."CUSTPO"="EL"."CUSTPO" AND "E"."RELID"="EL"."RELID" AND "EL"."FCDUEDATE">=SYSDATE@!-365 AND "EL"."FCSTQTY">0 AND "EL"."FCDUEDATE"<=SYSDATE@!+1200)
10 - filter("EL"."FCSTQTY">0)
13 - access("CO"."ID"="COL"."CUST_ORDER_ID")
14 - filter("CUSTOMER_PO_REF" IS NOT NULL)
15 - filter("COL"."DESIRED_SHIP_DATE">=SYSDATE@!-365) 

Using the above execution plan, the INSERT INTO SQL statement completed in about a second (or less).  What did I do to fix the problem?

———

Here is what the sections of the query are intended to accomplish:

On a daily basis the header rows for custom order forecasts are inserted into the EDI830 table, and each order may be revised multiple times (possibly once a day or once a week), each time bumping the RELID value up by 1 or 2 (RELID is a zero padded number stored in a VARCHAR2 column).  This part of the query retrieves the most recent release number for each of the customer POs so that we are able to return the line item detail for the most recent customer order forecast release:

    (SELECT
      E.CUSTPO,
      MAX(RELID) RELID
    FROM
      EDI830 E
    GROUP BY
      E.CUSTPO) E 

Join the above inline view to the line item detail, with restrictions so that we do not look at releases from more than a year ago.  The LEADING hint is used to make certain that the optimizer first returns the rows from the EDI830 table before accessing the EDI830_LINES table (there is a chance that the optimizer will access the EDI830_LINES table first before returning the rows from the inline view):

  (SELECT /*+ LEADING(E) */
    E.CUSTPO,
    EL.FCSTQTY,
    EL.FCDUEDATE
  FROM
    (SELECT
      E.CUSTPO,
      MAX(RELID) RELID
    FROM
      EDI830 E
    GROUP BY
      E.CUSTPO) E,
    EDI830_LINES EL
  WHERE 
    E.CUSTPO=EL.CUSTPO
    AND E.RELID=EL.RELID
    AND EL.FCDUEDATE BETWEEN SYSDATE-365 AND SYSDATE+1200
    AND EL.FCSTQTY>0) E 

The goal of the following subquery is to return the ship date of the last order line that made it into the order entry system for each of the customer POs.  This subquery will allow us to determine which of the rows in the most recent EDI release are beyond the last firmed customer order line in the system (typically, only the firmed EDI release lines are brought into the CUST_ORDER_LINE table):

  (SELECT
    CO.CUSTOMER_PO_REF,
    MAX(COL.DESIRED_SHIP_DATE) DESIRED_SHIP_DATE,
    MAX(COL.PART_ID) PART_ID
  FROM
    CUSTOMER_ORDER CO,
    CUST_ORDER_LINE COL
  WHERE
    CO.ID=COL.CUST_ORDER_ID
    AND CUSTOMER_PO_REF IS NOT NULL
    AND COL.DESIRED_SHIP_DATE>=SYSDATE-365
  GROUP BY
    CO.CUSTOMER_PO_REF) CO

The outer-most portion of the SQL statement joins the two inline views together, using a LEADING hint to make certain that the EDI release rows are retrieved before accessing the CUSTOMER_ORDER and CUST_ORDER_LINE tables (even with the outer join, it is possible that those tables might be accessed first):

SELECT /*+ LEADING(E) */
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM') PART_ID,
  E.FCDUEDATE REQUIRED_DATE,
  SUM(E.FCSTQTY) QTY,
  1 PLAN_LEVEL
FROM
...
  GROUP BY
    CO.CUSTOMER_PO_REF) CO
WHERE
  E.CUSTPO=CO.CUSTOMER_PO_REF(+)
  AND E.FCDUEDATE>COALESCE(CO.DESIRED_SHIP_DATE,SYSDATE-365)
GROUP BY
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM'),
  E.FCDUEDATE
ORDER BY
  COALESCE(CO.PART_ID,'NOT-IN-SYSTEM'),
  E.FCDUEDATE;  

What happened?  What process would you use to investigate the performance problem?  How would you resolve this performance problem.

If you tell me to buy a bigger server, I will simply tell you to read a different book.  :-)





Different Performance from Standard Edition and Enterprise Edition? 4

24 11 2010

November 24, 2010

(Back to the Previous Post in the Series)

The previous articles in this series showed potential differences in performance between the Enterprise Edition of Oracle Database and the Standard Edition, as well as changes from release 10.2.0.5 to 11.2.0.1 for the same edition, even when the execution plans appeared to be the same.  The queries in the earlier articles were quite simple, yet demonstrated some of the types of problems that could be encountered if the servers used for the development or test do not use the same release version or edition as the production database, or even if the workload system (CPU) statistics differ.

Today’s blog article builds a more complicated test case – if you decide to try the test case, be prepared to spend between one and three hours building the test tables.  The tables that are constructed by the script are intended to model a portion of the data model employed by an ERP package, complete with foreign key constraints and regular check constraints.  The test script includes queries that are intended to answer questions that might be posed by a user of the ERP package, although the generated, reproducible test data likely does not match what would be found in a typical ERP application.  It might also be interesting to see how the different release versions and editions behave when pummeled by database agnostic code that might be found in certain applications – I wondr if that might be a topic for a future blog article.

Before we start, the commands to drop the generated tables and indexes are listed below - if you have any tables with these names in your database (schema), you probably do not want to execute the scripts in this blog article:

DROP TABLE PO_LINE PURGE;
DROP TABLE PO_HEADER PURGE;
DROP TABLE PO_LINE_TEMP PURGE;
DROP TABLE PO_HEADER_TEMP PURGE;
DROP TABLE PARTS PURGE;
DROP TABLE PARTS_TEMP PURGE;
DROP TABLE VENDORS PURGE;
DROP TABLE VENDORS_TEMP PURGE;
DROP TABLE LOCATIONS PURGE;
DROP TABLE UMS PURGE;

DROP INDEX IND_LOCATIONS_1;
DROP INDEX IND_PARTS_1;
DROP INDEX IND_PARTS_2;
DROP INDEX IND_PARTS_3;
DROP INDEX IND_PARTS_4;
DROP INDEX IND_PARTS_5;
DROP INDEX IND_PARTS_6;
DROP INDEX IND_PARTS_7;
DROP INDEX IND_PO_HEADER_1;
DROP INDEX IND_PO_HEADER_2;
DROP INDEX IND_PO_HEADER_3;
DROP INDEX IND_PO_HEADER_4;
DROP INDEX IND_PO_LINE_1;
DROP INDEX IND_PO_LINE_2;
DROP INDEX IND_PO_LINE_3;
DROP INDEX IND_PO_LINE_4;

As in the earlier blog articles, the following system (CPU) statistics will be used in all of the databases:

EXEC DBMS_STATS.SET_SYSTEM_STATS('MBRC',16)
EXEC DBMS_STATS.SET_SYSTEM_STATS('CPUSPEED',2664)
EXEC DBMS_STATS.SET_SYSTEM_STATS('SREADTIM',8)
EXEC DBMS_STATS.SET_SYSTEM_STATS('MREADTIM',10)
EXEC DBMS_STATS.SET_SYSTEM_STATS('MAXTHR',19181568) 

The initial table setup script follows, expect this script to take one to three hours to complete.  A 10053 and 10046 trace will be enabled, just to see if we receive different performance behavior from the four databases.  The defaults for table and index statistics collection will be used in the script, the SGA_TARGET will be set to 8000M, and the PGA_AGGREGATE_TARGET will be set to 1800M for the test runs.  (The redo logs were left at the default of 50MB in the 10.2.0.5 Standard Edition Database, while the other databases had five 512MB redo logs – this will affect the results of this script that are displayed later in this article.  Archiving of redo logs was disabled in all databases.)

SET ARRAYSIZE 1000

ALTER SESSION SET TRACEFILE_IDENTIFIER = 'CREATE_TABLES';
ALTER SESSION SET EVENTS '10053 TRACE NAME CONTEXT FOREVER, LEVEL 1';
ALTER SESSION SET EVENTS '10046 TRACE NAME CONTEXT FOREVER, LEVEL 8';

CREATE TABLE LOCATIONS(
  LOCATION_ID VARCHAR2(15) NOT NULL ENABLE,
  WAREHOUSE_ID VARCHAR2(15) NOT NULL ENABLE,
  DESCRIPTION VARCHAR2(80),
  LOCATION_TYPE CHAR(1) NOT NULL ENABLE,
  CONSTRAINT "CHK_LOCATIONS" CHECK (
    (LOCATION_TYPE = 'T' Or LOCATION_TYPE = 'R' Or LOCATION_TYPE = 'F')) ENABLE,
  PRIMARY KEY (WAREHOUSE_ID, LOCATION_ID));

CREATE INDEX IND_LOCATIONS_1 ON LOCATIONS (LOCATION_ID);

CREATE TABLE UMS (
  UNIT_OF_MEASURE VARCHAR2(15) NOT NULL ENABLE,
  DESCRIPTION VARCHAR2(40),
  UOM_SCALE NUMBER NOT NULL ENABLE,
  CONSTRAINT "CHK_UOM_SCALE" CHECK (
    (UOM_SCALE >= 0 And UOM_SCALE <= 4)) ENABLE,
  PRIMARY KEY ("UNIT_OF_MEASURE"));

CREATE TABLE VENDORS (
  VENDOR_ID VARCHAR2(15) NOT NULL ENABLE,
  VENDOR_NAME VARCHAR2(50),
  ADDR_1 VARCHAR2(50),
  ADDR_2 VARCHAR2(50),
  ADDR_3 VARCHAR2(50),
  CITY VARCHAR2(30),
  STATE VARCHAR2(10),
  ZIPCODE VARCHAR2(10),
  COUNTRY VARCHAR2(50),
  CONTACT_FIRST_NAME VARCHAR2(30),
  CONTACT_LAST_NAME VARCHAR2(30),
  CONTACT_INITIAL VARCHAR2(2),
  CONTACT_POSITION VARCHAR2(20),
  CONTACT_HONORIFIC VARCHAR2(4),
  CONTACT_SALUTATION VARCHAR2(60),
  CONTACT_PHONE VARCHAR2(20),
  CONTACT_FAX VARCHAR2(20),
  REMIT_TO_NAME VARCHAR2(50),
  REMIT_TO_ADDR_1 VARCHAR2(50),
  REMIT_TO_ADDR_2 VARCHAR2(50),
  REMIT_TO_ADDR_3 VARCHAR2(50),
  REMIT_TO_CITY VARCHAR2(30),
  REMIT_TO_STATE VARCHAR2(10),
  REMIT_TO_ZIPCODE VARCHAR2(10),
  REMIT_TO_COUNTRY VARCHAR2(50),
  FREE_ON_BOARD VARCHAR2(25),
  SHIP_VIA VARCHAR2(40),
  BUYER VARCHAR2(15),
  REPORT_1099_MISC CHAR(1) DEFAULT 'N' NOT NULL ENABLE,
  TERMS_NET_TYPE CHAR(1) DEFAULT ' ' NOT NULL ENABLE,
  TERMS_NET_DAYS NUMBER,
  TERMS_NET_DATE DATE,
  TERMS_DISC_TYPE CHAR(1) DEFAULT ' ' NOT NULL ENABLE,
  TERMS_DISC_DAYS NUMBER,
  TERMS_DISC_DATE DATE,
  TERMS_DISC_PERCENT NUMBER(5,3),
  TERMS_DESCRIPTION VARCHAR2(50),
  USER_1 VARCHAR2(80),
  USER_2 VARCHAR2(80),
  USER_3 VARCHAR2(80),
  USER_4 VARCHAR2(80),
  USER_5 VARCHAR2(80),
  USER_6 VARCHAR2(80),
  USER_7 VARCHAR2(80),
  USER_8 VARCHAR2(80),
  USER_9 VARCHAR2(80),
  USER_10 VARCHAR2(80),
  CONSTRAINT "CHK_VENDORS" CHECK (
    (REPORT_1099_MISC = 'Y' Or REPORT_1099_MISC = 'N')
    AND (TERMS_NET_TYPE = 'A'
      Or TERMS_NET_TYPE = 'M'
      Or TERMS_NET_TYPE = 'D'
      Or TERMS_NET_TYPE = 'N'
      Or TERMS_NET_TYPE = 'E')
    AND (TERMS_DISC_TYPE = 'A'
      Or TERMS_DISC_TYPE = 'M'
      Or TERMS_DISC_TYPE = 'D'
      Or TERMS_DISC_TYPE = 'N'
      Or TERMS_DISC_TYPE = 'E')) ENABLE,
  PRIMARY KEY (VENDOR_ID));

CREATE TABLE VENDORS_TEMP AS
SELECT
  *
FROM
  VENDORS;

CREATE TABLE PARTS (
  PART_ID VARCHAR2(30) NOT NULL ENABLE,
  DESCRIPTION VARCHAR2(40),
  STOCK_UM VARCHAR2(15) NOT NULL ENABLE,
  PLANNING_LEADTIME NUMBER DEFAULT 0 NOT NULL ENABLE,
  ORDER_POLICY CHAR(1) DEFAULT 'M' NOT NULL ENABLE,
  ORDER_POINT NUMBER(14,4),
  SAFETY_STOCK_QTY NUMBER(14,4),
  FIXED_ORDER_QTY NUMBER(14,4),
  DAYS_OF_SUPPLY NUMBER,
  MINIMUM_ORDER_QTY NUMBER(14,4),
  MAXIMUM_ORDER_QTY NUMBER(14,4),
  ENGINEERING_MSTR VARCHAR2(3),
  PRODUCT_CODE VARCHAR2(15),
  COMMODITY_CODE VARCHAR2(15),
  MFG_NAME VARCHAR2(30),
  MFG_PART_ID VARCHAR2(30),
  FABRICATED CHAR(1) DEFAULT 'N' NOT NULL ENABLE,
  PURCHASED CHAR(1) DEFAULT 'Y' NOT NULL ENABLE,
  STOCKED CHAR(1) DEFAULT 'N' NOT NULL ENABLE,
  DETAIL_ONLY CHAR(1) DEFAULT 'N' NOT NULL ENABLE,
  DEMAND_HISTORY CHAR(1) DEFAULT 'N' NOT NULL ENABLE,
  TOOL_OR_FIXTURE CHAR(1) DEFAULT 'N' NOT NULL ENABLE,
  INSPECTION_REQD CHAR(1) DEFAULT 'N' NOT NULL ENABLE,
  WEIGHT NUMBER(14,4),
  WEIGHT_UM VARCHAR2(15),
  DRAWING_ID VARCHAR2(15),
  DRAWING_REV_NO VARCHAR2(8),
  PREF_VENDOR_ID VARCHAR2(15),
  PRIMARY_WHS_ID VARCHAR2(15),
  PRIMARY_LOC_ID VARCHAR2(15),
  BACKFLUSH_WHS_ID VARCHAR2(15),
  BACKFLUSH_LOC_ID VARCHAR2(15),
  INSPECT_WHS_ID VARCHAR2(15),
  INSPECT_LOC_ID VARCHAR2(15),
  MRP_REQUIRED CHAR(1) DEFAULT 'N',
  MRP_EXCEPTIONS CHAR(1) DEFAULT 'N',
  PRIVATE_UM_CONV CHAR(1) DEFAULT 'N',
  AUTO_BACKFLUSH CHAR(1) DEFAULT 'Y',
  PLANNER_USER_ID VARCHAR2(20),
  BUYER_USER_ID VARCHAR2(20),
  ABC_CODE CHAR(1),
  ANNUAL_USAGE_QTY NUMBER(15,4),
  INVENTORY_LOCKED CHAR(1) DEFAULT 'N' NOT NULL ENABLE,
  UNIT_MATERIAL_COST NUMBER(20,6) DEFAULT 0 NOT NULL ENABLE,
  UNIT_LABOR_COST NUMBER(20,6) DEFAULT 0 NOT NULL ENABLE,
  UNIT_BURDEN_COST NUMBER(20,6) DEFAULT 0 NOT NULL ENABLE,
  UNIT_SERVICE_COST NUMBER(20,6) DEFAULT 0 NOT NULL ENABLE,
  BURDEN_PERCENT NUMBER(5,2) DEFAULT 0 NOT NULL ENABLE,
  BURDEN_PER_UNIT NUMBER(20,6) DEFAULT 0 NOT NULL ENABLE,
  PURC_BUR_PERCENT NUMBER(6,3) DEFAULT 0 NOT NULL ENABLE,
  PURC_BUR_PER_UNIT NUMBER(20,6) DEFAULT 0 NOT NULL ENABLE,
  FIXED_COST NUMBER(15,2) DEFAULT 0 NOT NULL ENABLE,
  UNIT_PRICE NUMBER(20,6),
  NEW_MATERIAL_COST NUMBER(14,4) DEFAULT 0 NOT NULL ENABLE,
  NEW_LABOR_COST NUMBER(14,4) DEFAULT 0 NOT NULL ENABLE,
  NEW_BURDEN_COST NUMBER(14,4) DEFAULT 0 NOT NULL ENABLE,
  NEW_SERVICE_COST NUMBER(14,4) DEFAULT 0 NOT NULL ENABLE,
  NEW_BURDEN_PERCENT NUMBER(5,2) DEFAULT 0 NOT NULL ENABLE,
  NEW_BURDEN_PERUNIT NUMBER(20,6) DEFAULT 0 NOT NULL ENABLE,
  NEW_FIXED_COST NUMBER(15,2) DEFAULT 0 NOT NULL ENABLE,
  MAT_GL_ACCT_ID VARCHAR2(30),
  LAB_GL_ACCT_ID VARCHAR2(30),
  BUR_GL_ACCT_ID VARCHAR2(30),
  SER_GL_ACCT_ID VARCHAR2(30),
  QTY_ON_HAND NUMBER(14,4) DEFAULT 0 NOT NULL ENABLE,
  QTY_AVAILABLE_ISS NUMBER(14,4) DEFAULT 0 NOT NULL ENABLE,
  QTY_AVAILABLE_MRP NUMBER(14,4) DEFAULT 0 NOT NULL ENABLE,
  QTY_ON_ORDER NUMBER(14,4) DEFAULT 0 NOT NULL ENABLE,
  QTY_IN_DEMAND NUMBER(14,4) DEFAULT 0 NOT NULL ENABLE,
  USER_1 VARCHAR2(80),
  USER_2 VARCHAR2(80),
  USER_3 VARCHAR2(80),
  USER_4 VARCHAR2(80),
  USER_5 VARCHAR2(80),
  USER_6 VARCHAR2(80),
  USER_7 VARCHAR2(80),
  USER_8 VARCHAR2(80),
  USER_9 VARCHAR2(80),
  USER_10 VARCHAR2(80),
  LT_PLUS_DAYS NUMBER,
  LT_MINUS_DAYS NUMBER,
  STATUS CHAR(1),
  USE_SUPPLY_BEF_LT CHAR(1),
  QTY_COMMITTED NUMBER(14,4) DEFAULT 0 NOT NULL ENABLE,
  PRT_CREATE_USER_ID VARCHAR2(30) DEFAULT USER,
  PRT_CREATE_DATE DATE DEFAULT SYSDATE,
  CONSTRAINT "CHK_PART1" CHECK (
    (PLANNING_LEADTIME >= 0)
    AND (ORDER_POLICY = 'N'
      Or ORDER_POLICY = 'M'
      Or ORDER_POLICY = 'F'
      Or ORDER_POLICY = 'E'
      Or ORDER_POLICY = 'D'
      Or ORDER_POLICY = 'P')
    AND (ORDER_POINT >= 0)
    AND (SAFETY_STOCK_QTY >= 0)
    AND (FIXED_ORDER_QTY >= 0)
    AND (DAYS_OF_SUPPLY >= 0)
    AND (MINIMUM_ORDER_QTY >= 0)
    AND (MAXIMUM_ORDER_QTY >= 0)
    AND (FABRICATED = 'Y' Or FABRICATED = 'N')
    AND (PURCHASED = 'Y' Or PURCHASED = 'N')
    AND (STOCKED = 'Y' Or STOCKED = 'N')
    AND (DETAIL_ONLY = 'Y' Or DETAIL_ONLY = 'N')
    AND (DEMAND_HISTORY = 'Y' Or DEMAND_HISTORY = 'N')
    AND (TOOL_OR_FIXTURE = 'Y' Or TOOL_OR_FIXTURE = 'N')
    AND (MRP_REQUIRED = 'Y' Or MRP_REQUIRED = 'N')
    AND (MRP_EXCEPTIONS = 'Y' Or MRP_EXCEPTIONS = 'N')
    AND (PRIVATE_UM_CONV = 'Y' Or PRIVATE_UM_CONV = 'N')
    AND (INVENTORY_LOCKED = 'Y' Or INVENTORY_LOCKED = 'N')
    AND (INSPECTION_REQD = 'Y' Or INSPECTION_REQD = 'N')) ENABLE,
  PRIMARY KEY (PART_ID),
  CONSTRAINT "FKEY_INSP" FOREIGN KEY (INSPECT_WHS_ID, INSPECT_LOC_ID)
    REFERENCES LOCATIONS (WAREHOUSE_ID, LOCATION_ID) ENABLE,
  CONSTRAINT "FKEY_PREF_VENDOR" FOREIGN KEY (PREF_VENDOR_ID)
    REFERENCES VENDORS (VENDOR_ID) ENABLE,
  CONSTRAINT "FKEY_UM" FOREIGN KEY (WEIGHT_UM)
    REFERENCES UMS (UNIT_OF_MEASURE) ENABLE,
  CONSTRAINT "FKEY_STOCK_UM" FOREIGN KEY (STOCK_UM)
    REFERENCES UMS (UNIT_OF_MEASURE) ENABLE);

CREATE INDEX IND_PARTS_1 ON PARTS (MRP_EXCEPTIONS);
CREATE INDEX IND_PARTS_2 ON PARTS (MFG_NAME, MFG_PART_ID);
CREATE INDEX IND_PARTS_3 ON PARTS (WEIGHT_UM);
CREATE INDEX IND_PARTS_4 ON PARTS (MRP_REQUIRED);
CREATE INDEX IND_PARTS_5 ON PARTS (PREF_VENDOR_ID);
CREATE INDEX IND_PARTS_6 ON PARTS (STOCK_UM);
CREATE INDEX IND_PARTS_7 ON PARTS (ORDER_POINT);

CREATE TABLE PARTS_TEMP AS
SELECT
  *
FROM
  PARTS;

CREATE TABLE PO_HEADER (
  PURC_ORDER_ID VARCHAR2(15) NOT NULL ENABLE,
  VENDOR_ID VARCHAR2(15) NOT NULL ENABLE,
  CONTACT_FIRST_NAME VARCHAR2(30),
  CONTACT_LAST_NAME VARCHAR2(30),
  CONTACT_INITIAL VARCHAR2(2),
  CONTACT_POSITION VARCHAR2(20),
  CONTACT_HONORIFIC VARCHAR2(4),
  CONTACT_SALUTATION VARCHAR2(60),
  CONTACT_PHONE VARCHAR2(20),
  CONTACT_FAX VARCHAR2(20),
  PURC_ORD_ADDR_NO NUMBER,
  SHIPTO_ADDR_NO NUMBER,
  ORDER_DATE DATE DEFAULT SYSDATE NOT NULL ENABLE,
  DESIRED_RECV_DATE DATE DEFAULT TRUNC(SYSDATE),
  BUYER VARCHAR2(15),
  FREE_ON_BOARD VARCHAR2(25),
  SHIP_VIA VARCHAR2(40),
  SALES_TAX_GROUP_ID VARCHAR2(15),
  PO_STATUS CHAR(1) DEFAULT ' ' NOT NULL ENABLE,
  BACK_ORDER CHAR(1) DEFAULT ' ' NOT NULL ENABLE,
  SELL_RATE NUMBER(15,8) NOT NULL ENABLE,
  BUY_RATE NUMBER(15,8) NOT NULL ENABLE,
  ENTITY_ID VARCHAR2(5) NOT NULL ENABLE,
  POSTING_CANDIDATE CHAR(1) DEFAULT 'Y' NOT NULL ENABLE,
  LAST_RECEIVED_DATE DATE,
  TOTAL_AMT_ORDERED NUMBER(15,2) DEFAULT 0 NOT NULL ENABLE,
  TOTAL_AMT_RECVD NUMBER(15,2) DEFAULT 0 NOT NULL ENABLE,
  MARKED_FOR_PURGE CHAR(1) DEFAULT 'N' NOT NULL ENABLE,
  EXCH_RATE_FIXED CHAR(1) DEFAULT 'N' NOT NULL ENABLE,
  PROMISE_DATE DATE,
  PRINTED_DATE DATE,
  TERMS_DISC_TYPE CHAR(1),
  EDI_BLANKET_FLAG CHAR(1),
  EDI_BLANKET_PO_NO VARCHAR2(30),
  CONTRACT_ID VARCHAR2(30),
  SHIPTO_ID VARCHAR2(20),
  TERMS_NET_TYPE CHAR(1) DEFAULT ' ' NOT NULL ENABLE,
  TERMS_NET_DAYS NUMBER,
  TERMS_NET_DATE DATE,
  TERMS_DISC_DAYS NUMBER,
  TERMS_DISC_DATE DATE,
  TERMS_DISC_PERCENT NUMBER(5,3),
  TERMS_DESCRIPTION VARCHAR2(50),
  CURRENCY_ID VARCHAR2(15),
  WAREHOUSE_ID VARCHAR2(15),
  CREATE_DATE DATE DEFAULT SYSDATE NOT NULL ENABLE,
  CONTACT_MOBILE VARCHAR2(20),
  CONTACT_EMAIL VARCHAR2(50),
  USER_1 VARCHAR2(80),
  USER_2 VARCHAR2(80),
  USER_3 VARCHAR2(80),
  USER_4 VARCHAR2(80),
  USER_5 VARCHAR2(80),
  USER_6 VARCHAR2(80),
  USER_7 VARCHAR2(80),
  USER_8 VARCHAR2(80),
  USER_9 VARCHAR2(80),
  USER_10 VARCHAR2(80),
  UDF_LAYOUT_ID VARCHAR2(15),
  PO_CREATE_USER_ID VARCHAR2(30) DEFAULT USER,
  CONSTRAINT "CHK_PO" CHECK (
    (PO_STATUS = 'F' Or PO_STATUS = 'R' Or PO_STATUS = 'C' Or PO_STATUS = 'X')
    AND (BACK_ORDER = 'Y' Or BACK_ORDER = 'N')
    AND (POSTING_CANDIDATE = 'Y' Or POSTING_CANDIDATE = 'N')
    AND (MARKED_FOR_PURGE = 'Y' Or MARKED_FOR_PURGE = 'N')
    AND (TERMS_DISC_TYPE = 'A' Or TERMS_DISC_TYPE = 'M' Or TERMS_DISC_TYPE = 'D' Or TERMS_DISC_TYPE = 'N' Or TERMS_DISC_TYPE = 'E')
    AND (TERMS_NET_TYPE = 'A' Or TERMS_NET_TYPE = 'M' Or TERMS_NET_TYPE = 'D' Or TERMS_NET_TYPE = 'N' Or TERMS_NET_TYPE = 'E')) ENABLE,
  PRIMARY KEY (PURC_ORDER_ID));

CREATE INDEX IND_PO_HEADER_1 ON PO_HEADER (VENDOR_ID, PURC_ORD_ADDR_NO);
CREATE INDEX IND_PO_HEADER_2 ON PO_HEADER (VENDOR_ID);
CREATE INDEX IND_PO_HEADER_3 ON PO_HEADER (SHIPTO_ADDR_NO);
CREATE INDEX IND_PO_HEADER_4 ON PO_HEADER (POSTING_CANDIDATE);

CREATE TABLE PO_HEADER_TEMP AS
SELECT
  *
FROM
  PO_HEADER;

CREATE TABLE PO_LINE (
  PURC_ORDER_ID VARCHAR2(15) NOT NULL ENABLE,
  LINE_NO NUMBER NOT NULL ENABLE,
  PART_ID VARCHAR2(30),
  VENDOR_PART_ID VARCHAR2(30),
  SERVICE_ID VARCHAR2(15),
  USER_ORDER_QTY NUMBER(14,4) NOT NULL ENABLE,
  ORDER_QTY NUMBER(14,4) NOT NULL ENABLE,
  PURCHASE_UM VARCHAR2(15),
  UNIT_PRICE NUMBER(20,6) NOT NULL ENABLE,
  TRADE_DISC_PERCENT NUMBER(6,3) DEFAULT 0 NOT NULL ENABLE,
  FIXED_CHARGE NUMBER(15,2),
  EST_FREIGHT NUMBER(15,2) DEFAULT 0 NOT NULL ENABLE,
  GL_EXPENSE_ACCT_ID VARCHAR2(30),
  SALES_TAX_GROUP_ID VARCHAR2(15),
  PRODUCT_CODE VARCHAR2(15),
  COMMODITY_CODE VARCHAR2(15),
  DESIRED_RECV_DATE DATE,
  LINE_STATUS CHAR(1) DEFAULT ' ' NOT NULL ENABLE,
  LAST_RECEIVED_DATE DATE,
  TOTAL_ACT_FREIGHT NUMBER(15,2) DEFAULT 0 NOT NULL ENABLE,
  TOTAL_USR_RECD_QTY NUMBER(14,4) DEFAULT 0 NOT NULL ENABLE,
  TOTAL_RECEIVED_QTY NUMBER(14,4) DEFAULT 0 NOT NULL ENABLE,
  TOTAL_AMT_RECVD NUMBER(15,2) DEFAULT 0 NOT NULL ENABLE,
  TOTAL_AMT_ORDERED NUMBER(15,2) DEFAULT 0 NOT NULL ENABLE,
  MFG_NAME VARCHAR2(30),
  MFG_PART_ID VARCHAR2(30),
  PROMISE_DATE DATE,
  PIECE_COUNT NUMBER(14,4),
  LENGTH NUMBER(14,4),
  WIDTH NUMBER(14,4),
  HEIGHT NUMBER(14,4),
  DIMENSIONS_UM VARCHAR2(15),
  VAT_CODE VARCHAR2(15),
  TOTAL_DISPATCH_QTY NUMBER(14,4) DEFAULT 0 NOT NULL ENABLE,
  TOTAL_USR_DISP_QTY NUMBER(14,4) DEFAULT 0 NOT NULL ENABLE,
  MINIMUM_CHARGE NUMBER(15,2),
  LAST_DISPATCH_DATE DATE,
  EDI_BLANKET_QTY NUMBER(14,4),
  EDI_BLANKET_USRQTY NUMBER(14,4),
  EDI_ACCUM_QTY_REL NUMBER(14,4),
  EDI_ACCUM_USR_REL NUMBER(14,4),
  EDI_ACCUM_QTY_REC NUMBER(14,4),
  EDI_ACCUM_USR_REC NUMBER(14,4),
  EDI_LAST_REC_DATE DATE,
  EDI_RELEASE_NO VARCHAR2(3),
  EDI_RELEASE_DATE DATE,
  EDI_QTY_RELEASED NUMBER(14,4),
  EDI_USR_QTY_REL NUMBER(14,4),
  EDI_REQ_REL_DATE DATE,
  SHIPTO_ID VARCHAR2(20),
  WAREHOUSE_ID VARCHAR2(15),
  WIP_VAS_REQUIRED CHAR(1),
  ALLOCATED_QTY NUMBER(14,4) DEFAULT 0 NOT NULL ENABLE,
  FULFILLED_QTY NUMBER(14,4) DEFAULT 0 NOT NULL ENABLE,
  HTS_CODE VARCHAR2(20),
  ORIG_COUNTRY_ID VARCHAR2(15),
  USER_1 VARCHAR2(80),
  USER_2 VARCHAR2(80),
  USER_3 VARCHAR2(80),
  USER_4 VARCHAR2(80),
  USER_5 VARCHAR2(80),
  USER_6 VARCHAR2(80),
  USER_7 VARCHAR2(80),
  USER_8 VARCHAR2(80),
  USER_9 VARCHAR2(80),
  USER_10 VARCHAR2(80),
  UDF_LAYOUT_ID VARCHAR2(15),
  POL_CREATE_USER_ID VARCHAR2(30) DEFAULT USER,
  POL_CREATE_DATE DATE DEFAULT SYSDATE,
  CONSTRAINT "CHK_PO_LINE" CHECK ((LINE_STATUS = 'A' Or LINE_STATUS = 'C')) ENABLE,
  PRIMARY KEY (PURC_ORDER_ID, LINE_NO),
  CONSTRAINT "FKEY_PO_HEADER" FOREIGN KEY (PURC_ORDER_ID)
    REFERENCES PO_HEADER (PURC_ORDER_ID) ON DELETE CASCADE ENABLE,
  CONSTRAINT "FKEY_PART_ID" FOREIGN KEY (PART_ID)
    REFERENCES PARTS (PART_ID) ENABLE,
  CONSTRAINT "FKEY_PURC_UM" FOREIGN KEY (PURCHASE_UM)
   REFERENCES UMS (UNIT_OF_MEASURE) ENABLE);

CREATE INDEX IND_PO_LINE_1 ON PO_LINE (WAREHOUSE_ID);
CREATE INDEX IND_PO_LINE_2 ON PO_LINE (SERVICE_ID);
CREATE INDEX IND_PO_LINE_3 ON PO_LINE (PART_ID);
CREATE INDEX IND_PO_LINE_4 ON PO_LINE (VENDOR_PART_ID);

CREATE TABLE PO_LINE_TEMP AS
SELECT
  *
FROM
  PO_LINE;

INSERT INTO
  LOCATIONS
SELECT /*+ ORDERED */
  LOC.LOCATION_ID,
  WH.WAREHOUSE_ID,
  RPAD(WH.WAREHOUSE_ID||'-'||LOC.LOCATION_ID,60),
  DECODE(MOD(ROWNUM,5),0,'T',1,'R','F')
FROM
  (SELECT
    TRIM(TO_CHAR(ABS(ROUND(COS(ROWNUM*3.1415/180*1.2)*1000000,0))))||'LOC' LOCATION_ID,
    ROWNUM RN
  FROM
    DUAL
  CONNECT BY
    LEVEL<=200) LOC,
  (SELECT
    TRIM(TO_CHAR(ABS(ROUND(SIN(ROWNUM*3.1415/180*10.1)*1000000,0))))||'WH' WAREHOUSE_ID,
    ROWNUM RN
  FROM
    DUAL
  CONNECT BY
    LEVEL<=20) WH
WHERE
  (MOD(WH.RN,10)*20+1) <= LOC.RN;

COMMIT;

EXEC DBMS_STATS.GATHER_TABLE_STATS(OWNNAME=>USER,TABNAME=>'LOCATIONS',CASCADE=>TRUE);

INSERT INTO
  UMS
SELECT
  DECODE(ROWNUM,1,'EA',2,'PC',3,'FT',4,'METER',5,'KG',6,'CASE',7,'LBS',8,'DOZEN'),
  NULL,
  4
FROM
  DUAL
CONNECT BY
  LEVEL<=8;

COMMIT;

EXEC DBMS_STATS.GATHER_TABLE_STATS(OWNNAME=>USER,TABNAME=>'UMS',CASCADE=>TRUE);

INSERT INTO
  VENDORS_TEMP
SELECT
  TRIM(TO_CHAR(ABS(ROUND(COS(ROWNUM*3.14159265/180*51.491976)*10000000,0))))||'VEN' VENDOR_ID,
  TRIM(TO_CHAR(ABS(ROUND(COS(ROWNUM*3.1415/180*.49)*1000000,0))))||'VENDOR NAME' VENDOR_NAME,
  RPAD('ADDR_1',40) ADDR_1,
  RPAD('ADDR_2',35) ADDR_2,
  NULL ADDR_3,
  RPAD('CITY',20) CITY,
  'CA' STATE,
  LPAD(TO_CHAR(ROWNUM),6) ZIPCODE,
  'NONE' COUNTRY,
  NULL CONTACT_FIRST_NAME,
  NULL CONTACT_LAST_NAME,
  NULL CONTACT_INITIAL,
  NULL CONTACT_POSITION,
  NULL CONTACT_HONORIFIC,
  NULL CONTACT_SALUTATION,
  NULL CONTACT_PHONE,
  NULL CONTACT_FAX,
  TRIM(TO_CHAR(ABS(ROUND(COS(ROWNUM*3.1415/180*4.491976)*1000000,0))))||'VENDOR NAME' REMIT_TO_NAME,
  RPAD('ADDR_1',40) REMIT_TO_ADDR_1,
  RPAD('ADDR_2',35) REMIT_TO_ADDR_2,
  NULL REMIT_TO_ADDR_3,
  RPAD('CITY',20) REMIT_TO_CITY,
  'CA' REMIT_TO_STATE,
  LPAD(TO_CHAR(ROWNUM),6) REMIT_TO_ZIPCODE,
  'NONE' REMIT_TO_COUNTRY,
  'NONE' FREE_ON_BOARD,
  'SPECIAL DEL' SHIP_VIA,
  'UNKNOWN' BUYER,
  'N' REPORT_1099_MISC,
  DECODE(MOD(ROWNUM,6),0,'A',1,'M',2,'D',3,'N','E') TERMS_NET_TYPE,
  ROWNUM TERMS_NET_DAYS,
  NULL TERMS_NET_DATE,
  DECODE(MOD(ROWNUM,6),0,'A',1,'M',2,'D',3,'N','E') TERMS_DISC_TYPE,
  MOD(ROWNUM,100)+10 TERMS_DISC_DAYS,
  NULL TERMS_DISC_DATE,
  3.5 TERMS_DISC_PERCENT,
  'STANDARD' TERMS_DESCRIPTION,
  'X' USER_1,
  TO_CHAR(TRUNC(SYSDATE,'YYYY'),'MON DD, YYYY') USER_2,
  NULL USER_3,
  NULL USER_4,
  NULL USER_5,
  NULL USER_6,
  NULL USER_7,
  NULL USER_8,
  NULL USER_9,
  NULL USER_10
FROM
  DUAL
CONNECT BY
  LEVEL<=50000;

DELETE FROM
  VENDORS_TEMP
WHERE
  (VENDOR_ID,TERMS_NET_DAYS) IN
    (SELECT
      V.VENDOR_ID,
      V.TERMS_NET_DAYS
    FROM
      VENDORS_TEMP V,
      (SELECT
        VENDOR_ID,
        MIN(TERMS_NET_DAYS) TERMS_NET_DAYS
      FROM
        VENDORS_TEMP
      GROUP BY
        VENDOR_ID
      HAVING
        COUNT(*)>1) M
    WHERE
      V.VENDOR_ID=M.VENDOR_ID
      AND V.TERMS_NET_DAYS>M.TERMS_NET_DAYS);

INSERT INTO
  VENDORS
SELECT
  *
FROM
  VENDORS_TEMP;

COMMIT;

EXEC DBMS_STATS.GATHER_TABLE_STATS(OWNNAME=>USER,TABNAME=>'VENDORS',CASCADE=>TRUE);

INSERT INTO
  PARTS_TEMP
SELECT
  TRIM(TO_CHAR(ABS(ROUND(SIN(ROWNUM*3.14159265/180*10.191976)*10000000,0))))||'PART' PART_ID,
  TRIM(TO_CHAR(ABS(ROUND(SIN(ROWNUM*3.14159265/180*10.191976)*10000000,0))))||'DESCRIPTION' DESCRIPTION,
  DECODE(MOD(ROWNUM,20),2,'PC',3,'FT',4,'METER',5,'KG',6,'CASE',7,'LBS',8,'DOZEN','EA') STOCK_UM,
  1 PLANNING_LEADTIME,
  'M' ORDER_POLICY,
  ROWNUM ORDER_POINT,
  1 SAFETY_STOCK_QTY,
  1 FIXED_ORDER_QTY,
  1 DAYS_OF_SUPPLY,
  1 MINIMUM_ORDER_QTY,
  9999 MAXIMUM_ORDER_QTY,
  '0' ENGINEERING_MSTR,
  DECODE(MOD(ROWNUM,20),1,'SHOP',2,'OFFICE',3,'JANITOR',4,'INVENTORY',5,'INVENTORY','FG') PRODUCT_CODE,
  DECODE(MOD(ROWNUM,7),1,'SHOP',2,'OFFICE',3,'JANITOR',4,'INVENTORY',5,'INVENTORY','FG') COMMODITY_CODE,
  'UNKNOWN' MFG_NAME,
  'UNKNOWN' MFG_PART_ID,
  DECODE(MOD(ROWNUM,3),1,'Y','N') FABRICATED,
  DECODE(MOD(ROWNUM,3),1,'N','Y') PURCHASED,
  'N' STOCKED,
  'N' DETAIL_ONLY,
  'N' DEMAND_HISTORY,
  'N' TOOL_OR_FIXTURE,
  'N' INSPECTION_REQD,
  0 WEIGHT,
  DECODE(MOD(ROWNUM,20),2,'PC',3,'FT',4,'METER',5,'KG',6,'CASE',7,'LBS',8,'DOZEN','EA') WEIGHT_UM,
  NULL DRAWING_ID,
  NULL DRAWING_REV_NO,
  NULL PREF_VENDOR_ID,
  NULL PRIMARY_WHS_ID,
  NULL PRIMARY_LOC_ID,
  NULL BACKFLUSH_WHS_ID,
  NULL BACKFLUSH_LOC_ID,
  NULL INSPECT_WHS_ID,
  NULL INSPECT_LOC_ID,
  'Y' MRP_REQUIRED,
  'N' MRP_EXCEPTIONS,
  'N' PRIVATE_UM_CONV,
  'Y' AUTO_BACKFLUSH,
  NULL PLANNER_USER_ID,
  NULL BUYER_USER_ID,
  DECODE(MOD(ROWNUM,7),1,'A',2,'B',3,'B','C') ABC_CODE,
  ROWNUM-100000 ANNUAL_USAGE_QTY,
  'N' INVENTORY_LOCKED,
  0 UNIT_MATERIAL_COST,
  0 UNIT_LABOR_COST,
  0 UNIT_BURDEN_COST,
  0 UNIT_SERVICE_COST,
  0 BURDEN_PERCENT,
  0 BURDEN_PER_UNIT,
  0 PURC_BUR_PERCENT,
  0 PURC_BUR_PER_UNIT,
  0 FIXED_COST,
  0 UNIT_PRICE,
  0 NEW_MATERIAL_COST,
  0 NEW_LABOR_COST,
  0 NEW_BURDEN_COST,
  0 NEW_SERVICE_COST,
  0 NEW_BURDEN_PERCENT,
  0 NEW_BURDEN_PERUNIT,
  0 NEW_FIXED_COST,
  '1111111' MAT_GL_ACCT_ID,
  '2222222' LAB_GL_ACCT_ID,
  '3333333' BUR_GL_ACCT_ID,
  '4444444' SER_GL_ACCT_ID,
  ABS(ROUND(SIN(ROWNUM*3.14159265/180*2)*100000,3)) QTY_ON_HAND,
  ABS(ROUND(SIN(ROWNUM*3.14159265/180*2)*100000,3)) QTY_AVAILABLE_ISS,
  ABS(ROUND(SIN(ROWNUM*3.14159265/180*2)*100000,3)) QTY_AVAILABLE_MRP,
  0 QTY_ON_ORDER,
  0 QTY_IN_DEMAND,
  RPAD('USER_1',30) USER_1,
  RPAD('USER_2',30) USER_2,
  RPAD('USER_3',30) USER_3,
  NULL USER_4,
  NULL USER_5,
  NULL USER_6,
  NULL USER_7,
  NULL USER_8,
  NULL USER_9,
  NULL USER_10,
  0 LT_PLUS_DAYS,
  0 LT_MINUS_DAYS,
  'A' STATUS,
  'Y' USE_SUPPLY_BEF_LT,
  0 QTY_COMMITTED,
  'TESTING' PRT_CREATE_USER_ID,
  SYSDATE PRT_CREATE_DATE
FROM
  DUAL
CONNECT BY
  LEVEL<=100000;

DELETE FROM
  PARTS_TEMP
WHERE
  (PART_ID,ORDER_POINT) IN
    (SELECT
      V.PART_ID,
      V.ORDER_POINT
    FROM
      PARTS_TEMP V,
      (SELECT
        PART_ID,
        MIN(ORDER_POINT) ORDER_POINT
      FROM
        PARTS_TEMP
      GROUP BY
        PART_ID
      HAVING
        COUNT(*)>1) M
    WHERE
      V.PART_ID=M.PART_ID
      AND V.ORDER_POINT>M.ORDER_POINT);

INSERT INTO
  PARTS
SELECT
  *
FROM
  PARTS_TEMP;

UPDATE
  PARTS P
SET
  (PRIMARY_WHS_ID,PRIMARY_LOC_ID)=(
    SELECT
      WAREHOUSE_ID,
      LOCATION_ID
    FROM
      (SELECT
        WAREHOUSE_ID,
        LOCATION_ID,
        ROWNUM RN
      FROM
        LOCATIONS)
    WHERE
      MOD(P.ORDER_POINT,2000)=RN);

UPDATE
  PARTS
SET
  PREF_VENDOR_ID=TRIM(TO_CHAR(ABS(ROUND(COS((MOD(ROWNUM,9000)*2+1)*3.14159265/180*51.491976)*10000000,0))))||'VEN'
WHERE
  PURCHASED='Y';

COMMIT;

EXEC DBMS_STATS.GATHER_TABLE_STATS(OWNNAME=>USER,TABNAME=>'PARTS',CASCADE=>TRUE);

INSERT INTO
  PO_HEADER_TEMP
SELECT
  'PO'||TO_CHAR(ROWNUM) PURC_ORDER_ID,
  TRIM(TO_CHAR(ABS(ROUND(COS((MOD(ROWNUM,9000)*2+1)*3.14159265/180*51.491976)*10000000,0))))||'VEN' VENDOR_ID,
  NULL CONTACT_FIRST_NAME,
  NULL CONTACT_LAST_NAME,
  NULL CONTACT_INITIAL,
  NULL CONTACT_POSITION,
  NULL CONTACT_HONORIFIC,
  NULL CONTACT_SALUTATION,
  NULL CONTACT_PHONE,
  NULL CONTACT_FAX,
  1 PURC_ORD_ADDR_NO,
  1 SHIPTO_ADDR_NO,
  TRUNC(SYSDATE-(COS(ROWNUM*3.14159265/180)*1000)) ORDER_DATE,
  TRUNC(SYSDATE-(COS(ROWNUM*3.14159265/180)*1000))+10 DESIRED_RECV_DATE,
  'MY_BUYER' BUYER,
  NULL FREE_ON_BOARD,
  'BEST WAY' SHIP_VIA,
  'REGULAR' SALES_TAX_GROUP_ID,
  DECODE(MOD(ROWNUM,6),1,'F',2,'R',3,'X','C') PO_STATUS,
  'N' BACK_ORDER,
  1 SELL_RATE,
  1 BUY_RATE,
  '1' ENTITY_ID,
  DECODE(MOD(ROWNUM,3),1,'Y','N') POSTING_CANDIDATE,
  NULL LAST_RECEIVED_DATE,
  0 TOTAL_AMT_ORDERED,
  0 TOTAL_AMT_RECVD,
  'N' MARKED_FOR_PURGE,
  'Y' EXCH_RATE_FIXED,
  TRUNC(SYSDATE-(COS(ROWNUM*3.14159265/180)*1000))+10 PROMISE_DATE,
  SYSDATE PRINTED_DATE,
  DECODE(MOD(ROWNUM,6),0,'A',1,'M',2,'D',3,'N','E') TERMS_DISC_TYPE,
  NULL EDI_BLANKET_FLAG,
  NULL EDI_BLANKET_PO_NO,
  1 CONTRACT_ID,
  1 SHIPTO_ID,
  DECODE(MOD(ROWNUM,6),0,'A',1,'M',2,'D',3,'N','E') TERMS_NET_TYPE,
  1 TERMS_NET_DAYS,
  NULL TERMS_NET_DATE,
  1 TERMS_DISC_DAYS,
  NULL TERMS_DISC_DATE,
  3 TERMS_DISC_PERCENT,
  'ON TIME' TERMS_DESCRIPTION,
  'USD' CURRENCY_ID,
  NULL WAREHOUSE_ID,
  SYSDATE CREATE_DATE,
  NULL CONTACT_MOBILE,
  NULL CONTACT_EMAIL,
  NULL USER_1,
  NULL USER_2,
  NULL USER_3,
  NULL USER_4,
  NULL USER_5,
  NULL USER_6,
  NULL USER_7,
  NULL USER_8,
  NULL USER_9,
  NULL USER_10,
  'DEFAULT' UDF_LAYOUT_ID,
  'TESTING' PO_CREATE_USER_ID
FROM
  DUAL
CONNECT BY
  LEVEL<=500000;

INSERT INTO
  PO_HEADER
SELECT
  *
FROM
  PO_HEADER_TEMP;

COMMIT;

EXEC DBMS_STATS.GATHER_TABLE_STATS(OWNNAME=>USER,TABNAME=>'PO_HEADER',CASCADE=>TRUE);

INSERT INTO PO_LINE_TEMP (
  PURC_ORDER_ID,
  LINE_NO,
  PART_ID,
  VENDOR_PART_ID,
  SERVICE_ID,
  USER_ORDER_QTY,
  ORDER_QTY,
  PURCHASE_UM,
  UNIT_PRICE,
  FIXED_CHARGE,
  GL_EXPENSE_ACCT_ID,
  SALES_TAX_GROUP_ID,
  PRODUCT_CODE,
  COMMODITY_CODE,
  DESIRED_RECV_DATE,
  TRADE_DISC_PERCENT,
  EST_FREIGHT,
  LINE_STATUS,
  TOTAL_ACT_FREIGHT,
  TOTAL_USR_RECD_QTY,
  TOTAL_RECEIVED_QTY,
  TOTAL_AMT_RECVD,
  TOTAL_AMT_ORDERED,
  TOTAL_DISPATCH_QTY,
  TOTAL_USR_DISP_QTY,
  ALLOCATED_QTY,
  FULFILLED_QTY)
SELECT /*+ ORDERED */
  PURC_ORDER_ID,
  ORDER_POINT-START_LINE+1,
  PART_ID,
  PART_ID,
  NULL,
  10,
  10,
  DECODE(MOD(ROWNUM,20),2,'PC',3,'FT',4,'METER',5,'KG',6,'CASE',7,'LBS',8,'DOZEN','EA'),
  1099.99,
  0,
  NULL,
  NULL,
  PRODUCT_CODE,
  COMMODITY_CODE,
  TRUNC(SYSDATE-1000+ROWNUM/1000),
  0,
  0,
  'A',
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0,
  0
FROM
  (SELECT
    'PO'||TO_CHAR(ROWNUM) PURC_ORDER_ID,
    ROWNUM RN,
    ABS(SIN(ROWNUM*3.14159265/180))*90000 START_LINE,
    MOD(ROWNUM,50)+1 LINES
  FROM
    DUAL
  CONNECT BY
    LEVEL<=500000) POL,
  PARTS P
WHERE
  P.ORDER_POINT BETWEEN START_LINE AND (START_LINE+LINES-1);

INSERT INTO
  PO_LINE
SELECT
  *
FROM
  PO_LINE_TEMP;

COMMIT;

ALTER SESSION SET EVENTS '10046 TRACE NAME CONTEXT OFF';
ALTER SESSION SET EVENTS '10053 TRACE NAME CONTEXT OFF';

EXEC DBMS_STATS.GATHER_TABLE_STATS(OWNNAME=>USER,TABNAME=>'PO_LINE',CASCADE=>TRUE); 

The second half of the test script, where the generated data is queried, should complete much faster than the table creation portion of the script.  The buffer cache will be flushed at the start of the script, so we might be able to see how the different data access strategies (using the buffer cache or bypassing the buffer cache through direct path reads during full table scans) from previous queries will affect the performance of later queries.  While reviewing the output, watch for changes in the number of blocks read from disk, number of consistent gets, the number of rows returned, elapsed time, and wait event statistics - in some cases those values will differ even if the execution plans are identical.

ALTER SYSTEM FLUSH BUFFER_CACHE;
ALTER SYSTEM FLUSH BUFFER_CACHE;

SET ARRAYSIZE 1000
SET AUTOTRACE TRACEONLY STATISTICS
ALTER SESSION SET TRACEFILE_IDENTIFIER = 'SELECT_FROM_TABLES';
ALTER SESSION SET EVENTS '10053 TRACE NAME CONTEXT FOREVER, LEVEL 1';
ALTER SESSION SET EVENTS '10046 TRACE NAME CONTEXT FOREVER, LEVEL 8';

SELECT
  PO.VENDOR_ID,
  P.PRODUCT_CODE,
  P.STOCK_UM,
  SUM(POL.ORDER_QTY) ORDER_QTY
FROM
  PO_HEADER PO,
  PO_LINE POL,
  PARTS P
WHERE
  PO.ORDER_DATE BETWEEN TRUNC(SYSDATE-90) AND TRUNC(SYSDATE)
  AND PO.PURC_ORDER_ID=POL.PURC_ORDER_ID
  AND POL.PART_ID=P.PART_ID
GROUP BY
  PO.VENDOR_ID,
  P.PRODUCT_CODE,
  P.STOCK_UM;

SELECT
  POL.PART_ID,
  P.DESCRIPTION,
  MAX(DESIRED_RECV_DATE) LAST_RECEIVE_DATE
FROM
  PO_LINE POL,
  PARTS P
WHERE
  P.PRODUCT_CODE='FG'
  AND P.ABC_CODE='C'
  AND P.PART_ID=POL.PART_ID
GROUP BY
  POL.PART_ID,
  P.DESCRIPTION;

SELECT
  PRODUCT_CODE,
  COUNT(*) PARTS_LARGE_WH
FROM
  (SELECT
    WAREHOUSE_ID
  FROM
    LOCATIONS
  GROUP BY
    WAREHOUSE_ID
  HAVING
    COUNT(*)>160) W,
  PARTS P
WHERE
  W.WAREHOUSE_ID=P.PRIMARY_WHS_ID
GROUP BY
  PRODUCT_CODE
ORDER BY
  PRODUCT_CODE;

SELECT
  COUNT(*)
FROM
  PARTS
WHERE
  QTY_ON_HAND>1000;

SELECT
  COUNT(*)
FROM
  VENDORS
WHERE
  ZIPCODE>' 44444';

SELECT
  COUNT(*)
FROM
  PO_LINE POL,
  PARTS P
WHERE
  POL.PURC_ORDER_ID BETWEEN '10000' AND '20000'
  AND POL.PART_ID=P.PART_ID;

SELECT
  PART_ID,
  ABC_CODE,
  PRODUCT_CODE,
  MAX(QTY_ON_HAND) OVER (PARTITION BY PRODUCT_CODE,ABC_CODE) MAX_QTY_PRD_ABC,
  MIN(QTY_ON_HAND) OVER (PARTITION BY PRODUCT_CODE,ABC_CODE) MIN_QTY_PRD_ABC,
  DENSE_RANK() OVER (PARTITION BY PRODUCT_CODE,ABC_CODE ORDER BY QTY_ON_HAND) DR_QTY_PRD_ABC,
  DENSE_RANK() OVER (PARTITION BY PREF_VENDOR_ID ORDER BY ORDER_POINT) DR_OP_VEND
FROM
  PARTS
ORDER BY
  PART_ID;

SELECT
  V.VENDOR_ID,
  V.VENDOR_NAME
FROM
  VENDORS V,
  (SELECT DISTINCT
    PO.VENDOR_ID
  FROM
    PO_HEADER PO,
    PO_LINE POL,
    PARTS P
  WHERE
    PO.PURC_ORDER_ID=POL.PURC_ORDER_ID
    AND POL.PART_ID=P.PART_ID
    AND P.PRODUCT_CODE='FG') PV
WHERE
  V.VENDOR_ID=PV.VENDOR_ID(+)
  AND PV.VENDOR_ID IS NULL
ORDER BY
  V.VENDOR_ID;

SELECT
  P.PART_ID,
  P.DESCRIPTION PART_DESCRIPTION,
  P.PRIMARY_WHS_ID,
  P.PRIMARY_LOC_ID,
  U.DESCRIPTION UMS_DESCRIPTION,
  U.UOM_SCALE,
  L.DESCRIPTION LOC_DESCRIPTION,
  V.VENDOR_ID,
  V.VENDOR_NAME,
  V.ADDR_1,
  V.ADDR_2,
  V.CITY,
  V.STATE
FROM
  UMS U,
  LOCATIONS L,
  PARTS P,
  VENDORS V
WHERE
  P.PRODUCT_CODE IN ('OFFICE','SHOP')
  AND P.PURCHASED='Y'
  AND P.STOCK_UM=U.UNIT_OF_MEASURE
  AND U.UNIT_OF_MEASURE IN ('EA','PC','CASE')
  AND P.PREF_VENDOR_ID=V.VENDOR_ID
  AND P.PRIMARY_WHS_ID=L.WAREHOUSE_ID
  AND P.PRIMARY_LOC_ID=L.LOCATION_ID;

SELECT
  VENDOR_ID,
  PART_ID,
  DESIRED_RECV_DATE
FROM
  (SELECT
    PO.VENDOR_ID,
    POL.PART_ID,
    POL.DESIRED_RECV_DATE,
    ROW_NUMBER() OVER (PARTITION BY POL.PART_ID ORDER BY POL.DESIRED_RECV_DATE DESC) RN
  FROM
    PO_HEADER PO,
    PO_LINE POL
  WHERE
    PO.PURC_ORDER_ID=POL.PURC_ORDER_ID)
WHERE
  RN=1
ORDER BY
  PART_ID;

SELECT
  P.PART_ID,
  P.DESCRIPTION PART_DESCRIPTION,
  P.PRIMARY_WHS_ID,
  P.PRIMARY_LOC_ID,
  U.DESCRIPTION UMS_DESCRIPTION,
  U.UOM_SCALE,
  L.DESCRIPTION LOC_DESCRIPTION,
  V.VENDOR_ID,
  V.VENDOR_NAME,
  V.ADDR_1,
  V.ADDR_2,
  V.CITY,
  V.STATE,
  LV.VENDOR_ID LAST_VENDOR_ID,
  V2.VENDOR_NAME LAST_VENDOR_NAME,
  V2.STATE LAST_VENDOR_STATE,
  LV.DESIRED_RECV_DATE LAST_DES_RECV_DATE
FROM
  UMS U,
  LOCATIONS L,
  PARTS P,
  VENDORS V,
  (SELECT
    VENDOR_ID,
    PART_ID,
    DESIRED_RECV_DATE
  FROM
    (SELECT
      PO.VENDOR_ID,
      POL.PART_ID,
      POL.DESIRED_RECV_DATE,
      ROW_NUMBER() OVER (PARTITION BY POL.PART_ID ORDER BY POL.DESIRED_RECV_DATE DESC) RN
    FROM
      PO_HEADER PO,
      PO_LINE POL
    WHERE
      PO.PURC_ORDER_ID=POL.PURC_ORDER_ID)
  WHERE
    RN=1) LV,
  VENDORS V2
WHERE
  P.PRODUCT_CODE IN ('OFFICE','SHOP')
  AND P.PURCHASED='Y'
  AND P.STOCK_UM=U.UNIT_OF_MEASURE
  AND U.UNIT_OF_MEASURE IN ('EA','PC','CASE')
  AND P.PREF_VENDOR_ID=V.VENDOR_ID
  AND P.PRIMARY_WHS_ID=L.WAREHOUSE_ID
  AND P.PRIMARY_LOC_ID=L.LOCATION_ID
  AND P.PART_ID=LV.PART_ID
  AND LV.VENDOR_ID=V2.VENDOR_ID;

SELECT
  P.PART_ID,
  P.DESCRIPTION PART_DESCRIPTION,
  P.PRIMARY_WHS_ID,
  P.PRIMARY_LOC_ID,
  U.DESCRIPTION UMS_DESCRIPTION,
  U.UOM_SCALE,
  L.DESCRIPTION LOC_DESCRIPTION,
  V.VENDOR_ID,
  V.VENDOR_NAME,
  V.ADDR_1,
  V.ADDR_2,
  V.CITY,
  V.STATE,
  LV.VENDOR_ID LAST_VENDOR_ID,
  V2.VENDOR_NAME LAST_VENDOR_NAME,
  V2.STATE LAST_VENDOR_STATE,
  LV.DESIRED_RECV_DATE LAST_DES_RECV_DATE
FROM
  UMS U,
  LOCATIONS L,
  PARTS P,
  VENDORS V,
  (SELECT
    VENDOR_ID,
    PART_ID,
    DESIRED_RECV_DATE
  FROM
    (SELECT
      PO.VENDOR_ID,
      POL.PART_ID,
      POL.DESIRED_RECV_DATE,
      ROW_NUMBER() OVER (PARTITION BY POL.PART_ID ORDER BY POL.DESIRED_RECV_DATE DESC) RN
    FROM
      PO_HEADER PO,
      PO_LINE POL
    WHERE
      PO.PURC_ORDER_ID=POL.PURC_ORDER_ID)
  WHERE
    RN=1) LV,
  VENDORS V2
WHERE
  (P.PRODUCT_CODE NOT IN ('OFFICE','SHOP')
     OR U.UNIT_OF_MEASURE NOT IN ('EA','PC','CASE'))
  AND P.PURCHASED='Y'
  AND P.STOCK_UM=U.UNIT_OF_MEASURE
  AND P.PREF_VENDOR_ID=V.VENDOR_ID
  AND P.PRIMARY_WHS_ID=L.WAREHOUSE_ID
  AND P.PRIMARY_LOC_ID=L.LOCATION_ID
  AND P.PART_ID=LV.PART_ID
  AND LV.VENDOR_ID=V2.VENDOR_ID;

SELECT
  P.PART_ID,
  P.DESCRIPTION,
  P.PREF_VENDOR_ID,
  V.VENDOR_NAME PREF_VENDOR_NAME,
  PV.VENDOR_ID,
  V2.VENDOR_NAME LAST_VENDOR_NAME,
  PV.ORDER_LINES,
  PV.FIRST_RECV_DATE,
  PV.LAST_RECV_DATE
FROM
  (SELECT
    PO.VENDOR_ID,
    POL.PART_ID,
    COUNT(*) ORDER_LINES,
    MIN(POL.DESIRED_RECV_DATE) FIRST_RECV_DATE,
    MAX(POL.DESIRED_RECV_DATE) LAST_RECV_DATE
  FROM
    PO_HEADER PO,
    PO_LINE POL
  WHERE
    PO.PURC_ORDER_ID=POL.PURC_ORDER_ID
  GROUP BY
    PO.VENDOR_ID,
    POL.PART_ID) PV,
  PARTS P,
  VENDORS V,
  VENDORS V2
WHERE
  P.PART_ID=PV.PART_ID
  AND P.PREF_VENDOR_ID != PV.VENDOR_ID
  AND P.PREF_VENDOR_ID=V.VENDOR_ID
  AND PV.VENDOR_ID=V2.VENDOR_ID;

SELECT
  *
FROM
  PO_HEADER PO,
  PO_LINE POL,
  PARTS P,
  VENDORS V
WHERE
  PO.VENDOR_ID LIKE '100%'
  AND PO.POSTING_CANDIDATE='N'
  AND PO.PURC_ORDER_ID=POL.PURC_ORDER_ID
  AND POL.PART_ID BETWEEN '80' AND '999999'
  AND POL.PART_ID=P.PART_ID
  AND PO.VENDOR_ID=V.VENDOR_ID;

ALTER SESSION SET EVENTS '10046 TRACE NAME CONTEXT OFF';
ALTER SESSION SET EVENTS '10053 TRACE NAME CONTEXT OFF';
SET AUTOTRACE OFF 

Just for fun, I also ran the test script on my laptop, which was running Oracle Database Enterprise 11.2.0.1 configured with a 12000M SGA_TARGET and a 2000M PGA_AGGREGATE_TARGET.

Simple insert into a table:

INSERT INTO
  LOCATIONS
SELECT /*+ ORDERED */
  LOC.LOCATION_ID,
  WH.WAREHOUSE_ID,
  RPAD(WH.WAREHOUSE_ID||'-'||LOC.LOCATION_ID,60),
  DECODE(MOD(ROWNUM,5),0,'T',1,'R','F')
FROM
  (SELECT
... 

Laptop running 11.2.0.1 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.03       0.02          0          0          0           0
Execute      1      0.14       0.13          0        141       3259        2200
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2      0.17       0.15          0        141       3259        2200

Misses in library cache during parse: 1
Misses in library cache during execute: 1
Optimizer mode: ALL_ROWS
Parsing user id: 286 
Number of plan statistics captured: 1

Rows (1st) Rows (avg) Rows (max)  Row Source Operation
---------- ---------- ----------  ---------------------------------------------------
         0          0          0  LOAD TABLE CONVENTIONAL  (cr=0 pr=0 pw=0 time=0 us)
         1          1          1   COUNT  (cr=0 pr=0 pw=0 time=0 us)
         1          1          1    NESTED LOOPS  (cr=0 pr=0 pw=0 time=0 us cost=4 size=72 card=1)
         1          1          1     VIEW  (cr=0 pr=0 pw=0 time=0 us cost=2 size=36 card=1)
         1          1          1      COUNT  (cr=0 pr=0 pw=0 time=0 us)
         1          1          1       CONNECT BY WITHOUT FILTERING (cr=0 pr=0 pw=0 time=0 us)
         1          1          1        FAST DUAL  (cr=0 pr=0 pw=0 time=0 us cost=2 size=0 card=1)
         1          1          1     VIEW  (cr=0 pr=0 pw=0 time=0 us cost=2 size=36 card=1)
        10         10         10      COUNT  (cr=0 pr=0 pw=0 time=18 us)
        10         10         10       CONNECT BY WITHOUT FILTERING (cr=0 pr=0 pw=0 time=18 us)
         1          1          1        FAST DUAL  (cr=0 pr=0 pw=0 time=0 us cost=2 size=0 card=1)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  rdbms ipc reply                                 2        0.00          0.00
  log file sync                                   1        0.00          0.00
  SQL*Net message to client                       1        0.00          0.00
  SQL*Net message from client                     1        0.00          0.00 

Oracle Database 10.2.0.5 Standard Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.01       0.07          0          0          0           0
Execute      1      0.09       0.12          0        258       3443        2200
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2      0.10       0.20          0        258       3443        2200

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 47 

Rows     Row Source Operation
-------  ---------------------------------------------------
   2200  COUNT  (cr=0 pr=0 pw=0 time=116495 us)
   2200   NESTED LOOPS  (cr=0 pr=0 pw=0 time=77138 us)
    200    VIEW  (cr=0 pr=0 pw=0 time=19754 us)
    200     COUNT  (cr=0 pr=0 pw=0 time=210 us)
    200      CONNECT BY WITHOUT FILTERING (cr=0 pr=0 pw=0 time=11 us)
      1       FAST DUAL  (cr=0 pr=0 pw=0 time=1 us)
   2200    VIEW  (cr=0 pr=0 pw=0 time=52757 us)
   4000     COUNT  (cr=0 pr=0 pw=0 time=691 us)
   4000      CONNECT BY WITHOUT FILTERING (cr=0 pr=0 pw=0 time=593 us)
    200       FAST DUAL  (cr=0 pr=0 pw=0 time=48 us)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  log file sync                                   1        0.00          0.00
  SQL*Net message to client                       1        0.00          0.00
  SQL*Net message from client                     1        0.01          0.01 

Oracle Database 10.2.0.5 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.01       0.14          0          0          0           0
Execute      1      0.10       0.10          0        259       3434        2200
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2      0.12       0.25          0        259       3434        2200

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 164 

Rows     Row Source Operation
-------  ---------------------------------------------------
   2200  COUNT  (cr=0 pr=0 pw=0 time=101335 us)
   2200   NESTED LOOPS  (cr=0 pr=0 pw=0 time=61984 us)
    200    VIEW  (cr=0 pr=0 pw=0 time=2423 us)
    200     COUNT  (cr=0 pr=0 pw=0 time=210 us)
    200      CONNECT BY WITHOUT FILTERING (cr=0 pr=0 pw=0 time=209 us)
      1       FAST DUAL  (cr=0 pr=0 pw=0 time=0 us)
   2200    VIEW  (cr=0 pr=0 pw=0 time=54837 us)
   4000     COUNT  (cr=0 pr=0 pw=0 time=693 us)
   4000      CONNECT BY WITHOUT FILTERING (cr=0 pr=0 pw=0 time=620 us)
    200       FAST DUAL  (cr=0 pr=0 pw=0 time=52 us) 

Oracle Database 11.2.0.1 Standard Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.03       0.02          0          0          0           0
Execute      1      0.07       0.07          0        155       3447        2200
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2      0.10       0.10          0        155       3447        2200

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 51 

Rows     Row Source Operation
-------  ---------------------------------------------------
      0  LOAD TABLE CONVENTIONAL  (cr=190 pr=0 pw=0 time=0 us)
   2200   COUNT  (cr=0 pr=0 pw=0 time=76598 us)
   2200    NESTED LOOPS  (cr=0 pr=0 pw=0 time=76476 us cost=4 size=72 card=1)
    200     VIEW  (cr=0 pr=0 pw=0 time=2288 us cost=2 size=36 card=1)
    200      COUNT  (cr=0 pr=0 pw=0 time=99 us)
    200       CONNECT BY WITHOUT FILTERING (cr=0 pr=0 pw=0 time=0 us)
      1        FAST DUAL  (cr=0 pr=0 pw=0 time=0 us cost=2 size=0 card=1)
   2200     VIEW  (cr=0 pr=0 pw=0 time=69004 us cost=2 size=36 card=1)
   4000      COUNT  (cr=0 pr=0 pw=0 time=2719 us)
   4000       CONNECT BY WITHOUT FILTERING (cr=0 pr=0 pw=0 time=2026 us)
    200        FAST DUAL  (cr=0 pr=0 pw=0 time=0 us cost=2 size=0 card=1)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  log file sync                                   1        0.00          0.00
  SQL*Net message to client                       1        0.00          0.00
  SQL*Net message from client                     1        0.00          0.00

Oracle Database 11.2.0.1 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.03       0.02          0          0          0           0
Execute      1      0.12       0.12          0        158       3547        2200
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2      0.15       0.14          0        158       3547        2200

Misses in library cache during parse: 1
Misses in library cache during execute: 1
Optimizer mode: ALL_ROWS
Parsing user id: 194 

Rows     Row Source Operation
-------  ---------------------------------------------------
      0  LOAD TABLE CONVENTIONAL  (cr=0 pr=0 pw=0 time=0 us)
      1   COUNT  (cr=0 pr=0 pw=0 time=0 us)
      1    NESTED LOOPS  (cr=0 pr=0 pw=0 time=0 us cost=4 size=72 card=1)
      1     VIEW  (cr=0 pr=0 pw=0 time=0 us cost=2 size=36 card=1)
      1      COUNT  (cr=0 pr=0 pw=0 time=0 us)
      1       CONNECT BY WITHOUT FILTERING (cr=0 pr=0 pw=0 time=0 us)
      1        FAST DUAL  (cr=0 pr=0 pw=0 time=0 us cost=2 size=0 card=1)
      1     VIEW  (cr=0 pr=0 pw=0 time=0 us cost=2 size=36 card=1)
     10      COUNT  (cr=0 pr=0 pw=0 time=45 us)
     10       CONNECT BY WITHOUT FILTERING (cr=0 pr=0 pw=0 time=36 us)
      1        FAST DUAL  (cr=0 pr=0 pw=0 time=0 us cost=2 size=0 card=1)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  log file sync                                   1        0.01          0.01
  SQL*Net message to client                       1        0.00          0.00
  SQL*Net message from client                     1        0.00          0.00

Deleting from the temporary holding table for the vendors, before inserting into the VENDORS table with the constraints:

DELETE FROM
  VENDORS_TEMP
WHERE
  (VENDOR_ID,TERMS_NET_DAYS) IN
    (SELECT
      V.VENDOR_ID,
      V.TERMS_NET_DAYS
    FROM
      VENDORS_TEMP V,
      (SELECT
        VENDOR_ID,
        MIN(TERMS_NET_DAYS) TERMS_NET_DAYS
      FROM
        VENDORS_TEMP
      GROUP BY
        VENDOR_ID
      HAVING
        COUNT(*)>1) M
    WHERE
      V.VENDOR_ID=M.VENDOR_ID
      AND V.TERMS_NET_DAYS>M.TERMS_NET_DAYS) 

Laptop running 11.2.0.1 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.01       0.03          0         16          0           0
Execute      1      0.10       0.10          0       7521        244         214
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2      0.12       0.14          0       7537        244         214

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 286 
Number of plan statistics captured: 1

Rows (1st) Rows (avg) Rows (max)  Row Source Operation
---------- ---------- ----------  ---------------------------------------------------
         0          0          0  DELETE  VENDORS_TEMP (cr=7521 pr=0 pw=0 time=0 us)
       214        214        214   HASH JOIN RIGHT SEMI (cr=7521 pr=0 pw=0 time=64219 us cost=603 size=2061136 card=46844)
       214        214        214    VIEW  VW_NSO_1 (cr=5014 pr=0 pw=0 time=63367 us cost=403 size=51524 card=2342)
       214        214        214     HASH JOIN  (cr=5014 pr=0 pw=0 time=63367 us cost=403 size=103048 card=2342)
       135        135        135      VIEW  (cr=2507 pr=0 pw=0 time=936392 us cost=202 size=1030568 card=46844)
       135        135        135       FILTER  (cr=2507 pr=0 pw=0 time=936392 us)
     49786      49786      49786        SORT GROUP BY (cr=2507 pr=0 pw=0 time=12670 us cost=202 size=1030568 card=46844)
     50000      50000      50000         TABLE ACCESS FULL VENDORS_TEMP (cr=2507 pr=0 pw=0 time=26597 us cost=199 size=1030568 card=46844)
     50000      50000      50000      TABLE ACCESS FULL VENDORS_TEMP (cr=2507 pr=0 pw=0 time=19820 us cost=199 size=1030568 card=46844)
     50000      50000      50000    TABLE ACCESS FULL VENDORS_TEMP (cr=2507 pr=0 pw=0 time=22250 us cost=199 size=1030568 card=46844)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  asynch descriptor resize                        1        0.00          0.00
  SQL*Net message to client                       1        0.00          0.00
  SQL*Net message from client                     1        0.00          0.00 

Oracle Database 10.2.0.5 Standard Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.03       0.03          0         12          0           0
Execute      1      0.10       0.11          0       7554        244         214
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2      0.14       0.14          0       7566        244         214

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 47 

Rows     Row Source Operation
-------  ---------------------------------------------------
      0  DELETE  VENDORS_TEMP (cr=7554 pr=0 pw=0 time=111433 us)
    214   HASH JOIN RIGHT SEMI (cr=7554 pr=0 pw=0 time=122775 us)
    214    VIEW  VW_NSO_1 (cr=5036 pr=0 pw=0 time=104690 us)
    214     HASH JOIN  (cr=5036 pr=0 pw=0 time=104688 us)
    135      VIEW  (cr=2518 pr=0 pw=0 time=1007463 us)
    135       FILTER  (cr=2518 pr=0 pw=0 time=1007462 us)
  49786        SORT GROUP BY (cr=2518 pr=0 pw=0 time=58205 us)
  50000         TABLE ACCESS FULL VENDORS_TEMP (cr=2518 pr=0 pw=0 time=17 us)
  50000      TABLE ACCESS FULL VENDORS_TEMP (cr=2518 pr=0 pw=0 time=23 us)
  50000    TABLE ACCESS FULL VENDORS_TEMP (cr=2518 pr=0 pw=0 time=20 us)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                       1        0.00          0.00
  SQL*Net message from client                     1        0.02          0.02 

Oracle Database 10.2.0.5 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.03       0.05          0         12          0           0
Execute      1      0.10       0.11          0       7554        244         214
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2      0.14       0.16          0       7566        244         214

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 164 

Rows     Row Source Operation
-------  ---------------------------------------------------
      0  DELETE  VENDORS_TEMP (cr=7554 pr=0 pw=0 time=112308 us)
    214   HASH JOIN RIGHT SEMI (cr=7554 pr=0 pw=0 time=229889 us)
    214    VIEW  VW_NSO_1 (cr=5036 pr=0 pw=0 time=210415 us)
    214     HASH JOIN  (cr=5036 pr=0 pw=0 time=210414 us)
    135      VIEW  (cr=2518 pr=0 pw=0 time=1052458 us)
    135       FILTER  (cr=2518 pr=0 pw=0 time=1052458 us)
  49786        SORT GROUP BY (cr=2518 pr=0 pw=0 time=58712 us)
  50000         TABLE ACCESS FULL VENDORS_TEMP (cr=2518 pr=0 pw=0 time=25 us)
  50000      TABLE ACCESS FULL VENDORS_TEMP (cr=2518 pr=0 pw=0 time=23 us)
  50000    TABLE ACCESS FULL VENDORS_TEMP (cr=2518 pr=0 pw=0 time=24 us)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                       1        0.00          0.00
  SQL*Net message from client                     1        0.00          0.00

Oracle Database 11.2.0.1 Standard Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.01       0.04          0         16          0           0
Execute      1      0.10       0.11          0       7554        242         214
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2      0.12       0.15          0       7570        242         214

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 51 

Rows     Row Source Operation
-------  ---------------------------------------------------
      0  DELETE  VENDORS_TEMP (cr=7554 pr=0 pw=0 time=0 us)
    214   HASH JOIN RIGHT SEMI (cr=7554 pr=0 pw=0 time=88501 us cost=661 size=2807068 card=63797)
    214    VIEW  VW_NSO_1 (cr=5036 pr=0 pw=0 time=0 us cost=459 size=70180 card=3190)
    214     HASH JOIN  (cr=5036 pr=0 pw=0 time=0 us cost=459 size=140360 card=3190)
  50000      TABLE ACCESS FULL VENDORS_TEMP (cr=2518 pr=0 pw=0 time=19564 us cost=201 size=1403534 card=63797)
    135      VIEW  (cr=2518 pr=0 pw=0 time=987714 us cost=204 size=1403534 card=63797)
    135       FILTER  (cr=2518 pr=0 pw=0 time=987580 us)
  49786        SORT GROUP BY (cr=2518 pr=0 pw=0 time=12414 us cost=204 size=1403534 card=63797)
  50000         TABLE ACCESS FULL VENDORS_TEMP (cr=2518 pr=0 pw=0 time=25191 us cost=201 size=1403534 card=63797)
  50000    TABLE ACCESS FULL VENDORS_TEMP (cr=2518 pr=0 pw=0 time=18925 us cost=201 size=1403534 card=63797)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  asynch descriptor resize                        2        0.00          0.00
  SQL*Net message to client                       1        0.00          0.00
  SQL*Net message from client                     1        0.00          0.00

Oracle Database 11.2.0.1 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.04       0.04          0         16          0           0
Execute      1      0.10       0.10          0       7554        242         214
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2      0.15       0.14          0       7570        242         214

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 194 

Rows     Row Source Operation
-------  ---------------------------------------------------
      0  DELETE  VENDORS_TEMP (cr=7554 pr=0 pw=0 time=0 us)
    214   HASH JOIN RIGHT SEMI (cr=7554 pr=0 pw=0 time=44730 us cost=607 size=2526348 card=57417)
    214    VIEW  VW_NSO_1 (cr=5036 pr=0 pw=0 time=44623 us cost=406 size=66638 card=3029)
    214     HASH JOIN  (cr=5036 pr=0 pw=0 time=44623 us cost=406 size=133276 card=3029)
    135      VIEW  (cr=2518 pr=0 pw=0 time=934047 us cost=204 size=1263174 card=57417)
    135       FILTER  (cr=2518 pr=0 pw=0 time=934047 us)
  49786        SORT GROUP BY (cr=2518 pr=0 pw=0 time=10494 us cost=204 size=1263174 card=57417)
  50000         TABLE ACCESS FULL VENDORS_TEMP (cr=2518 pr=0 pw=0 time=25191 us cost=201 size=1263174 card=57417)
  50000      TABLE ACCESS FULL VENDORS_TEMP (cr=2518 pr=0 pw=0 time=20587 us cost=201 size=1263174 card=57417)
  50000    TABLE ACCESS FULL VENDORS_TEMP (cr=2518 pr=0 pw=0 time=18030 us cost=201 size=1263174 card=57417)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  asynch descriptor resize                        1        0.00          0.00
  SQL*Net message to client                       1        0.00          0.00
  SQL*Net message from client                     1        0.00          0.00  

Deleting from the temporary holding table for the PARTS before inserting into the PARTS table:

DELETE FROM
  PARTS_TEMP
WHERE
  (PART_ID,ORDER_POINT) IN
    (SELECT
      V.PART_ID,
      V.ORDER_POINT
    FROM
      PARTS_TEMP V,
      (SELECT
        PART_ID,
        MIN(ORDER_POINT) ORDER_POINT
      FROM
        PARTS_TEMP
      GROUP BY
        PART_ID
      HAVING
        COUNT(*)>1) M
    WHERE
      V.PART_ID=M.PART_ID
      AND V.ORDER_POINT>M.ORDER_POINT) 

Laptop running 11.2.0.1 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.06       0.04          0         16          0           0
Execute      1      0.21       0.21          0      15028        374         306
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2      0.28       0.26          0      15044        374         306

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 286 
Number of plan statistics captured: 1

Rows (1st) Rows (avg) Rows (max)  Row Source Operation
---------- ---------- ----------  ---------------------------------------------------
         0          0          0  DELETE  PARTS_TEMP (cr=15035 pr=0 pw=0 time=0 us)
       306        306        306   HASH JOIN RIGHT SEMI (cr=15027 pr=0 pw=0 time=29280 us cost=1274 size=4953360 card=82556)
       306        306        306    VIEW  VW_NSO_1 (cr=10018 pr=0 pw=0 time=26535 us cost=878 size=123840 card=4128)
       306        306        306     HASH JOIN  (cr=10018 pr=0 pw=0 time=26433 us cost=878 size=247680 card=4128)
       193        193        193      VIEW  (cr=5009 pr=0 pw=0 time=2787264 us cost=398 size=2476680 card=82556)
       193        193        193       FILTER  (cr=5009 pr=0 pw=0 time=2787168 us)
     99694      99694      99694        SORT GROUP BY (cr=5009 pr=0 pw=0 time=27386 us cost=398 size=2476680 card=82556)
    100000     100000     100000         TABLE ACCESS FULL PARTS_TEMP (cr=5009 pr=0 pw=0 time=46418 us cost=395 size=2476680 card=82556)
    100000     100000     100000      TABLE ACCESS FULL PARTS_TEMP (cr=5009 pr=0 pw=0 time=30945 us cost=395 size=2476680 card=82556)
    100000     100000     100000    TABLE ACCESS FULL PARTS_TEMP (cr=5009 pr=0 pw=0 time=31713 us cost=395 size=2476680 card=82556)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  asynch descriptor resize                        2        0.00          0.00
  SQL*Net message to client                       1        0.00          0.00
  SQL*Net message from client                     1        0.00          0.00 

Oracle Database 10.2.0.5 Standard Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.00       0.04          0         12          0           0
Execute      1      0.20       0.20          0      15120        362         306
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2      0.20       0.25          0      15132        362         306

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 47 

Rows     Row Source Operation
-------  ---------------------------------------------------
      0  DELETE  PARTS_TEMP (cr=15120 pr=0 pw=0 time=203889 us)
    306   HASH JOIN RIGHT SEMI (cr=15120 pr=0 pw=0 time=186251 us)
    306    VIEW  VW_NSO_1 (cr=10080 pr=0 pw=0 time=158060 us)
    306     HASH JOIN  (cr=10080 pr=0 pw=0 time=158059 us)
    193      VIEW  (cr=5040 pr=0 pw=0 time=2709664 us)
    193       FILTER  (cr=5040 pr=0 pw=0 time=2709471 us)
  99694        SORT GROUP BY (cr=5040 pr=0 pw=0 time=115549 us)
 100000         TABLE ACCESS FULL PARTS_TEMP (cr=5040 pr=0 pw=0 time=15 us)
 100000      TABLE ACCESS FULL PARTS_TEMP (cr=5040 pr=0 pw=0 time=25 us)
 100000    TABLE ACCESS FULL PARTS_TEMP (cr=5040 pr=0 pw=0 time=21 us)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                       1        0.00          0.00
  SQL*Net message from client                     1        0.02          0.02 

Oracle Database 10.2.0.5 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.03       0.02          0         12          0           0
Execute      1      0.21       0.21          0      15120        362         306
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2      0.24       0.24          0      15132        362         306

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 164 

Rows     Row Source Operation
-------  ---------------------------------------------------
      0  DELETE  PARTS_TEMP (cr=15120 pr=0 pw=0 time=218918 us)
    306   HASH JOIN RIGHT SEMI (cr=15120 pr=0 pw=0 time=201432 us)
    306    VIEW  VW_NSO_1 (cr=10080 pr=0 pw=0 time=152694 us)
    306     HASH JOIN  (cr=10080 pr=0 pw=0 time=152694 us)
 100000      TABLE ACCESS FULL PARTS_TEMP (cr=5040 pr=0 pw=0 time=27 us)
    193      VIEW  (cr=5040 pr=0 pw=0 time=2975280 us)
    193       FILTER  (cr=5040 pr=0 pw=0 time=2975279 us)
  99694        SORT GROUP BY (cr=5040 pr=0 pw=0 time=113516 us)
 100000         TABLE ACCESS FULL PARTS_TEMP (cr=5040 pr=0 pw=0 time=19 us)
 100000    TABLE ACCESS FULL PARTS_TEMP (cr=5040 pr=0 pw=0 time=32 us)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                       1        0.00          0.00
  SQL*Net message from client                     1        0.00          0.00

Oracle Database 11.2.0.1 Standard Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.03       0.04          0         16          0           0
Execute      1      0.21       0.21          0      15081        362         306
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2      0.24       0.25          0      15097        362         306

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 51 

Rows     Row Source Operation
-------  ---------------------------------------------------
      0  DELETE  PARTS_TEMP (cr=15081 pr=0 pw=0 time=0 us)
    306   HASH JOIN RIGHT SEMI (cr=15081 pr=0 pw=0 time=15250 us cost=1289 size=5367480 card=89458)
    306    VIEW  VW_NSO_1 (cr=10054 pr=0 pw=0 time=203 us cost=891 size=134190 card=4473)
    306     HASH JOIN  (cr=10054 pr=0 pw=0 time=203 us cost=891 size=268380 card=4473)
 100000      TABLE ACCESS FULL PARTS_TEMP (cr=5027 pr=0 pw=0 time=30306 us cost=398 size=2683740 card=89458)
    193      VIEW  (cr=5027 pr=0 pw=0 time=3036768 us cost=402 size=2683740 card=89458)
    193       FILTER  (cr=5027 pr=0 pw=0 time=3036480 us)
  99694        SORT GROUP BY (cr=5027 pr=0 pw=0 time=26618 us cost=402 size=2683740 card=89458)
 100000         TABLE ACCESS FULL PARTS_TEMP (cr=5027 pr=0 pw=0 time=40536 us cost=398 size=2683740 card=89458)
 100000    TABLE ACCESS FULL PARTS_TEMP (cr=5027 pr=0 pw=0 time=34015 us cost=398 size=2683740 card=89458)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  asynch descriptor resize                        2        0.00          0.00
  SQL*Net message to client                       1        0.00          0.00
  SQL*Net message from client                     1        0.00          0.00

Oracle Database 11.2.0.1 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.03       0.04          0         16          0           0
Execute      1      0.21       0.20          0      15120        362         306
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2      0.24       0.24          0      15136        362         306

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 194 

Rows     Row Source Operation
-------  ---------------------------------------------------
      0  DELETE  PARTS_TEMP (cr=15120 pr=0 pw=0 time=0 us)
    306   HASH JOIN RIGHT SEMI (cr=15120 pr=0 pw=0 time=20028 us cost=1327 size=7380240 card=123004)
    306    VIEW  VW_NSO_1 (cr=10080 pr=0 pw=0 time=19215 us cost=927 size=184500 card=6150)
    306     HASH JOIN  (cr=10080 pr=0 pw=0 time=19215 us cost=927 size=369000 card=6150)
    193      VIEW  (cr=5040 pr=0 pw=0 time=2823264 us cost=404 size=3690120 card=123004)
    193       FILTER  (cr=5040 pr=0 pw=0 time=2823264 us)
  99694        SORT GROUP BY (cr=5040 pr=0 pw=0 time=29434 us cost=404 size=3690120 card=123004)
 100000         TABLE ACCESS FULL PARTS_TEMP (cr=5040 pr=0 pw=0 time=44245 us cost=398 size=3690120 card=123004)
 100000      TABLE ACCESS FULL PARTS_TEMP (cr=5040 pr=0 pw=0 time=34015 us cost=398 size=3690120 card=123004)
 100000    TABLE ACCESS FULL PARTS_TEMP (cr=5040 pr=0 pw=0 time=33119 us cost=398 size=3690120 card=123004)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  asynch descriptor resize                        2        0.00          0.00
  SQL*Net message to client                       1        0.00          0.00
  SQL*Net message from client                     1        0.00          0.00

Inserting into the PARTS table with the foreign key constraints and other constraints, as well as existing indexes:

INSERT INTO
  PARTS
SELECT
  *
FROM
  PARTS_TEMP 

Laptop running 11.2.0.1 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.01       0.01          0          1          0           0
Execute      1     10.40      10.47          0      22215     471969       99694
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2     10.42      10.49          0      22216     471969       99694

Misses in library cache during parse: 1
Misses in library cache during execute: 1
Optimizer mode: ALL_ROWS
Parsing user id: 286 
Number of plan statistics captured: 1

Rows (1st) Rows (avg) Rows (max)  Row Source Operation
---------- ---------- ----------  ---------------------------------------------------
         0          0          0  LOAD TABLE CONVENTIONAL  (cr=0 pr=0 pw=0 time=0 us)
         1          1          1   TABLE ACCESS FULL PARTS_TEMP (cr=4 pr=0 pw=0 time=0 us cost=401 size=100456986 card=82477)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  rdbms ipc reply                                 8        0.00          0.00
  asynch descriptor resize                        8        0.00          0.00
  log file sync                                   1        0.00          0.00
  SQL*Net message to client                       1        0.00          0.00
  SQL*Net message from client                     1        0.01          0.01  

Oracle Database 10.2.0.5 Standard Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.00       0.01          0          1          0           0
Execute      1      3.10      11.63          0      26941     515900       99694
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2      3.10      11.64          0      26942     515900       99694

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 47 

Rows     Row Source Operation
-------  ---------------------------------------------------
  99694  TABLE ACCESS FULL PARTS_TEMP (cr=5040 pr=0 pw=0 time=39 us)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  log file switch completion                      7        1.01          3.35
  log file switch (checkpoint incomplete)        10        1.01          4.51
  log buffer space                                3        0.02          0.05
  log file sync                                   1        0.00          0.00
  SQL*Net message to client                       1        0.00          0.00
  SQL*Net message from client                     1        0.07          0.07

Oracle Database 10.2.0.5 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.01       0.01          0          1          0           0
Execute      1      3.15       4.06          0      26675     516513       99694
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2      3.16       4.07          0      26676     516513       99694

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 164 

Rows     Row Source Operation
-------  ---------------------------------------------------
  99694  TABLE ACCESS FULL PARTS_TEMP (cr=5040 pr=0 pw=0 time=46 us)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  log buffer space                                4        0.38          0.49
  log file sync                                   1        0.00          0.00
  SQL*Net message to client                       1        0.00          0.00
  SQL*Net message from client                     1        0.00          0.00

Oracle Database 11.2.0.1 Standard Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.03       0.02          0          1          0           0
Execute      1      2.85       3.87          0      23790     513495       99694
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2      2.88       3.89          0      23791     513495       99694

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 51 

Rows     Row Source Operation
-------  ---------------------------------------------------
      0  LOAD TABLE CONVENTIONAL  (cr=25258 pr=0 pw=0 time=0 us)
  99694   TABLE ACCESS FULL PARTS_TEMP (cr=5027 pr=0 pw=0 time=58484 us cost=404 size=108570084 card=89138)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  log buffer space                                9        0.17          0.76
  log file sync                                   1        0.05          0.05
  SQL*Net message to client                       1        0.00          0.00
  SQL*Net message from client                     1        0.00          0.00

Oracle Database 11.2.0.1 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.01       0.02          0          1          0           0
Execute      1      2.91       4.13          0      23688     517295       99694
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2      2.93       4.16          0      23689     517295       99694

Misses in library cache during parse: 1
Misses in library cache during execute: 1
Optimizer mode: ALL_ROWS
Parsing user id: 194 

Rows     Row Source Operation
-------  ---------------------------------------------------
      0  LOAD TABLE CONVENTIONAL  (cr=0 pr=0 pw=0 time=0 us)
      1   TABLE ACCESS FULL PARTS_TEMP (cr=4 pr=0 pw=0 time=0 us cost=407 size=149527770 card=122765)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  asynch descriptor resize                        8        0.00          0.00
  log buffer space                               17        0.18          1.14
  log file sync                                   1        0.02          0.02
  SQL*Net message to client                       1        0.00          0.00
  SQL*Net message from client                     1        0.00          0.00

Setting the warehouse and location for the parts in the PARTS table:

UPDATE
  PARTS P
SET
  (PRIMARY_WHS_ID,PRIMARY_LOC_ID)=(
    SELECT
      WAREHOUSE_ID,
      LOCATION_ID
    FROM
      (SELECT
        WAREHOUSE_ID,
        LOCATION_ID,
        ROWNUM RN
      FROM
        LOCATIONS)
    WHERE
      MOD(P.ORDER_POINT,2000)=RN) 

Laptop running 11.2.0.1 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.01       0.01          0          1          0           0
Execute      1    111.50     111.65          0    2131063     220890       99694
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2    111.52     111.67          0    2131064     220890       99694

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 286 
Number of plan statistics captured: 1

Rows (1st) Rows (avg) Rows (max)  Row Source Operation
---------- ---------- ----------  ---------------------------------------------------
         0          0          0  UPDATE  PARTS (cr=2003912 pr=0 pw=0 time=0 us)
    205731     205731     205731   TABLE ACCESS FULL PARTS (cr=10314 pr=0 pw=0 time=233967 us cost=396 size=3436164 card=110844)
    105985     105985     105985   VIEW  (cr=2120740 pr=0 pw=0 time=0 us cost=3 size=68200 card=2200)
 233281400  233281400  233281400    COUNT  (cr=2120740 pr=0 pw=0 time=49388820 us)
 233281400  233281400  233281400     INDEX FAST FULL SCAN SYS_C0024962 (cr=2120740 pr=0 pw=0 time=27487736 us cost=3 size=41800 card=2200)(object id 82045)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                       1        0.00          0.00
  SQL*Net message from client                     1        0.01          0.01 

Oracle Database 10.2.0.5 Standard Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.01       0.01          0          1          0           0
Execute      1    185.62     185.65          0    3273130     490125       99694
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2    185.64     185.66          0    3273131     490125       99694

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 47 

  Rows     Row Source Operation
  -------  ---------------------------------------------------
        0  UPDATE  PARTS (cr=1704883 pr=0 pw=0 time=96171788 us)
   291367   TABLE ACCESS FULL PARTS (cr=14687 pr=0 pw=0 time=291444 us)
   191580   VIEW  (cr=3258441 pr=0 pw=0 time=181333700 us)
421680600    COUNT  (cr=3258441 pr=0 pw=0 time=1555388 us)
421680600     INDEX FAST FULL SCAN SYS_C004567 (cr=3258441 pr=0 pw=0 time=1482697 us)(object id 47888)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  log file switch completion                      2        0.02          0.03
  SQL*Net message to client                       1        0.00          0.00
  SQL*Net message from client                     1        0.04          0.04

Oracle Database 10.2.0.5 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows

------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.01       0.00          0          1          0           0
Execute      1    101.22     101.26          0    1800041     223772       99694
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2    101.24     101.27          0    1800042     223772       99694

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 164 

  Rows     Row Source Operation
  -------  ---------------------------------------------------
        0  UPDATE  PARTS (cr=1704883 pr=0 pw=0 time=96199569 us)
   204969   TABLE ACCESS FULL PARTS (cr=10364 pr=0 pw=0 time=69 us)
   105224   VIEW  (cr=1789675 pr=0 pw=0 time=99082917 us)
231605000    COUNT  (cr=1789675 pr=0 pw=0 time=920840 us)
231605000     INDEX FAST FULL SCAN SYS_C0012074 (cr=1789675 pr=0 pw=0 time=882985 us)(object id 51693)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  log file switch completion                      2        0.02          0.04
  SQL*Net message to client                       1        0.00          0.00
  SQL*Net message from client                     1        0.00          0.00

Oracle Database 11.2.0.1 Standard Edition:

call     count       cpu    elapsed       disk      query    current        rows

------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.03       0.02          0          1          0           0
Execute      1    185.57     185.57          0    3300666     462095       99694
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2    185.60     185.59          0    3300667     462095       99694

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 51 

  Rows     Row Source Operation
  -------  ---------------------------------------------------
        0  UPDATE  PARTS (cr=1804551 pr=0 pw=0 time=0 us)
   282275   TABLE ACCESS FULL PARTS (cr=14206 pr=0 pw=0 time=358592 us cost=401 size=3466482 card=111822)
   182491   VIEW  (cr=3286458 pr=0 pw=0 time=0 us cost=3 size=68200 card=2200)
401678200    COUNT  (cr=3286458 pr=0 pw=0 time=81721128 us)
401678200     INDEX FAST FULL SCAN SYS_C009200 (cr=3286458 pr=0 pw=0 time=43336740 us cost=3 size=41800 card=2200)(object id 20300)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                       1        0.00          0.00
  SQL*Net message from client                     1        0.00          0.00

Oracle Database 11.2.0.1 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.03       0.02          0          1          0           0
Execute      1    199.94     199.95          0    3426213     483539       99694
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2    199.97     199.98          0    3426214     483539       99694

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 194 

  Rows     Row Source Operation
  -------  ---------------------------------------------------
        0  UPDATE  PARTS (cr=1804577 pr=0 pw=0 time=0 us)
   289229   TABLE ACCESS FULL PARTS (cr=14581 pr=0 pw=0 time=375661 us cost=400 size=3020795 card=97445)
   189443   VIEW  (cr=3411630 pr=0 pw=0 time=0 us cost=3 size=68200 card=2200)
416977000    COUNT  (cr=3411630 pr=0 pw=0 time=86533192 us)
416977000     INDEX FAST FULL SCAN SYS_C0024649 (cr=3411630 pr=0 pw=0 time=46295536 us cost=3 size=41800 card=2200)(object id 83195)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                       1        0.00          0.00
  SQL*Net message from client                     1        0.00          0.00

Inserting into the header level detail table for purchase orders from the temporary holding table that was initially set up, several check constraints on this table:

INSERT INTO
  PO_HEADER
SELECT
  *
FROM
  PO_HEADER_TEMP 

Laptop running 11.2.0.1 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.01       0.01          0          1          0           0
Execute      1     60.52      60.68          0      75970    3853984      500000
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2     60.54      60.70          0      75971    3853984      500000

Misses in library cache during parse: 1
Misses in library cache during execute: 1
Optimizer mode: ALL_ROWS
Parsing user id: 286 
Number of plan statistics captured: 1

Rows (1st) Rows (avg) Rows (max)  Row Source Operation
---------- ---------- ----------  ---------------------------------------------------
         0          0          0  LOAD TABLE CONVENTIONAL  (cr=0 pr=0 pw=0 time=0 us)
         1          1          1   TABLE ACCESS FULL PO_HEADER_TEMP (cr=4 pr=0 pw=0 time=0 us cost=1060 size=402093498 card=412827)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  rdbms ipc reply                                 5        0.00          0.00
  asynch descriptor resize                        5        0.00          0.00
  log file switch completion                      1        0.00          0.00
  log file sync                                   1        0.00          0.00
  SQL*Net message to client                       1        0.00          0.00
  SQL*Net message from client                     1        0.00          0.00 

Oracle Database 10.2.0.5 Standard Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.01       0.00          0          1          0           0
Execute      1     13.97      56.05          0      75785    3954396      500000
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2     13.99      56.06          0      75786    3954396      500000

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 47 

Rows     Row Source Operation
-------  ---------------------------------------------------
 500000  TABLE ACCESS FULL PO_HEADER_TEMP (cr=13190 pr=0 pw=0 time=21 us)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  log file switch completion                     26        1.01         12.10
  log file switch (checkpoint incomplete)        55        1.01         27.12
  log buffer space                                5        0.12          0.25
  rdbms ipc reply                                34        0.00          0.00
  control file sequential read                   68        0.36          0.84
  db file sequential read                         8        0.02          0.02
  Data file init write                           44        0.01          0.13
  direct path sync                                4        0.00          0.00
  db file single write                            4        0.00          0.00
  control file parallel write                    12        0.00          0.00
  log file sync                                   1        0.00          0.00
  SQL*Net message to client                       1        0.00          0.00
  SQL*Net message from client                     1        0.02          0.02 

Oracle Database 10.2.0.5 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows

------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.01       0.00          0          1          0           0
Execute      1     13.93      29.44          0      73557    3946136      500000
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2     13.94      29.45          0      73558    3946136      500000

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 164 

Rows     Row Source Operation
-------  ---------------------------------------------------
 500000  TABLE ACCESS FULL PO_HEADER_TEMP (cr=13190 pr=0 pw=0 time=22 us)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  log buffer space                               44        0.99          9.17
  log file switch completion                     13        0.44          1.42
  log file switch (checkpoint incomplete)         8        1.01          3.10
  log file sync                                   1        0.00          0.00
  SQL*Net message to client                       1        0.00          0.00
  SQL*Net message from client                     1        0.00          0.00

Oracle Database 11.2.0.1 Standard Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.01       0.02          0          1          0           0
Execute      1     12.71      15.53          0      72026    3962055      500000
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2     12.72      15.55          0      72027    3962055      500000

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 51 

Rows     Row Source Operation
-------  ---------------------------------------------------
      0  LOAD TABLE CONVENTIONAL  (cr=73940 pr=0 pw=0 time=0 us)
 500000   TABLE ACCESS FULL PO_HEADER_TEMP (cr=13190 pr=0 pw=0 time=222932 us cost=1144 size=474746106 card=487419)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  log buffer space                               36        0.18          2.01
  log file switch completion                      4        0.27          0.56
  log file sync                                   1        0.15          0.15
  SQL*Net message to client                       1        0.00          0.00
  SQL*Net message from client                     1        0.00          0.00

Oracle Database 11.2.0.1 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.03       0.02          0          1          0           0
Execute      1     12.65      17.11          0      71508    3958260      500000
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2     12.68      17.13          0      71509    3958260      500000

Misses in library cache during parse: 1
Misses in library cache during execute: 1
Optimizer mode: ALL_ROWS
Parsing user id: 194 

Rows     Row Source Operation
-------  ---------------------------------------------------
      0  LOAD TABLE CONVENTIONAL  (cr=0 pr=0 pw=0 time=0 us)
      1   TABLE ACCESS FULL PO_HEADER_TEMP (cr=4 pr=0 pw=0 time=0 us cost=1147 size=516390450 card=530175)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  asynch descriptor resize                        5        0.00          0.00
  log buffer space                               62        0.29          3.91
  log file switch (private strand flush incomplete)
                                                  2        0.10          0.19
  log file switch completion                      1        0.06          0.06
  log file sync                                   1        0.00          0.00
  SQL*Net message to client                       1        0.00          0.00
  SQL*Net message from client                     1        0.00          0.00   

Inserting more than 12 million rows into a table before inserting those rows into the table with the constraints and indexes:

INSERT INTO PO_LINE_TEMP (
  PURC_ORDER_ID,
  LINE_NO,
  PART_ID,
...
  FULFILLED_QTY)
SELECT /*+ ORDERED */
  PURC_ORDER_ID,
  ORDER_POINT-START_LINE+1,
  PART_ID,
...
FROM
  (SELECT
    'PO'||TO_CHAR(ROWNUM) PURC_ORDER_ID,
    ROWNUM RN,
    ABS(SIN(ROWNUM*3.14159265/180))*90000 START_LINE,
    MOD(ROWNUM,50)+1 LINES
  FROM
    DUAL
  CONNECT BY
    LEVEL<=500000) POL,
  PARTS P
WHERE
  P.ORDER_POINT BETWEEN START_LINE AND (START_LINE+LINES-1) 

Laptop running 11.2.0.1 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.03       0.02          0          0          0           0
Execute      1     93.07      95.64          0    1924137    1376229    12205347
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2     93.10      95.67          0    1924137    1376229    12205347

Misses in library cache during parse: 1
Misses in library cache during execute: 1
Optimizer mode: ALL_ROWS
Parsing user id: 286 
Number of plan statistics captured: 1

Rows (1st) Rows (avg) Rows (max)  Row Source Operation
---------- ---------- ----------  ---------------------------------------------------
         0          0          0  LOAD TABLE CONVENTIONAL  (cr=0 pr=0 pw=0 time=0 us)
         1          1          1   COUNT  (cr=3 pr=0 pw=0 time=0 us)
         1          1          1    NESTED LOOPS  (cr=3 pr=0 pw=0 time=0 us)
         1          1          1     NESTED LOOPS  (cr=2 pr=0 pw=0 time=0 us cost=26 size=19422 card=249)
         1          1          1      VIEW  (cr=0 pr=0 pw=0 time=0 us cost=2 size=49 card=1)
         1          1          1       COUNT  (cr=0 pr=0 pw=0 time=0 us)
         1          1          1        CONNECT BY WITHOUT FILTERING (cr=0 pr=0 pw=0 time=0 us)
         1          1          1         FAST DUAL  (cr=0 pr=0 pw=0 time=0 us cost=2 size=0 card=1)
         1          1          1      INDEX RANGE SCAN IND_PARTS_7 (cr=2 pr=0 pw=0 time=0 us cost=1 size=0 card=449)(object id 82060)
         1          1          1     TABLE ACCESS BY INDEX ROWID PARTS (cr=1 pr=0 pw=0 time=0 us cost=24 size=7221 card=249)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  log file switch (private strand flush incomplete)
                                                  2        0.00          0.01
  latch: object queue header operation            5        0.00          0.00
  log file switch completion                      4        0.04          0.09
  log buffer space                                2        1.41          1.45
  SQL*Net message to client                       1        0.00          0.00
  SQL*Net message from client                     1       53.66         53.66 

Oracle Database 10.2.0.5 Standard Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.01       0.04          0          0          0           0
Execute      1     91.10     231.44          0    2573862    2165886    12205347
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2     91.12     231.49          0    2573862    2165886    12205347

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 47 

 Rows     Row Source Operation
 -------  ---------------------------------------------------
12205347  COUNT  (cr=2136585 pr=0 pw=0 time=24410743 us)
12205347   NESTED LOOPS  (cr=2136585 pr=0 pw=0 time=24425909 us)
  500000    VIEW  (cr=0 pr=0 pw=0 time=8000015 us)
  500000     COUNT  (cr=0 pr=0 pw=0 time=500012 us)
  500000      CONNECT BY WITHOUT FILTERING (cr=0 pr=0 pw=0 time=500354 us)
       1       FAST DUAL  (cr=0 pr=0 pw=0 time=0 us)
12205347    TABLE ACCESS BY INDEX ROWID PARTS (cr=2136585 pr=0 pw=0 time=15311808 us)
12205347     INDEX RANGE SCAN IND_PARTS_7 (cr=532876 pr=0 pw=0 time=2172989 us)(object id 47903)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  log file switch completion                     97        1.01         39.20
  log file switch (checkpoint incomplete)       168        1.01         95.13
  control file sequential read                  187        0.72          2.68
  db file sequential read                        22        0.06          0.12
  Data file init write                           66        0.04          0.49
  direct path sync                               11        0.00          0.00
  db file single write                           11        0.00          0.00
  control file parallel write                    33        0.00          0.00
  rdbms ipc reply                                11        0.00          0.00
  log buffer space                                2        0.48          0.56
  SQL*Net message to client                       1        0.00          0.00
  SQL*Net message from client                     1        0.04          0.04

Oracle Database 10.2.0.5 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.03       0.04          0          0          0           0
Execute      1     88.98     142.98          4    2615674    2163468    12205347
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2     89.01     143.02          4    2615674    2163468    12205347

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 164 

 Rows     Row Source Operation
 -------  ---------------------------------------------------
12205347  COUNT  (cr=2137204 pr=4 pw=0 time=24410741 us)
12205347   NESTED LOOPS  (cr=2137204 pr=4 pw=0 time=24426124 us)
  500000    VIEW  (cr=0 pr=0 pw=0 time=8000012 us)
  500000     COUNT  (cr=0 pr=0 pw=0 time=500012 us)
  500000      CONNECT BY WITHOUT FILTERING (cr=0 pr=0 pw=0 time=500341 us)
       1       FAST DUAL  (cr=0 pr=0 pw=0 time=1 us)
12205347    TABLE ACCESS BY INDEX ROWID PARTS (cr=2137204 pr=4 pw=0 time=16373725 us)
12205347     INDEX RANGE SCAN IND_PARTS_7 (cr=533368 pr=0 pw=0 time=2101123 us)(object id 51708)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  log file switch completion                     52        1.00         14.60
  log buffer space                              118        1.00         18.55
  log file switch (checkpoint incomplete)        30        1.01         13.35
  db file sequential read                         4        0.60          1.23
  latch: object queue header operation            1        0.00          0.00
  SQL*Net message to client                       1        0.00          0.00
  SQL*Net message from client                     1        0.00          0.00

Oracle Database 11.2.0.1 Standard Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.03       0.03          0          0          0           0
Execute      1     83.00     100.61          0    2554010    2164473    12205347
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2     83.03     100.65          0    2554010    2164473    12205347

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 51 

 Rows     Row Source Operation
 -------  ---------------------------------------------------
       0  LOAD TABLE CONVENTIONAL  (cr=2555697 pr=0 pw=0 time=0 us)
12205347   COUNT  (cr=2070136 pr=0 pw=0 time=30568852 us)
12205347    NESTED LOOPS  (cr=2070136 pr=0 pw=0 time=28919458 us)
12205347     NESTED LOOPS  (cr=521689 pr=0 pw=0 time=15529864 us cost=44 size=19422 card=249)
  500000      VIEW  (cr=0 pr=0 pw=0 time=8116185 us cost=2 size=49 card=1)
  500000       COUNT  (cr=0 pr=0 pw=0 time=828383 us)
  500000        CONNECT BY WITHOUT FILTERING (cr=0 pr=0 pw=0 time=744494 us)
       1         FAST DUAL  (cr=0 pr=0 pw=0 time=0 us cost=2 size=0 card=1)
12205347      INDEX RANGE SCAN IND_PARTS_7 (cr=521689 pr=0 pw=0 time=4129164 us cost=2 size=0 card=449)(object id 20315)
12205347     TABLE ACCESS BY INDEX ROWID PARTS (cr=1548447 pr=0 pw=0 time=0 us cost=42 size=7221 card=249)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  log file switch completion                      4        0.49          0.80
  log buffer space                               43        1.55         15.66
  latch: object queue header operation            1        0.00          0.00
  SQL*Net message to client                       1        0.00          0.00
  SQL*Net message from client                     1        0.00          0.00

Oracle Database 11.2.0.1 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.03       0.03          0          0          0           0
Execute      1     84.80     107.84          0    2613657    2162650    12205347
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2     84.83     107.87          0    2613657    2162650    12205347

Misses in library cache during parse: 1
Misses in library cache during execute: 1
Optimizer mode: ALL_ROWS
Parsing user id: 194 

Rows     Row Source Operation
-------  ---------------------------------------------------
      0  LOAD TABLE CONVENTIONAL  (cr=0 pr=0 pw=0 time=0 us)
      1   COUNT  (cr=3 pr=0 pw=0 time=0 us)
      1    NESTED LOOPS  (cr=3 pr=0 pw=0 time=0 us)
      1     NESTED LOOPS  (cr=2 pr=0 pw=0 time=0 us cost=47 size=19422 card=249)
      1      VIEW  (cr=0 pr=0 pw=0 time=0 us cost=2 size=49 card=1)
      1       COUNT  (cr=0 pr=0 pw=0 time=0 us)
      1        CONNECT BY WITHOUT FILTERING (cr=0 pr=0 pw=0 time=0 us)
      1         FAST DUAL  (cr=0 pr=0 pw=0 time=0 us cost=2 size=0 card=1)
      1      INDEX RANGE SCAN IND_PARTS_7 (cr=2 pr=0 pw=0 time=0 us cost=2 size=0 card=449)(object id 83210)
      1     TABLE ACCESS BY INDEX ROWID PARTS (cr=1 pr=0 pw=0 time=0 us cost=45 size=7221 card=249)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  log buffer space                              189        0.56         20.65
  log file switch (private strand flush incomplete)
                                                  2        0.73          0.79
  log file switch completion                      3        0.15          0.37
  latch: object queue header operation            1        0.00          0.00
  SQL*Net message to client                       1        0.00          0.00
  SQL*Net message from client                     1        0.00          0.00   

Inserting more than 12 million rows into a table with several foreign keys, check constraints, and indexes:

INSERT INTO
  PO_LINE
SELECT
  *
FROM
  PO_LINE_TEMP 

Laptop running 11.2.0.1 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.00       0.01          0          1          0           0
Execute      1   1136.71    1156.64      28932    1733923  139706464    12205347
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2   1136.71    1156.66      28932    1733924  139706464    12205347

Misses in library cache during parse: 1
Misses in library cache during execute: 1
Optimizer mode: ALL_ROWS
Parsing user id: 286 
Number of plan statistics captured: 1

Rows (1st) Rows (avg) Rows (max)  Row Source Operation
---------- ---------- ----------  ---------------------------------------------------
         0          0          0  LOAD TABLE CONVENTIONAL  (cr=0 pr=0 pw=0 time=0 us)
         1          1          1   TABLE ACCESS FULL PO_LINE_TEMP (cr=4 pr=0 pw=0 time=0 us cost=20365 size=12823639038 card=11626146)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  rdbms ipc reply                               172        0.10          0.71
  asynch descriptor resize                        5        0.00          0.00
  log file switch completion                     27        0.02          0.27
  latch: object queue header operation            1        0.00          0.00
  Disk file operations I/O                      476        0.00          0.23
  control file sequential read                 3318        0.05          0.63
  db file sequential read                       696        0.07          0.40
  Data file init write                          158        0.00          0.00
  db file single write                          158        0.00          0.05
  control file parallel write                   474        0.00          0.17
  reliable message                                9        0.00          0.00
  db file scattered read                        240        0.05          0.36
  log file sync                                   1        0.00          0.00
  SQL*Net message to client                       1        0.00          0.00
  SQL*Net message from client                     1        0.00          0.00 

Oracle Database 10.2.0.5 Standard Edition:

call     count       cpu    elapsed       disk      query    current        rows

------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.01       0.00          0          1          0           0
Execute      1    353.56    2568.62     124584    1578922  141542735    12205347
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2    353.57    2568.63     124584    1578923  141542735    12205347

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 47 

Rows     Row Source Operation
-------  ---------------------------------------------------
12205347  TABLE ACCESS FULL PO_LINE_TEMP (cr=249230 pr=122013 pw=0 time=305133674 us)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  control file sequential read                 3043        3.50         76.00
  db file sequential read                      2991        3.22         39.92
  Data file init write                         6414        1.84         64.88
  direct path sync                              179        0.00          0.00
  db file single write                          179        0.00          0.01
  control file parallel write                   537        0.10          0.32
  rdbms ipc reply                               199        1.49          2.48
  log file switch completion                    420        1.01        262.79
  log file switch (checkpoint incomplete)      1523        1.01       1032.99
  enq: CF - contention                            2        0.36          0.42
  log buffer space                              125        1.01         62.52
  latch: object queue header operation            3        0.00          0.00
  latch: cache buffers lru chain                  2        0.00          0.00
  db file scattered read                       1098        3.99        123.07
  log file sync                                   1        0.00          0.00
  SQL*Net message to client                       1        0.00          0.00
  SQL*Net message from client                     1        0.02          0.02
 

Oracle Database 10.2.0.5 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.00       0.01          0          1          0           0
Execute      1    353.09    1648.72     258026    1511940  141720375    12205347
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2    353.09    1648.73     258026    1511941  141720375    12205347

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 164 

Rows     Row Source Operation
-------  ---------------------------------------------------
12205347  TABLE ACCESS FULL PO_LINE_TEMP (cr=249562 pr=248589 pw=0 time=915409964 us)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  db file scattered read                       2055        4.47        345.49
  db file sequential read                      9591        4.02        434.71
  log buffer space                              111        1.01         46.34
  log file switch completion                    272        1.01         64.43
  log file switch (checkpoint incomplete)       169        1.01         94.82
  latch: object queue header operation            2        0.00          0.00
  rdbms ipc reply                               176        0.30          0.75
  control file sequential read                 1258        3.65         58.57
  Data file init write                         4959        1.85         69.14
  direct path sync                               74        0.00          0.00
  db file single write                           74        0.40          0.40
  control file parallel write                   222        1.19          1.90
  enq: CF - contention                           12        1.95          4.11
  buffer exterminate                            182        0.01          2.79
  latch: cache buffers lru chain                  2        0.00          0.00
  latch free                                      1        0.00          0.00
  log file sync                                   1        0.00          0.00
  SQL*Net message to client                       1        0.00          0.00
  SQL*Net message from client                     1        0.00          0.00

Oracle Database 11.2.0.1 Standard Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.01       0.02          0          1          0           0
Execute      1    331.28     901.42     131243    1484367  141539241    12205347
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2    331.29     901.44     131243    1484368  141539241    12205347

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 51 

 Rows     Row Source Operation
 -------  ---------------------------------------------------
       0  LOAD TABLE CONVENTIONAL  (cr=1490464 pr=131243 pw=0 time=0 us)
12205347   TABLE ACCESS FULL PO_LINE_TEMP (cr=249198 pr=128481 pw=0 time=745579520 us cost=20775 size=14111383817 card=12793639)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  log buffer space                              522        6.87        145.23
  log file switch completion                     31        4.22         11.47
  reliable message                               20        0.38          0.38
  rdbms ipc reply                                78        1.22          1.65
  Disk file operations I/O                      176        1.20          1.60
  control file sequential read                 1218        2.85         54.69
  db file sequential read                      2895        2.72         88.80
  Data file init write                           58        1.10          1.10
  db file single write                           58        0.00          0.00
  control file parallel write                   174        0.07          0.44
  latch: redo allocation                          2        0.00          0.00
  enq: CF - contention                           12        0.83          6.59
  db file scattered read                       1046        2.71        128.56
  log file sync                                   1        0.00          0.00
  SQL*Net message to client                       1        0.00          0.00
  SQL*Net message from client                     1        0.00          0.00

Oracle Database 11.2.0.1 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.03       0.02          0          1          0           0
Execute      1    327.08     777.27     260153    1483975  141436854    12205347
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2    327.11     777.29     260153    1483976  141436854    12205347

Misses in library cache during parse: 1
Misses in library cache during execute: 1
Optimizer mode: ALL_ROWS
Parsing user id: 194 

Rows     Row Source Operation
-------  ---------------------------------------------------
      0  LOAD TABLE CONVENTIONAL  (cr=0 pr=0 pw=0 time=0 us)
      1   TABLE ACCESS FULL PO_LINE_TEMP (cr=4 pr=5 pw=0 time=0 us cost=20566 size=10857297775 card=9843425)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  db file scattered read                       2055        0.82        195.44
  asynch descriptor resize                        5        0.00          0.00
  db file sequential read                     11123        0.94        222.31
  log buffer space                              115        0.38          6.49
  log file switch completion                     30        0.36          2.98
  latch: object queue header operation            1        0.00          0.00
  latch free                                      2        0.00          0.00
  reliable message                               10        0.00          0.00
  rdbms ipc reply                                29        0.09          0.15
  Disk file operations I/O                       59        0.03          0.06
  control file sequential read                  399        0.64          4.11
  Data file init write                           19        0.00          0.00
  db file single write                           19        0.00          0.00
  control file parallel write                    57        0.00          0.00
  log file sync                                   1        0.00          0.00
  SQL*Net message to client                       1        0.00          0.00
  SQL*Net message from client                     1        0.00          0.00   

Determining how many of each part was ordered in the last 90 days:

SELECT
  PO.VENDOR_ID,
  P.PRODUCT_CODE,
  P.STOCK_UM,
  SUM(POL.ORDER_QTY) ORDER_QTY
FROM
  PO_HEADER PO,
  PO_LINE POL,
  PARTS P
WHERE
  PO.ORDER_DATE BETWEEN TRUNC(SYSDATE-90) AND TRUNC(SYSDATE)
  AND PO.PURC_ORDER_ID=POL.PURC_ORDER_ID
  AND POL.PART_ID=P.PART_ID
GROUP BY
  PO.VENDOR_ID,
  P.PRODUCT_CODE,
  P.STOCK_UM 

Laptop running 11.2.0.1 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.09       0.09         28        975          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        4      3.18       4.54     267202     267225          0        2245
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        6      3.27       4.63     267230     268200          0        2245

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 286 
Number of plan statistics captured: 1

Rows (1st) Rows (avg) Rows (max)  Row Source Operation
---------- ---------- ----------  ---------------------------------------------------
      2245       2245       2245  HASH GROUP BY (cr=267225 pr=267202 pw=0 time=132 us cost=25911 size=12588193 card=172441)
    399249     399249     399249   FILTER  (cr=267225 pr=267202 pw=0 time=3877952 us)
    399249     399249     399249    HASH JOIN  (cr=267225 pr=267202 pw=0 time=3818192 us cost=21791 size=50701858 card=694546)
     99694      99694      99694     TABLE ACCESS FULL PARTS (cr=4996 pr=4989 pw=0 time=44919 us cost=394 size=2093574 card=99694)
    399249     399249     399249     HASH JOIN  (cr=262229 pr=262213 pw=0 time=3642370 us cost=20823 size=36116392 card=694546)
     16668      16668      16668      TABLE ACCESS FULL PO_HEADER (cr=13173 pr=13163 pw=0 time=905107 us cost=1068 size=785568 card=28056)
  12205347   12205347   12205347      TABLE ACCESS FULL PO_LINE (cr=249056 pr=249050 pw=0 time=2135535 us cost=19697 size=292928328 card=12205347)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                       4        0.00          0.00
  db file sequential read                         3        0.00          0.00
  db file scattered read                        172        0.00          0.32
  direct path read                              678        0.00          0.34
  asynch descriptor resize                        3        0.00          0.00
  SQL*Net message from client                     4        0.00          0.00
  SQL*Net more data to client                     5        0.00          0.00 

Oracle Database 10.2.0.5 Standard Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.00       0.26         26        917          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        4      4.13      22.17     267421     283033          0        2245
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        6      4.13      22.43     267447     283950          0        2245

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 47 

 Rows     Row Source Operation
 -------  ---------------------------------------------------
    2245  HASH GROUP BY (cr=283033 pr=267421 pw=0 time=22168922 us)
  399249   FILTER  (cr=283033 pr=267421 pw=0 time=19262355 us)
  399249    HASH JOIN  (cr=283033 pr=267421 pw=0 time=19262351 us)
   99694     TABLE ACCESS FULL PARTS (cr=5040 pr=5033 pw=0 time=7895521 us)
  399249     HASH JOIN  (cr=277993 pr=262388 pw=0 time=18091601 us)
   16668      TABLE ACCESS FULL PO_HEADER (cr=17931 pr=13180 pw=0 time=1189286 us)
12205347      TABLE ACCESS FULL PO_LINE (cr=260062 pr=249208 pw=0 time=12216877 us)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                       4        0.00          0.00
  db file sequential read                         8        0.04          0.17
  db file scattered read                       2148        0.06         17.70
  SQL*Net message from client                     4        0.00          0.00
  SQL*Net more data to client                    27        0.00          0.00

Oracle Database 10.2.0.5 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.09       0.27         39        950          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        4      4.05      30.56     267371     278582          0        2245
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        6      4.14      30.83     267410     279532          0        2245

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 164 

 Rows     Row Source Operation
 -------  ---------------------------------------------------
    2245  HASH GROUP BY (cr=278582 pr=267371 pw=0 time=30561759 us)
  399249   FILTER  (cr=278582 pr=267371 pw=0 time=14361948 us)
  399249    HASH JOIN  (cr=278582 pr=267371 pw=0 time=14361943 us)
   99694     TABLE ACCESS FULL PARTS (cr=5040 pr=5033 pw=0 time=4535877 us)
  399249     HASH JOIN  (cr=273542 pr=262338 pw=0 time=13730984 us)
   16668      TABLE ACCESS FULL PO_HEADER (cr=13190 pr=13180 pw=0 time=4023636 us)
12205347      TABLE ACCESS FULL PO_LINE (cr=260352 pr=249158 pw=0 time=12247459 us)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                       4        0.00          0.00
  db file sequential read                         8        0.04          0.19
  db file scattered read                       2145        0.83         24.42
  SQL*Net message from client                     4        0.00          0.00
  SQL*Net more data to client                    27        0.00          0.00

Oracle Database 11.2.0.1 Standard Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.07       0.16         26        948          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        4      3.05      19.97     267756     267779          0        2245
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        6      3.13      20.14     267782     268727          0        2245

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 51 

 Rows     Row Source Operation
 -------  ---------------------------------------------------
    2245  HASH GROUP BY (cr=267779 pr=267756 pw=0 time=528 us cost=26366 size=12586733 card=172421)
  399249   FILTER  (cr=267779 pr=267756 pw=0 time=16199360 us)
  399249    HASH JOIN  (cr=267779 pr=267756 pw=0 time=16159946 us cost=22250 size=50646378 card=693786)
   99694     TABLE ACCESS FULL PARTS (cr=5027 pr=5020 pw=0 time=7047105 us cost=399 size=2093574 card=99694)
  399249     HASH JOIN  (cr=262752 pr=262736 pw=0 time=16006774 us cost=21279 size=36076872 card=693786)
   16668      TABLE ACCESS FULL PO_HEADER (cr=13190 pr=13180 pw=0 time=3079960 us cost=1148 size=784700 card=28025)
12205347      TABLE ACCESS FULL PO_LINE (cr=249562 pr=249556 pw=0 time=19074670 us cost=20073 size=292928328 card=12205347)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                       4        0.00          0.00
  Disk file operations I/O                        2        0.00          0.00
  db file sequential read                        10        0.02          0.15
  db file scattered read                        179        0.06          2.35
  direct path read                             1961        0.05         14.05
  asynch descriptor resize                        3        0.00          0.00
  SQL*Net message from client                     4        0.00          0.00
  SQL*Net more data to client                     5        0.00          0.00
 

Oracle Database 11.2.0.1 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.12       0.47         30        979          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        4      2.90      19.77     267379     267391          0        2245
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        6      3.02      20.24     267409     268370          0        2245

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 194 

 Rows     Row Source Operation
 -------  ---------------------------------------------------
    2245  HASH GROUP BY (cr=267391 pr=267379 pw=0 time=792 us cost=26322 size=12589653 card=172461)
  399249   FILTER  (cr=267391 pr=267379 pw=0 time=15617891 us)
  399249    HASH JOIN  (cr=267391 pr=267379 pw=0 time=15576303 us cost=22201 size=50757922 card=695314)
   99694     TABLE ACCESS FULL PARTS (cr=5036 pr=5033 pw=0 time=3415029 us cost=399 size=2093574 card=99694)
  399249     HASH JOIN  (cr=262355 pr=262346 pw=0 time=15423001 us cost=21229 size=36156328 card=695314)
   16668      TABLE ACCESS FULL PO_HEADER (cr=13183 pr=13180 pw=0 time=6721890 us cost=1148 size=786436 card=28087)
12205347      TABLE ACCESS FULL PO_LINE (cr=249172 pr=249166 pw=0 time=3846626 us cost=20023 size=292928328 card=12205347)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                       4        0.00          0.00
  Disk file operations I/O                        2        0.00          0.00
  db file sequential read                         7        0.03          0.13
  direct path read                             2030        0.08         16.32
  asynch descriptor resize                        6        0.00          0.00
  db file scattered read                          2        0.02          0.04
  SQL*Net message from client                     4        0.00          0.00
  SQL*Net more data to client                     5        0.00          0.00   

Determining the last date each C level (defines the frequency of purchase with the purchase cost) for parts with a product code of FG:

SELECT
  POL.PART_ID,
  P.DESCRIPTION,
  MAX(DESIRED_RECV_DATE) LAST_RECEIVE_DATE
FROM
  PO_LINE POL,
  PARTS P
WHERE
  P.PRODUCT_CODE='FG'
  AND P.ABC_CODE='C'
  AND P.PART_ID=POL.PART_ID
GROUP BY
  POL.PART_ID,
  P.DESCRIPTION 

Laptop running 11.2.0.1 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.03       0.02          0          9          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        3      4.61       5.10     249049     254052          0        1815
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        5      4.64       5.13     249049     254061          0        1815

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 286 
Number of plan statistics captured: 1

Rows (1st) Rows (avg) Rows (max)  Row Source Operation
---------- ---------- ----------  ---------------------------------------------------
      1815       1815       1815  HASH GROUP BY (cr=254052 pr=249049 pw=0 time=388 us cost=20819 size=250514 card=4246)
      1815       1815       1815   HASH JOIN  (cr=254052 pr=249049 pw=0 time=1814 us cost=20818 size=250514 card=4246)
      4246       4246       4246    VIEW  VW_GBC_5 (cr=249056 pr=249049 pw=0 time=998 us cost=20420 size=89166 card=4246)
      4246       4246       4246     HASH GROUP BY (cr=249056 pr=249049 pw=0 time=499 us cost=20420 size=84920 card=4246)
  12205347   12205347   12205347      TABLE ACCESS FULL PO_LINE (cr=249056 pr=249049 pw=0 time=2001392 us cost=19811 size=244106940 card=12205347)
     42727      42727      42727    TABLE ACCESS FULL PARTS (cr=4996 pr=0 pw=0 time=21874 us cost=398 size=252548 card=6646)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                       3        0.00          0.00
  direct path read                               84        0.00          0.04
  asynch descriptor resize                        3        0.00          0.00
  SQL*Net message from client                     3        0.00          0.00
  SQL*Net more data to client                     7        0.00          0.00 

Oracle Database 10.2.0.5 Standard Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.00       0.02          0          9          0           0
Execute      1      0.00       0.01          0          0          0           0
Fetch        3      6.25       6.26          0     254270          0        1815
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        5      6.25       6.30          0     254279          0        1815

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 47 

 Rows     Row Source Operation
 -------  ---------------------------------------------------
    1815  HASH GROUP BY (cr=254270 pr=0 pw=0 time=6274965 us)
 5203352   HASH JOIN  (cr=254270 pr=0 pw=0 time=35124 us)
   42727    TABLE ACCESS FULL PARTS (cr=5040 pr=0 pw=0 time=24 us)
12205347    TABLE ACCESS FULL PO_LINE (cr=249230 pr=0 pw=0 time=19 us)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                       3        0.00          0.00
  SQL*Net message from client                     3        0.00          0.00
  SQL*Net more data to client                    36        0.00          0.00

Oracle Database 10.2.0.5 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.00       0.01          0          9          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        3      6.41       9.64     109023     254220          0        1815
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        5      6.41       9.65     109023     254229          0        1815

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 164 

 Rows     Row Source Operation
 -------  ---------------------------------------------------
    1815  HASH GROUP BY (cr=254220 pr=109023 pw=0 time=9646123 us)
 5203352   HASH JOIN  (cr=254220 pr=109023 pw=0 time=5238045 us)
   42727    TABLE ACCESS FULL PARTS (cr=5040 pr=0 pw=0 time=26 us)
12205347    TABLE ACCESS FULL PO_LINE (cr=249180 pr=109023 pw=0 time=21 us)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                       3        0.00          0.00
  db file sequential read                        10        0.01          0.02
  db file scattered read                        906        0.04          3.16
  SQL*Net message from client                     3        0.00          0.00
  SQL*Net more data to client                    36        0.00          0.00

Oracle Database 11.2.0.1 Standard Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.00       0.05          1          9          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        3      4.64      17.70     249545     254589          0        1815
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        5      4.64      17.76     249546     254598          0        1815

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 51 

 Rows     Row Source Operation
 -------  ---------------------------------------------------
    1815  HASH GROUP BY (cr=254589 pr=249545 pw=0 time=259 us cost=21200 size=250514 card=4246)
    1815   HASH JOIN  (cr=254589 pr=249545 pw=0 time=967 us cost=21199 size=250514 card=4246)
    4246    VIEW  VW_GBC_5 (cr=249562 pr=249545 pw=0 time=1747 us cost=20796 size=89166 card=4246)
    4246     HASH GROUP BY (cr=249562 pr=249545 pw=0 time=1123 us cost=20796 size=84920 card=4246)
12205347      TABLE ACCESS FULL PO_LINE (cr=249562 pr=249545 pw=0 time=16761216 us cost=20188 size=244106940 card=12205347)
   42727    TABLE ACCESS FULL PARTS (cr=5027 pr=0 pw=0 time=24305 us cost=402 size=252548 card=6646)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                       3        0.00          0.00
  direct path read                             1955        0.05         12.83
  asynch descriptor resize                        3        0.00          0.00
  SQL*Net message from client                     3        0.00          0.00
  SQL*Net more data to client                     7        0.00          0.00

Oracle Database 11.2.0.1 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.00       0.05          1          9          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        3      4.92      15.73     254188     254212          0        1815
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        5      4.92      15.79     254189     254221          0        1815

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 194 

 Rows     Row Source Operation
 -------  ---------------------------------------------------
    1815  HASH GROUP BY (cr=254212 pr=254188 pw=0 time=388 us cost=21149 size=250514 card=4246)
    1815   HASH JOIN  (cr=254212 pr=254188 pw=0 time=8465 us cost=21148 size=250514 card=4246)
    4246    VIEW  VW_GBC_5 (cr=249172 pr=249156 pw=0 time=1123 us cost=20746 size=89166 card=4246)
    4246     HASH GROUP BY (cr=249172 pr=249156 pw=0 time=374 us cost=20746 size=84920 card=4246)
12205347      TABLE ACCESS FULL PO_LINE (cr=249172 pr=249156 pw=0 time=3973985 us cost=20138 size=244106940 card=12205347)
   42727    TABLE ACCESS FULL PARTS (cr=5040 pr=5032 pw=0 time=18548 us cost=402 size=252548 card=6646)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                       3        0.00          0.00
  direct path read                             1889        0.08         10.13
  asynch descriptor resize                        4        0.00          0.00
  db file scattered read                         55        0.04          0.94
  SQL*Net message from client                     3        0.00          0.00
  SQL*Net more data to client                     7        0.00          0.00   

For those parts in warehouses with more than 160 warehouse locations, determines the number of parts with each distinct product code that resides in the warehouse: 

SELECT
  PRODUCT_CODE,
  COUNT(*) PARTS_LARGE_WH
FROM
  (SELECT
    WAREHOUSE_ID
  FROM
    LOCATIONS
  GROUP BY
    WAREHOUSE_ID
  HAVING
    COUNT(*)>160) W,
  PARTS P
WHERE
  W.WAREHOUSE_ID=P.PRIMARY_WHS_ID
GROUP BY
  PRODUCT_CODE
ORDER BY
  PRODUCT_CODE 

Laptop running 11.2.0.1 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.03       0.02          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        2      0.04       0.04         16       5016          0           5
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        4      0.07       0.07         16       5016          0           5

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 286 
Number of plan statistics captured: 1

Rows (1st) Rows (avg) Rows (max)  Row Source Operation
---------- ---------- ----------  ---------------------------------------------------
         5          5          5  SORT GROUP BY (cr=5016 pr=16 pw=0 time=0 us cost=402 size=115 card=5)
     37891      37891      37891   HASH JOIN  (cr=5016 pr=16 pw=0 time=35338 us cost=401 size=120612 card=5244)
         4          4          4    VIEW  (cr=20 pr=16 pw=0 time=6 us cost=4 size=9 card=1)
         4          4          4     FILTER  (cr=20 pr=16 pw=0 time=6 us)
        20         20         20      HASH GROUP BY (cr=20 pr=16 pw=0 time=19 us cost=4 size=9 card=1)
      2200       2200       2200       INDEX FAST FULL SCAN SYS_C0024962 (cr=20 pr=16 pw=0 time=244 us cost=3 size=19800 card=2200)(object id 82045)
     99694      99694      99694    TABLE ACCESS FULL PARTS (cr=4996 pr=0 pw=0 time=39416 us cost=396 size=1395716 card=99694)

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                         1        0.00          0.00
  db file scattered read                          2        0.00          0.00
  asynch descriptor resize                        1        0.00          0.00
  SQL*Net message from client                     2        0.00          0.00 

Oracle Database 10.2.0.5 Standard Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.01       0.09          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        2      0.04       0.09         14       5057          0           5
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        4      0.06       0.18         14       5057          0           5

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 47 

Rows     Row Source Operation
-------  ---------------------------------------------------
      5  SORT GROUP BY (cr=5057 pr=14 pw=0 time=90608 us)
  36233   HASH JOIN  (cr=5057 pr=14 pw=0 time=83180 us)
      4    VIEW  (cr=17 pr=14 pw=0 time=46755 us)
      4     FILTER  (cr=17 pr=14 pw=0 time=46754 us)
     20      HASH GROUP BY (cr=17 pr=14 pw=0 time=46769 us)
   2200       INDEX FAST FULL SCAN SYS_C004567 (cr=17 pr=14 pw=0 time=25602 us)(object id 47888)
  99694    TABLE ACCESS FULL PARTS (cr=5040 pr=0 pw=0 time=18 us)

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                         1        0.02          0.02
  db file scattered read                          2        0.02          0.02
  SQL*Net message from client                     2        0.00          0.00 

Oracle Database 10.2.0.5 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.01       0.02          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        2      0.04       0.14         14       5057          0           5
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        4      0.06       0.16         14       5057          0           5

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 164 

Rows     Row Source Operation
-------  ---------------------------------------------------
      5  SORT GROUP BY (cr=5057 pr=14 pw=0 time=147128 us)
  36229   HASH JOIN  (cr=5057 pr=14 pw=0 time=140062 us)
      4    VIEW  (cr=17 pr=14 pw=0 time=103639 us)
      4     FILTER  (cr=17 pr=14 pw=0 time=103639 us)
     20      HASH GROUP BY (cr=17 pr=14 pw=0 time=103633 us)
   2200       INDEX FAST FULL SCAN SYS_C0012074 (cr=17 pr=14 pw=0 time=58040 us)(object id 51693)
  99694    TABLE ACCESS FULL PARTS (cr=5040 pr=0 pw=0 time=20 us)

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                         1        0.01          0.01
  db file scattered read                          2        0.04          0.08
  SQL*Net message from client                     2        0.00          0.00

Oracle Database 11.2.0.1 Standard Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.01       0.03          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        2      0.04       0.08         14       5045          0           5
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        4      0.06       0.11         14       5045          0           5

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 51 

Rows     Row Source Operation
-------  ---------------------------------------------------
      5  SORT GROUP BY (cr=5045 pr=14 pw=0 time=0 us cost=406 size=115 card=5)
  37881   HASH JOIN  (cr=5045 pr=14 pw=0 time=42870 us cost=405 size=120612 card=5244)
      4    VIEW  (cr=18 pr=14 pw=0 time=6 us cost=4 size=9 card=1)
      4     FILTER  (cr=18 pr=14 pw=0 time=3 us)
     20      HASH GROUP BY (cr=18 pr=14 pw=0 time=19 us cost=4 size=9 card=1)
   2200       INDEX FAST FULL SCAN SYS_C009200 (cr=18 pr=14 pw=0 time=0 us cost=3 size=19800 card=2200)(object id 20300)
  99694    TABLE ACCESS FULL PARTS (cr=5027 pr=0 pw=0 time=36473 us cost=400 size=1395716 card=99694)

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                         1        0.01          0.01
  db file scattered read                          2        0.01          0.02
  asynch descriptor resize                        1        0.00          0.00
  SQL*Net message from client                     2        0.00          0.00 

Oracle Database 11.2.0.1 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.03       0.03          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        2      0.04       0.06         14       5058          0           5
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        4      0.07       0.10         14       5058          0           5

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 194 

Rows     Row Source Operation
-------  ---------------------------------------------------
      5  SORT GROUP BY (cr=5058 pr=14 pw=0 time=0 us cost=406 size=115 card=5)
  37897   HASH JOIN  (cr=5058 pr=14 pw=0 time=31261 us cost=405 size=127328 card=5536)
      4    VIEW  (cr=18 pr=14 pw=0 time=6 us cost=4 size=9 card=1)
      4     FILTER  (cr=18 pr=14 pw=0 time=3 us)
     20      HASH GROUP BY (cr=18 pr=14 pw=0 time=19 us cost=4 size=9 card=1)
   2200       INDEX FAST FULL SCAN SYS_C0024649 (cr=18 pr=14 pw=0 time=244 us cost=3 size=19800 card=2200)(object id 83195)
  99694    TABLE ACCESS FULL PARTS (cr=5040 pr=0 pw=0 time=37368 us cost=400 size=1395716 card=99694)

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                         1        0.01          0.01
  db file scattered read                          2        0.00          0.00
  asynch descriptor resize                        2        0.00          0.00
  SQL*Net message from client                     2        0.00          0.00

Simple query that finds the number of parts for which there are more than 1000 in inventory:

SELECT
  COUNT(*)
FROM
  PARTS
WHERE
  QTY_ON_HAND>1000 

Laptop running 11.2.0.1 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.01       0.01          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        2      0.03       0.02          0       4996          0           1
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        4      0.04       0.04          0       4996          0           1

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 286 
Number of plan statistics captured: 1

Rows (1st) Rows (avg) Rows (max)  Row Source Operation
---------- ---------- ----------  ---------------------------------------------------
         1          1          1  SORT AGGREGATE (cr=4996 pr=0 pw=0 time=0 us)
     98586      98586      98586   TABLE ACCESS FULL PARTS (cr=4996 pr=0 pw=0 time=29025 us cost=400 size=690879 card=98697)

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
  SQL*Net message from client                     2        0.00          0.00 

Oracle Database 10.2.0.5 Standard Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.01       0.00          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        2      0.01       0.02          0       5040          0           1
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        4      0.03       0.03          0       5040          0           1

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 47 

Rows     Row Source Operation
-------  ---------------------------------------------------
      1  SORT AGGREGATE (cr=5040 pr=0 pw=0 time=29574 us)
  98586   TABLE ACCESS FULL PARTS (cr=5040 pr=0 pw=0 time=21 us)

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
  SQL*Net message from client                     2        0.00          0.00

Oracle Database 10.2.0.5 Enterprise Edition:

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.03       0.03          0       5040          0           1
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        4      0.03       0.03          0       5040          0           1

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 164 

Rows     Row Source Operation
-------  ---------------------------------------------------
      1  SORT AGGREGATE (cr=5040 pr=0 pw=0 time=30228 us)
  98586   TABLE ACCESS FULL PARTS (cr=5040 pr=0 pw=0 time=21 us)

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
  SQL*Net message from client                     2        0.00          0.00

Oracle Database 11.2.0.1 Standard Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.01       0.01          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        2      0.03       0.03          0       5027          0           1
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        4      0.04       0.04          0       5027          0           1

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 51 

Rows     Row Source Operation
-------  ---------------------------------------------------
      1  SORT AGGREGATE (cr=5027 pr=0 pw=0 time=0 us)
  98586   TABLE ACCESS FULL PARTS (cr=5027 pr=0 pw=0 time=34396 us cost=404 size=690879 card=98697)

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
  SQL*Net message from client                     2        0.00          0.00

Oracle Database 11.2.0.1 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.01       0.01          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        2      0.03       0.02          0       5040          0           1
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        4      0.04       0.04          0       5040          0           1

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 194 

Rows     Row Source Operation
-------  ---------------------------------------------------
      1  SORT AGGREGATE (cr=5040 pr=0 pw=0 time=0 us)
  98586   TABLE ACCESS FULL PARTS (cr=5040 pr=0 pw=0 time=29665 us cost=404 size=690879 card=98697)

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
  SQL*Net message from client                     2        0.00          0.00   

Simple query that determines the vendors that have a zipcode larger than 44444:

SELECT
  COUNT(*)
FROM
  VENDORS
WHERE
  ZIPCODE>' 44444' 

Laptop running 11.2.0.1 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.01       0.01          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        2      0.01       0.05       2492       2497          0           1
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        4      0.03       0.07       2492       2497          0           1

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 286 
Number of plan statistics captured: 1

Rows (1st) Rows (avg) Rows (max)  Row Source Operation
---------- ---------- ----------  ---------------------------------------------------
         1          1          1  SORT AGGREGATE (cr=2497 pr=2492 pw=0 time=0 us)
      5528       5528       5528   TABLE ACCESS FULL VENDORS (cr=2497 pr=2492 pw=0 time=376 us cost=198 size=16289 card=2327)

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                         1        0.00          0.00
  db file scattered read                         35        0.00          0.03
  SQL*Net message from client                     2        0.00          0.00 

Oracle Database 10.2.0.5 Standard Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.01       0.01          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        2      0.01       0.61       2513       2518          0           1
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        4      0.03       0.62       2513       2518          0           1

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 47 

Rows     Row Source Operation
-------  ---------------------------------------------------
      1  SORT AGGREGATE (cr=2518 pr=2513 pw=0 time=616794 us)
   5528   TABLE ACCESS FULL VENDORS (cr=2518 pr=2513 pw=0 time=559645 us)

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                         1        0.00          0.00
  db file scattered read                         35        0.05          0.59
  SQL*Net message from client                     2        0.00          0.00

Oracle Database 10.2.0.5 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.01       0.01          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        2      0.03       0.24       2513       2518          0           1
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        4      0.04       0.25       2513       2518          0           1

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 164 

Rows     Row Source Operation
-------  ---------------------------------------------------
      1  SORT AGGREGATE (cr=2518 pr=2513 pw=0 time=247456 us)
   5528   TABLE ACCESS FULL VENDORS (cr=2518 pr=2513 pw=0 time=227501 us)

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                         1        0.01          0.01
  db file scattered read                         35        0.03          0.22
  SQL*Net message from client                     2        0.00          0.00 

Oracle Database 11.2.0.1 Standard Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.03       0.02          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        2      0.00       0.45       2500       2505          0           1
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        4      0.03       0.47       2500       2505          0           1

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 51 

Rows     Row Source Operation
-------  ---------------------------------------------------
      1  SORT AGGREGATE (cr=2505 pr=2500 pw=0 time=0 us)
   5528   TABLE ACCESS FULL VENDORS (cr=2505 pr=2500 pw=0 time=628 us cost=200 size=16289 card=2327)

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.01          0.01
  db file scattered read                         37        0.04          0.42
  SQL*Net message from client                     2        0.00          0.00 

Oracle Database 11.2.0.1 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.01       0.02          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        2      0.00       0.50       2513       2518          0           1
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        4      0.01       0.52       2513       2518          0           1

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 194 

Rows     Row Source Operation
-------  ---------------------------------------------------
      1  SORT AGGREGATE (cr=2518 pr=2513 pw=0 time=0 us)
   5528   TABLE ACCESS FULL VENDORS (cr=2518 pr=2513 pw=0 time=502 us cost=200 size=16289 card=2327)

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                         1        0.00          0.00
  db file scattered read                         35        0.04          0.46
  SQL*Net message from client                     2        0.00          0.00   

Find the number of purchase order lines for purchase orders in the range from 10000 to 20000.  The query contains an unnecessary join to the PARTS table, which the optimizer should eliminate:

SELECT
  COUNT(*)
FROM
  PO_LINE POL,
  PARTS P
WHERE
  POL.PURC_ORDER_ID BETWEEN '10000' AND '20000'
  AND POL.PART_ID=P.PART_ID 

Laptop running 11.2.0.1 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.01       0.01          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        2      0.00       0.00          3          3          0           1
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        4      0.01       0.01          3          3          0           1

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 286 
Number of plan statistics captured: 1

Rows (1st) Rows (avg) Rows (max)  Row Source Operation
---------- ---------- ----------  ---------------------------------------------------
         1          1          1  SORT AGGREGATE (cr=3 pr=3 pw=0 time=0 us)
         0          0          0   TABLE ACCESS BY INDEX ROWID PO_LINE (cr=3 pr=3 pw=0 time=0 us cost=4 size=525 card=25)
         0          0          0    INDEX RANGE SCAN SYS_C0025101 (cr=3 pr=3 pw=0 time=0 us cost=3 size=0 card=25)(object id 82070)

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                         3        0.00          0.00
  SQL*Net message from client                     2        0.00          0.00 

Oracle Database 10.2.0.5 Standard Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.03       0.00          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        2      0.00       0.09          6          4          0           1
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        4      0.03       0.10          6          4          0           1

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 47 

Rows     Row Source Operation
-------  ---------------------------------------------------
      1  SORT AGGREGATE (cr=4 pr=6 pw=0 time=91072 us)
      0   TABLE ACCESS BY INDEX ROWID PO_LINE (cr=4 pr=6 pw=0 time=91066 us)
      0    INDEX RANGE SCAN SYS_C004706 (cr=4 pr=6 pw=0 time=91066 us)(object id 47913)

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                         2        0.04          0.05
  db file scattered read                          1        0.03          0.03
  SQL*Net message from client                     2        0.00          0.00

Oracle Database 10.2.0.5 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.00       0.01          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        2      0.00       0.06          6          4          0           1
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        4      0.00       0.07          6          4          0           1

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 164 

Rows     Row Source Operation
-------  ---------------------------------------------------
      1  SORT AGGREGATE (cr=4 pr=6 pw=0 time=64632 us)
      0   TABLE ACCESS BY INDEX ROWID PO_LINE (cr=4 pr=6 pw=0 time=64623 us)
      0    INDEX RANGE SCAN SYS_C0012213 (cr=4 pr=6 pw=0 time=64623 us)(object id 51718)

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                         2        0.03          0.06
  db file scattered read                          1        0.00          0.00
  SQL*Net message from client                     2        0.00          0.00 

Oracle Database 11.2.0.1 Standard Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.01       0.01          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        2      0.00       0.06          7          4          0           1
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        4      0.01       0.08          7          4          0           1

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 51 

Rows     Row Source Operation
-------  ---------------------------------------------------
      1  SORT AGGREGATE (cr=4 pr=7 pw=0 time=0 us)
      0   TABLE ACCESS BY INDEX ROWID PO_LINE (cr=4 pr=7 pw=0 time=0 us cost=5 size=525 card=25)
      0    INDEX RANGE SCAN SYS_C009339 (cr=4 pr=7 pw=0 time=0 us cost=3 size=0 card=25)(object id 20325)

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                         3        0.02          0.06
  db file scattered read                          1        0.00          0.00
  SQL*Net message from client                     2        0.00          0.00

Oracle Database 11.2.0.1 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.01       0.01          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        2      0.00       0.04          6          4          0           1
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        4      0.01       0.06          6          4          0           1

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 194 

Rows     Row Source Operation
-------  ---------------------------------------------------
      1  SORT AGGREGATE (cr=4 pr=6 pw=0 time=0 us)
      0   TABLE ACCESS BY INDEX ROWID PO_LINE (cr=4 pr=6 pw=0 time=0 us cost=5 size=525 card=25)
      0    INDEX RANGE SCAN SYS_C0024788 (cr=4 pr=6 pw=0 time=0 us cost=3 size=0 card=25)(object id 83220)

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                         2        0.01          0.01
  db file scattered read                          1        0.02          0.02
  SQL*Net message from client                     2        0.00          0.00   

Analytic example to find statistics about related parts:

SELECT
  PART_ID,
  ABC_CODE,
  PRODUCT_CODE,
  MAX(QTY_ON_HAND) OVER (PARTITION BY PRODUCT_CODE,ABC_CODE) MAX_QTY_PRD_ABC,
  MIN(QTY_ON_HAND) OVER (PARTITION BY PRODUCT_CODE,ABC_CODE) MIN_QTY_PRD_ABC,
  DENSE_RANK() OVER (PARTITION BY PRODUCT_CODE,ABC_CODE ORDER BY QTY_ON_HAND) DR_QTY_PRD_ABC,
  DENSE_RANK() OVER (PARTITION BY PREF_VENDOR_ID ORDER BY ORDER_POINT) DR_OP_VEND
FROM
  PARTS
ORDER BY
  PART_ID 

Laptop running 11.2.0.1 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.03       0.01          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch      101      0.42       0.42          0       4996          0       99694
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total      103      0.45       0.44          0       4996          0       99694

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 286 
Number of plan statistics captured: 1

Rows (1st) Rows (avg) Rows (max)  Row Source Operation
---------- ---------- ----------  ---------------------------------------------------
     99694      99694      99694  SORT ORDER BY (cr=4996 pr=0 pw=0 time=43439 us cost=2902 size=3888066 card=99694)
     99694      99694      99694   WINDOW SORT (cr=4996 pr=0 pw=0 time=78321 us cost=2902 size=3888066 card=99694)
     99694      99694      99694    WINDOW SORT (cr=4996 pr=0 pw=0 time=89710 us cost=2902 size=3888066 card=99694)
     99694      99694      99694     TABLE ACCESS FULL PARTS (cr=4996 pr=0 pw=0 time=43511 us cost=399 size=3888066 card=99694)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                     101        0.00          0.00
  SQL*Net message from client                   101        0.00          0.16
  SQL*Net more data to client                   398        0.00          0.01 

Oracle Database 10.2.0.5 Standard Edition:

call     count       cpu    elapsed       disk      query    current        rows

------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.01       0.06          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch      101      0.45       0.41          0       5040          0       99694
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total      103      0.46       0.47          0       5040          0       99694

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 47 

Rows     Row Source Operation
-------  ---------------------------------------------------
  99694  SORT ORDER BY (cr=5040 pr=0 pw=0 time=299155 us)
  99694   WINDOW SORT (cr=5040 pr=0 pw=0 time=217786 us)
  99694    WINDOW SORT (cr=5040 pr=0 pw=0 time=662142 us)
  99694     TABLE ACCESS FULL PARTS (cr=5040 pr=0 pw=0 time=29 us)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                     101        0.00          0.00
  SQL*Net message from client                   101        0.00          0.14
  SQL*Net more data to client                  1595        0.00          0.02

Oracle Database 10.2.0.5 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.00       0.03          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch      101      0.49       0.41          0       5040          0       99694
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total      103      0.49       0.45          0       5040          0       99694

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 164 

Rows     Row Source Operation
-------  ---------------------------------------------------
  99694  SORT ORDER BY (cr=5040 pr=0 pw=0 time=295718 us)
  99694   WINDOW SORT (cr=5040 pr=0 pw=0 time=211922 us)
  99694    WINDOW SORT (cr=5040 pr=0 pw=0 time=64268 us)
  99694     TABLE ACCESS FULL PARTS (cr=5040 pr=0 pw=0 time=20 us)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                     101        0.00          0.00
  SQL*Net message from client                   101        0.00          0.14
  SQL*Net more data to client                  1595        0.00          0.02

Oracle Database 11.2.0.1 Standard Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.01       0.01          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch      101      0.40       0.41          0       5027          0       99694
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total      103      0.42       0.43          0       5027          0       99694

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 51 

Rows     Row Source Operation
-------  ---------------------------------------------------
  99694  SORT ORDER BY (cr=5027 pr=0 pw=0 time=42414 us cost=2906 size=3888066 card=99694)
  99694   WINDOW SORT (cr=5027 pr=0 pw=0 time=83568 us cost=2906 size=3888066 card=99694)
  99694    WINDOW SORT (cr=5027 pr=0 pw=0 time=91758 us cost=2906 size=3888066 card=99694)
  99694     TABLE ACCESS FULL PARTS (cr=5027 pr=0 pw=0 time=51062 us cost=403 size=3888066 card=99694)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                     101        0.00          0.00
  SQL*Net message from client                   101        0.00          0.16
  SQL*Net more data to client                   396        0.00          0.00 

Oracle Database 11.2.0.1 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.01       0.01          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch      101      0.39       0.40          0       5040          0       99694
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total      103      0.40       0.42          0       5040          0       99694

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 194 

Rows     Row Source Operation
-------  ---------------------------------------------------
  99694  SORT ORDER BY (cr=5040 pr=0 pw=0 time=47668 us cost=2906 size=3888066 card=99694)
  99694   WINDOW SORT (cr=5040 pr=0 pw=0 time=83184 us cost=2906 size=3888066 card=99694)
  99694    WINDOW SORT (cr=5040 pr=0 pw=0 time=91630 us cost=2906 size=3888066 card=99694)
  99694     TABLE ACCESS FULL PARTS (cr=5040 pr=0 pw=0 time=40824 us cost=403 size=3888066 card=99694)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                     101        0.00          0.00
  SQL*Net message from client                   101        0.00          0.17
  SQL*Net more data to client                   398        0.00          0.00   

Query to find those vendors from which we have never ordered parts with a FG product code:

SELECT
  V.VENDOR_ID,
  V.VENDOR_NAME
FROM
  VENDORS V,
  (SELECT DISTINCT
    PO.VENDOR_ID
  FROM
    PO_HEADER PO,
    PO_LINE POL,
    PARTS P
  WHERE
    PO.PURC_ORDER_ID=POL.PURC_ORDER_ID
    AND POL.PART_ID=P.PART_ID
    AND P.PRODUCT_CODE='FG') PV
WHERE
  V.VENDOR_ID=PV.VENDOR_ID(+)
  AND PV.VENDOR_ID IS NULL
ORDER BY
  V.VENDOR_ID 

Laptop running 11.2.0.1 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.04       0.05          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch       43      8.65       8.76     249049     269722          0       41120
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total       45      8.70       8.81     249049     269722          0       41120

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 286 
Number of plan statistics captured: 1

Rows (1st) Rows (avg) Rows (max)  Row Source Operation
---------- ---------- ----------  ---------------------------------------------------
     41120      41120      41120  MERGE JOIN ANTI (cr=269722 pr=249049 pw=0 time=34201 us cost=27359 size=1632120 card=40803)
     49786      49786      49786   SORT JOIN (cr=2497 pr=0 pw=0 time=15357 us cost=531 size=1443794 card=49786)
     49786      49786      49786    TABLE ACCESS FULL VENDORS (cr=2497 pr=0 pw=0 time=13566 us cost=197 size=1443794 card=49786)
      8666       8666       8666   SORT UNIQUE (cr=267225 pr=249049 pw=0 time=0 us cost=26828 size=98813 card=8983)
      8666       8666       8666    VIEW  (cr=267225 pr=249049 pw=0 time=1529 us cost=26827 size=98813 card=8983)
      8666       8666       8666     HASH UNIQUE (cr=267225 pr=249049 pw=0 time=637 us cost=26827 size=521014 card=8983)
   9176048    9176048    9176048      HASH JOIN  (cr=267225 pr=249049 pw=0 time=7566066 us cost=26218 size=707903050 card=12205225)
     74768      74768      74768       TABLE ACCESS FULL PARTS (cr=4996 pr=0 pw=0 time=16231 us cost=395 size=338963 card=19939)
  12205347   12205347   12205347       HASH JOIN  (cr=262229 pr=249049 pw=0 time=5527253 us cost=25766 size=500419227 card=12205347)
    500000     500000     500000        TABLE ACCESS FULL PO_HEADER (cr=13173 pr=0 pw=0 time=63731 us cost=1038 size=10000000 card=500000)
  12205347   12205347   12205347        TABLE ACCESS FULL PO_LINE (cr=249056 pr=249049 pw=0 time=1461748 us cost=19651 size=256312287 card=12205347)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                      43        0.00          0.00
  direct path read                                7        0.00          0.01
  asynch descriptor resize                        4        0.00          0.00
  SQL*Net message from client                    43        0.00          0.02
  SQL*Net more data to client                   124        0.00          0.00 

Oracle Database 10.2.0.5 Standard Edition:

call     count       cpu    elapsed       disk      query    current        rows

------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.00       0.09          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch       43      8.01       8.01          0     269978          0       41120
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total       45      8.01       8.11          0     269978          0       41120

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 47 

 Rows     Row Source Operation
 -------  ---------------------------------------------------
   41120  MERGE JOIN ANTI (cr=269978 pr=0 pw=0 time=7967223 us)
   49786   SORT JOIN (cr=2518 pr=0 pw=0 time=17624 us)
   49786    TABLE ACCESS FULL VENDORS (cr=2518 pr=0 pw=0 time=20 us)
    8666   SORT UNIQUE (cr=267460 pr=0 pw=0 time=7964103 us)
    8666    VIEW  (cr=267460 pr=0 pw=0 time=7943712 us)
    8666     HASH UNIQUE (cr=267460 pr=0 pw=0 time=7943710 us)
 9176048      HASH JOIN  (cr=267460 pr=0 pw=0 time=218654 us)
   74768       TABLE ACCESS FULL PARTS (cr=5040 pr=0 pw=0 time=25 us)
12205347       HASH JOIN  (cr=262420 pr=0 pw=0 time=186465 us)
  500000        TABLE ACCESS FULL PO_HEADER (cr=13190 pr=0 pw=0 time=23 us)
12205347        TABLE ACCESS FULL PO_LINE (cr=249230 pr=0 pw=0 time=22 us)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                      43        0.00          0.00
  SQL*Net message from client                    43        0.00          0.02
  SQL*Net more data to client                   610        0.00          0.00

Oracle Database 10.2.0.5 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.01       0.04          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch       43      8.48      11.12     109794     269928          0       41120
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total       45      8.50      11.16     109794     269928          0       41120

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 164 

 Rows     Row Source Operation
 -------  ---------------------------------------------------
   41120  MERGE JOIN ANTI (cr=269928 pr=109794 pw=0 time=11070193 us)
   49786   SORT JOIN (cr=2518 pr=0 pw=0 time=17744 us)
   49786    TABLE ACCESS FULL VENDORS (cr=2518 pr=0 pw=0 time=20 us)
    8666   SORT UNIQUE (cr=267410 pr=109794 pw=0 time=11066943 us)
    8666    VIEW  (cr=267410 pr=109794 pw=0 time=11046105 us)
    8666     HASH UNIQUE (cr=267410 pr=109794 pw=0 time=11046103 us)
 9176048      HASH JOIN  (cr=267410 pr=109794 pw=0 time=221402 us)
   74768       TABLE ACCESS FULL PARTS (cr=5040 pr=0 pw=0 time=24 us)
12205347       HASH JOIN  (cr=262370 pr=109794 pw=0 time=188692 us)
  500000        TABLE ACCESS FULL PO_HEADER (cr=13190 pr=0 pw=0 time=21 us)
12205347        TABLE ACCESS FULL PO_LINE (cr=249180 pr=109794 pw=0 time=20 us)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                      43        0.00          0.00
  db file sequential read                       196        0.03          0.11
  db file scattered read                        941        0.04          2.61
  SQL*Net message from client                    43        0.00          0.01
  SQL*Net more data to client                   610        0.00          0.00

Oracle Database 11.2.0.1 Standard Edition:

call     count       cpu    elapsed       disk      query    current        rows

------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.06       0.05          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch       43      8.33      17.85     249545     270284          0       41120
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total       45      8.39      17.91     249545     270284          0       41120

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 51 

 Rows     Row Source Operation
 -------  ---------------------------------------------------
   41120  MERGE JOIN ANTI (cr=270284 pr=249545 pw=0 time=29462 us cost=27821 size=1632120 card=40803)
   49786   SORT JOIN (cr=2505 pr=0 pw=0 time=12798 us cost=533 size=1443794 card=49786)
   49786    TABLE ACCESS FULL VENDORS (cr=2505 pr=0 pw=0 time=14589 us cost=199 size=1443794 card=49786)
    8666   SORT UNIQUE (cr=267779 pr=249545 pw=0 time=0 us cost=27288 size=98813 card=8983)
    8666    VIEW  (cr=267779 pr=249545 pw=0 time=2293 us cost=27287 size=98813 card=8983)
    8666     HASH UNIQUE (cr=267779 pr=249545 pw=0 time=1146 us cost=27287 size=521014 card=8983)
 9176048      HASH JOIN  (cr=267779 pr=249545 pw=0 time=21976024 us cost=26678 size=707903050 card=12205225)
   74768       TABLE ACCESS FULL PARTS (cr=5027 pr=0 pw=0 time=19426 us cost=399 size=338963 card=19939)
12205347       HASH JOIN  (cr=262752 pr=249545 pw=0 time=18076660 us cost=26222 size=500419227 card=12205347)
  500000        TABLE ACCESS FULL PO_HEADER (cr=13190 pr=0 pw=0 time=63347 us cost=1118 size=10000000 card=500000)
12205347        TABLE ACCESS FULL PO_LINE (cr=249562 pr=249545 pw=0 time=14012692 us cost=20028 size=256312287 card=12205347)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                      43        0.00          0.00
  direct path read                             1950        0.05          9.21
  asynch descriptor resize                        4        0.00          0.00
  SQL*Net message from client                    43        0.00          0.03

  SQL*Net more data to client                   124        0.00          0.00
 

Oracle Database 11.2.0.1 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.04       0.05          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch       43      8.62      17.57     262329     269920          0       41120
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total       45      8.67      17.62     262329     269920          0       41120

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 194 

 Rows     Row Source Operation
 -------  ---------------------------------------------------
   41120  MERGE JOIN ANTI (cr=269920 pr=262329 pw=0 time=30486 us cost=27771 size=1632120 card=40803)
   49786   SORT JOIN (cr=2518 pr=0 pw=0 time=14206 us cost=533 size=1443794 card=49786)
   49786    TABLE ACCESS FULL VENDORS (cr=2518 pr=0 pw=0 time=16125 us cost=199 size=1443794 card=49786)
    8666   SORT UNIQUE (cr=267402 pr=262329 pw=0 time=0 us cost=27238 size=98813 card=8983)
    8666    VIEW  (cr=267402 pr=262329 pw=0 time=2038 us cost=27237 size=98813 card=8983)
    8666     HASH UNIQUE (cr=267402 pr=262329 pw=0 time=1146 us cost=27237 size=521014 card=8983)
 9176048      HASH JOIN  (cr=267402 pr=262329 pw=0 time=13292648 us cost=26628 size=707903050 card=12205225)
   74768       TABLE ACCESS FULL PARTS (cr=5040 pr=0 pw=0 time=19554 us cost=399 size=338963 card=19939)
12205347       HASH JOIN  (cr=262362 pr=262329 pw=0 time=6456142 us cost=26172 size=500419227 card=12205347)
  500000        TABLE ACCESS FULL PO_HEADER (cr=13190 pr=13173 pw=0 time=3462112 us cost=1118 size=10000000 card=500000)
12205347        TABLE ACCESS FULL PO_LINE (cr=249172 pr=249156 pw=0 time=2428525 us cost=19977 size=256312287 card=12205347)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                      43        0.00          0.00
  db file scattered read                        120        0.10          2.49
  direct path read                             1218        0.07          6.37
  asynch descriptor resize                        4        0.00          0.00
  SQL*Net message from client                    43        0.00          0.02
  SQL*Net more data to client                   124        0.00          0.00   

Determine the storage location and preferred vendor for all office and shop products that have a unit of measure that is EA, PC, or CASE:

SELECT
  P.PART_ID,
  P.DESCRIPTION PART_DESCRIPTION,
  P.PRIMARY_WHS_ID,
  P.PRIMARY_LOC_ID,
  U.DESCRIPTION UMS_DESCRIPTION,
  U.UOM_SCALE,
  L.DESCRIPTION LOC_DESCRIPTION,
  V.VENDOR_ID,
  V.VENDOR_NAME,
  V.ADDR_1,
  V.ADDR_2,
  V.CITY,
  V.STATE
FROM
  UMS U,
  LOCATIONS L,
  PARTS P,
  VENDORS V
WHERE
  P.PRODUCT_CODE IN ('OFFICE','SHOP')
  AND P.PURCHASED='Y'
  AND P.STOCK_UM=U.UNIT_OF_MEASURE
  AND U.UNIT_OF_MEASURE IN ('EA','PC','CASE')
  AND P.PREF_VENDOR_ID=V.VENDOR_ID
  AND P.PRIMARY_WHS_ID=L.WAREHOUSE_ID
  AND P.PRIMARY_LOC_ID=L.LOCATION_ID 

Laptop running 11.2.0.1 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.04       0.04          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        8      0.06       0.06         31       7534          0        6647
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total       10      0.10       0.10         31       7534          0        6647

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 286 
Number of plan statistics captured: 1

Rows (1st) Rows (avg) Rows (max)  Row Source Operation
---------- ---------- ----------  ---------------------------------------------------
      6647       6647       6647  HASH JOIN  (cr=7534 pr=31 pw=0 time=9643 us cost=602 size=720148 card=2518)
      6647       6647       6647   HASH JOIN  (cr=5030 pr=31 pw=0 time=28501 us cost=404 size=392808 card=2518)
      2200       2200       2200    TABLE ACCESS FULL LOCATIONS (cr=31 pr=29 pw=0 time=366 us cost=4 size=176000 card=2200)
      6647       6647       6647    HASH JOIN  (cr=4999 pr=2 pw=0 time=26328 us cost=399 size=191368 card=2518)
         3          3          3     TABLE ACCESS FULL UMS (cr=3 pr=2 pw=0 time=0 us cost=2 size=21 card=3)
      6647       6647       6647     TABLE ACCESS FULL PARTS (cr=4996 pr=0 pw=0 time=23900 us cost=397 size=463335 card=6715)
     49786      49786      49786   TABLE ACCESS FULL VENDORS (cr=2504 pr=0 pw=0 time=16808 us cost=197 size=6472180 card=49786)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                       8        0.00          0.00
  db file sequential read                         3        0.00          0.00
  db file scattered read                          4        0.00          0.00
  asynch descriptor resize                        3        0.00          0.00
  SQL*Net message from client                     8        0.00          0.01
  SQL*Net more data to client                   108        0.00          0.00 

Oracle Database 10.2.0.5 Standard Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.03       0.11          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        8      0.06       0.12         31       7602          0        6647
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total       10      0.09       0.23         31       7602          0        6647

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 47 

Rows     Row Source Operation
-------  ---------------------------------------------------
   6647  HASH JOIN  (cr=7602 pr=31 pw=0 time=96852 us)
   6647   HASH JOIN  (cr=5077 pr=31 pw=0 time=88946 us)
   2200    TABLE ACCESS FULL LOCATIONS (cr=31 pr=29 pw=0 time=16541 us)
   6647    HASH JOIN  (cr=5046 pr=2 pw=0 time=49703 us)
      3     INLIST ITERATOR  (cr=6 pr=2 pw=0 time=22888 us)
      3      TABLE ACCESS BY INDEX ROWID UMS (cr=6 pr=2 pw=0 time=22913 us)
      3       INDEX UNIQUE SCAN SYS_C004571 (cr=3 pr=1 pw=0 time=332 us)(object id 47891)
   6647     TABLE ACCESS FULL PARTS (cr=5040 pr=0 pw=0 time=26601 us)
  49786   TABLE ACCESS FULL VENDORS (cr=2525 pr=0 pw=0 time=21 us)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                       8        0.00          0.00
  db file sequential read                         3        0.02          0.03
  db file scattered read                          4        0.01          0.01
  SQL*Net message from client                     8        0.00          0.01
  SQL*Net more data to client                   455        0.00          0.00

Oracle Database 10.2.0.5 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.06       0.05          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        8      0.06       0.14         31       7602          0        6647
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total       10      0.12       0.19         31       7602          0        6647

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 164 

Rows     Row Source Operation
-------  ---------------------------------------------------
   6647  HASH JOIN  (cr=7602 pr=31 pw=0 time=106066 us)
   6647   HASH JOIN  (cr=5077 pr=31 pw=0 time=98872 us)
   2200    TABLE ACCESS FULL LOCATIONS (cr=31 pr=29 pw=0 time=23994 us)
   6647    HASH JOIN  (cr=5046 pr=2 pw=0 time=30133 us)
      3     INLIST ITERATOR  (cr=6 pr=2 pw=0 time=10008 us)
      3      TABLE ACCESS BY INDEX ROWID UMS (cr=6 pr=2 pw=0 time=9997 us)
      3       INDEX UNIQUE SCAN SYS_C0012078 (cr=3 pr=1 pw=0 time=2124 us)(object id 51696)
   6647     TABLE ACCESS FULL PARTS (cr=5040 pr=0 pw=0 time=19957 us)
  49786   TABLE ACCESS FULL VENDORS (cr=2525 pr=0 pw=0 time=19 us)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                       8        0.00          0.00
  db file sequential read                         3        0.02          0.03
  db file scattered read                          4        0.02          0.03
  SQL*Net message from client                     8        0.00          0.01
  SQL*Net more data to client                   454        0.00          0.00

Oracle Database 11.2.0.1 Standard Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.03       0.04          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        8      0.04       0.12         31       7573          0        6647
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total       10      0.07       0.16         31       7573          0        6647

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 51 

Rows     Row Source Operation
-------  ---------------------------------------------------
   6647  HASH JOIN  (cr=7573 pr=31 pw=0 time=6124 us cost=608 size=712426 card=2491)
   6647   HASH JOIN  (cr=5061 pr=31 pw=0 time=33102 us cost=408 size=388596 card=2491)
   2200    TABLE ACCESS FULL LOCATIONS (cr=31 pr=29 pw=0 time=244 us cost=4 size=176000 card=2200)
   6647    HASH JOIN  (cr=5030 pr=2 pw=0 time=30801 us cost=403 size=189316 card=2491)
      3     INLIST ITERATOR  (cr=3 pr=2 pw=0 time=32 us)
      3      TABLE ACCESS BY INDEX ROWID UMS (cr=3 pr=2 pw=0 time=0 us cost=2 size=21 card=3)
      3       INDEX UNIQUE SCAN SYS_C009204 (cr=2 pr=1 pw=0 time=0 us cost=1 size=0 card=3)(object id 20303)
   6647     TABLE ACCESS FULL PARTS (cr=5027 pr=0 pw=0 time=28245 us cost=401 size=458367 card=6643)
  49786   TABLE ACCESS FULL VENDORS (cr=2512 pr=0 pw=0 time=18091 us cost=199 size=6472180 card=49786)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                       8        0.00          0.00
  db file sequential read                         3        0.01          0.01
  db file scattered read                          4        0.02          0.04
  asynch descriptor resize                        3        0.00          0.00
  SQL*Net message from client                     8        0.00          0.01
  SQL*Net more data to client                   109        0.00          0.00  

Oracle Database 11.2.0.1 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.04       0.04          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        8      0.06       0.12         31       7598          0        6647
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total       10      0.10       0.17         31       7598          0        6647

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 194 

Rows     Row Source Operation
-------  ---------------------------------------------------
   6647  HASH JOIN  (cr=7598 pr=31 pw=0 time=8470 us cost=608 size=710424 card=2484)
   6647   HASH JOIN  (cr=5074 pr=31 pw=0 time=32974 us cost=408 size=387504 card=2484)
   2200    TABLE ACCESS FULL LOCATIONS (cr=31 pr=29 pw=0 time=122 us cost=4 size=176000 card=2200)
   6647    HASH JOIN  (cr=5043 pr=2 pw=0 time=29140 us cost=403 size=188784 card=2484)
      3     INLIST ITERATOR  (cr=3 pr=2 pw=0 time=34 us)
      3      TABLE ACCESS BY INDEX ROWID UMS (cr=3 pr=2 pw=0 time=0 us cost=2 size=21 card=3)
      3       INDEX UNIQUE SCAN SYS_C0024653 (cr=2 pr=1 pw=0 time=0 us cost=1 size=0 card=3)(object id 83198)
   6647     TABLE ACCESS FULL PARTS (cr=5040 pr=0 pw=0 time=26328 us cost=401 size=456987 card=6623)
  49786   TABLE ACCESS FULL VENDORS (cr=2524 pr=0 pw=0 time=21299 us cost=199 size=6472180 card=49786)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                       8        0.00          0.00
  db file sequential read                         3        0.01          0.01
  db file scattered read                          4        0.02          0.05
  asynch descriptor resize                        3        0.00          0.00
  SQL*Net message from client                     8        0.00          0.01
  SQL*Net more data to client                   109        0.00          0.00   

Locating the most recent vendor for each part:

SELECT
  VENDOR_ID,
  PART_ID,
  DESIRED_RECV_DATE
FROM
  (SELECT
    PO.VENDOR_ID,
    POL.PART_ID,
    POL.DESIRED_RECV_DATE,
    ROW_NUMBER() OVER (PARTITION BY POL.PART_ID ORDER BY POL.DESIRED_RECV_DATE DESC) RN
  FROM
    PO_HEADER PO,
    PO_LINE POL
  WHERE
    PO.PURC_ORDER_ID=POL.PURC_ORDER_ID)
WHERE
  RN=1
ORDER BY
  PART_ID 

Laptop running 11.2.0.1 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.01       0.01          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        6     25.44      25.67     252854     262229         63        4246
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        8     25.45      25.69     252854     262229         63        4246

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 286 
Number of plan statistics captured: 1

Rows (1st) Rows (avg) Rows (max)  Row Source Operation
---------- ---------- ----------  ---------------------------------------------------
      4246       4246       4246  VIEW  (cr=262229 pr=252854 pw=3805 time=837165 us cost=150135 size=585856656 card=12205347)
    519965     519965     519965   WINDOW SORT PUSHED RANK (cr=262229 pr=252854 pw=3805 time=844973 us cost=150135 size=598062003 card=12205347)
  12205347   12205347   12205347    HASH JOIN  (cr=262229 pr=249049 pw=0 time=6314575 us cost=27081 size=598062003 card=12205347)
    500000     500000     500000     TABLE ACCESS FULL PO_HEADER (cr=13173 pr=0 pw=0 time=61684 us cost=1038 size=10000000 card=500000)
  12205347   12205347   12205347     TABLE ACCESS FULL PO_LINE (cr=249056 pr=249049 pw=0 time=1914609 us cost=19811 size=353955063 card=12205347)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                       6        0.00          0.00
  direct path read                                8        0.05          0.06
  Disk file operations I/O                        1        0.00          0.00
  asynch descriptor resize                        4        0.00          0.00
  direct path write temp                          1        0.00          0.00
  direct path read temp                         128        0.00          0.08
  SQL*Net message from client                     6        0.00          0.00
  SQL*Net more data to client                    13        0.00          0.00 

Oracle Database 10.2.0.5 Standard Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.00       0.03          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        6     27.79      28.59       3624     262420        112        4246
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        8     27.79      28.62       3624     262420        112        4246

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 47 

 Rows     Row Source Operation
 -------  ---------------------------------------------------
    4246  VIEW  (cr=262420 pr=3624 pw=3622 time=28575597 us)
    8895   WINDOW SORT PUSHED RANK (cr=262420 pr=3624 pw=3622 time=28491688 us)
12205347    HASH JOIN  (cr=262420 pr=0 pw=0 time=174567 us)
  500000     TABLE ACCESS FULL PO_HEADER (cr=13190 pr=0 pw=0 time=28 us)
12205347     TABLE ACCESS FULL PO_LINE (cr=249230 pr=0 pw=0 time=21 us)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                       6        0.00          0.00
  db file sequential read                         2        0.00          0.00
  local write wait                               78        0.00          0.01
  direct path read temp                          98        0.03          0.49
  SQL*Net message from client                     6        0.00          0.00
  SQL*Net more data to client                    68        0.00          0.00

Oracle Database 10.2.0.5 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.01       0.01          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        6     28.92      30.65     116653     262370         59        4246
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        8     28.93      30.66     116653     262370         59        4246

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 164 

 Rows     Row Source Operation
 -------  ---------------------------------------------------
    4246  VIEW  (cr=262370 pr=116653 pw=3563 time=30646863 us)
    8928   WINDOW SORT PUSHED RANK (cr=262370 pr=116653 pw=3563 time=30551159 us)
12205347    HASH JOIN  (cr=262370 pr=113090 pw=0 time=176948 us)
  500000     TABLE ACCESS FULL PO_HEADER (cr=13190 pr=0 pw=0 time=29 us)
12205347     TABLE ACCESS FULL PO_LINE (cr=249180 pr=113090 pw=0 time=21 us)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                       6        0.00          0.00
  db file sequential read                       222        0.01          0.23
  db file scattered read                       1229        0.04          1.31
  i/o slave wait                                163        0.03          0.36
  direct path write temp                          3        0.00          0.00
  direct path read temp                         118        0.03          0.30
  SQL*Net message from client                     6        0.00          0.00
  SQL*Net more data to client                    68        0.00          0.00

Oracle Database 11.2.0.1 Standard Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.01       0.02          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        6     27.33      31.14     253289     262752        116        4246
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        8     27.34      31.16     253289     262752        116        4246

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 51 

 Rows     Row Source Operation
 -------  ---------------------------------------------------
    4246  VIEW  (cr=262752 pr=253289 pw=3742 time=659004 us cost=150591 size=585856656 card=12205347)
  511557   WINDOW SORT PUSHED RANK (cr=262752 pr=253289 pw=3742 time=1603029 us cost=150591 size=598062003 card=12205347)
12205347    HASH JOIN  (cr=262752 pr=249545 pw=0 time=8244288 us cost=27537 size=598062003 card=12205347)
  500000     TABLE ACCESS FULL PO_HEADER (cr=13190 pr=0 pw=0 time=66035 us cost=1118 size=10000000 card=500000)
12205347     TABLE ACCESS FULL PO_LINE (cr=249562 pr=249545 pw=0 time=3445861 us cost=20188 size=353955063 card=12205347)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                       6        0.00          0.00
  direct path read                              157        0.04          1.88
  Disk file operations I/O                        1        0.00          0.00
  db file sequential read                         2        0.03          0.05
  local write wait                               81        0.00          0.01
  asynch descriptor resize                        4        0.00          0.00
  direct path read temp                         102        0.03          0.50
  SQL*Net message from client                     6        0.00          0.00
  SQL*Net more data to client                    13        0.00          0.00

Oracle Database 11.2.0.1 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.03       0.02          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        6     26.52      30.65     252898     262362         62        4246
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        8     26.55      30.68     252898     262362         62        4246

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 194 

 Rows     Row Source Operation
 -------  ---------------------------------------------------
   4246  VIEW  (cr=262362 pr=252898 pw=3742 time=655016 us cost=150541 size=585856656 card=12205347)
  511304   WINDOW SORT PUSHED RANK (cr=262362 pr=252898 pw=3742 time=699361 us cost=150541 size=598062003 card=12205347)
12205347    HASH JOIN  (cr=262362 pr=249156 pw=0 time=10892972 us cost=27487 size=598062003 card=12205347)
  500000     TABLE ACCESS FULL PO_HEADER (cr=13190 pr=0 pw=0 time=67570 us cost=1118 size=10000000 card=500000)
 12205347     TABLE ACCESS FULL PO_LINE (cr=249172 pr=249156 pw=0 time=6413774 us cost=20138 size=353955063 card=12205347)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                       6        0.00          0.00
  direct path read                              218        0.06          3.72
  Disk file operations I/O                        1        0.00          0.00
  asynch descriptor resize                        4        0.00          0.00
  direct path write temp                          2        0.00          0.01
  direct path read temp                         126        0.04          0.44
  SQL*Net message from client                     6        0.00          0.00
  SQL*Net more data to client                    13        0.00          0.00   

Comparing the most recent vendor for each part with the expected vendor for each purchased part that has either an OFFICE or SHOP product code:

SELECT
  P.PART_ID,
  P.DESCRIPTION PART_DESCRIPTION,
  P.PRIMARY_WHS_ID,
  P.PRIMARY_LOC_ID,
  U.DESCRIPTION UMS_DESCRIPTION,
  U.UOM_SCALE,
  L.DESCRIPTION LOC_DESCRIPTION,
  V.VENDOR_ID,
  V.VENDOR_NAME,
  V.ADDR_1,
  V.ADDR_2,
  V.CITY,
  V.STATE,
  LV.VENDOR_ID LAST_VENDOR_ID,
  V2.VENDOR_NAME LAST_VENDOR_NAME,
  V2.STATE LAST_VENDOR_STATE,
  LV.DESIRED_RECV_DATE LAST_DES_RECV_DATE
FROM
  UMS U,
  LOCATIONS L,
  PARTS P,
  VENDORS V,
  (SELECT
    VENDOR_ID,
    PART_ID,
    DESIRED_RECV_DATE
  FROM
    (SELECT
      PO.VENDOR_ID,
      POL.PART_ID,
      POL.DESIRED_RECV_DATE,
      ROW_NUMBER() OVER (PARTITION BY POL.PART_ID ORDER BY POL.DESIRED_RECV_DATE DESC) RN
    FROM
      PO_HEADER PO,
      PO_LINE POL
    WHERE
      PO.PURC_ORDER_ID=POL.PURC_ORDER_ID)
  WHERE
    RN=1) LV,
  VENDORS V2
WHERE
  P.PRODUCT_CODE IN ('OFFICE','SHOP')
  AND P.PURCHASED='Y'
  AND P.STOCK_UM=U.UNIT_OF_MEASURE
  AND U.UNIT_OF_MEASURE IN ('EA','PC','CASE')
  AND P.PREF_VENDOR_ID=V.VENDOR_ID
  AND P.PRIMARY_WHS_ID=L.WAREHOUSE_ID
  AND P.PRIMARY_LOC_ID=L.LOCATION_ID
  AND P.PART_ID=LV.PART_ID
  AND LV.VENDOR_ID=V2.VENDOR_ID 

Laptop running 11.2.0.1 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.39       0.39          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        2     25.56      25.78     252854     272253         63         278
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        4     25.95      26.18     252854     272253         63         278

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 286 
Number of plan statistics captured: 1

Rows (1st) Rows (avg) Rows (max)  Row Source Operation
---------- ---------- ----------  ---------------------------------------------------
       278        278        278  HASH JOIN  (cr=272253 pr=252854 pw=3805 time=535302 us cost=165495 size=1675035600 card=4576600)
      2200       2200       2200   TABLE ACCESS FULL LOCATIONS (cr=31 pr=0 pw=0 time=488 us cost=4 size=176000 card=2200)
       278        278        278   HASH JOIN  (cr=272222 pr=252854 pw=3805 time=535164 us cost=165469 size=1308907600 card=4576600)
     49786      49786      49786    TABLE ACCESS FULL VENDORS (cr=2497 pr=0 pw=0 time=13822 us cost=197 size=1593152 card=49786)
       278        278        278    HASH JOIN  (cr=269725 pr=252854 pw=3805 time=534887 us cost=150791 size=1162456400 card=4576600)
      6647       6647       6647     HASH JOIN  (cr=7496 pr=0 pw=0 time=5879 us cost=598 size=518708 card=2518)
      6647       6647       6647      HASH JOIN  (cr=4999 pr=0 pw=0 time=25689 us cost=399 size=191368 card=2518)
         3          3          3       TABLE ACCESS FULL UMS (cr=3 pr=0 pw=0 time=2 us cost=2 size=21 card=3)
      6647       6647       6647       TABLE ACCESS FULL PARTS (cr=4996 pr=0 pw=0 time=23261 us cost=397 size=463335 card=6715)
     49786      49786      49786      TABLE ACCESS FULL VENDORS (cr=2497 pr=0 pw=0 time=14717 us cost=197 size=6472180 card=49786)
      4246       4246       4246     VIEW  (cr=262229 pr=252854 pw=3805 time=777459 us cost=150135 size=585856656 card=12205347)
    519965     519965     519965      WINDOW SORT PUSHED RANK (cr=262229 pr=252854 pw=3805 time=786536 us cost=150135 size=598062003 card=12205347)
  12205347   12205347   12205347       HASH JOIN  (cr=262229 pr=249049 pw=0 time=6259791 us cost=27081 size=598062003 card=12205347)
    500000     500000     500000        TABLE ACCESS FULL PO_HEADER (cr=13173 pr=0 pw=0 time=61812 us cost=1038 size=10000000 card=500000)
  12205347   12205347   12205347        TABLE ACCESS FULL PO_LINE (cr=249056 pr=249049 pw=0 time=1906545 us cost=19811 size=353955063 card=12205347)

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
  asynch descriptor resize                        9        0.00          0.00
  direct path read                                7        0.00          0.01
  direct path write temp                          1        0.00          0.00
  direct path read temp                         100        0.00          0.06
  SQL*Net message from client                     2        0.00          0.00
  SQL*Net more data to client                     6        0.00          0.00 

Oracle Database 10.2.0.5 Standard Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.60       0.81          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        2     28.04      28.91       3622     272533         60         278
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        4     28.65      29.73       3622     272533         60         278

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 47 

 Rows     Row Source Operation
 -------  ---------------------------------------------------
     278  HASH JOIN  (cr=272533 pr=3622 pw=3622 time=28652546 us)
    2200   TABLE ACCESS FULL LOCATIONS (cr=31 pr=0 pw=0 time=35 us)
     278   HASH JOIN  (cr=272502 pr=3622 pw=3622 time=28651159 us)
   49786    TABLE ACCESS FULL VENDORS (cr=2518 pr=0 pw=0 time=13 us)
     278    HASH JOIN  (cr=269984 pr=3622 pw=3622 time=28629675 us)
    6647     HASH JOIN  (cr=7564 pr=0 pw=0 time=38331 us)
    6647      HASH JOIN  (cr=5046 pr=0 pw=0 time=26841 us)
       3       INLIST ITERATOR  (cr=6 pr=0 pw=0 time=47 us)
       3        TABLE ACCESS BY INDEX ROWID UMS (cr=6 pr=0 pw=0 time=38 us)
       3         INDEX UNIQUE SCAN SYS_C004571 (cr=3 pr=0 pw=0 time=15 us)(object id 47891)
    6647       TABLE ACCESS FULL PARTS (cr=5040 pr=0 pw=0 time=26610 us)
   49786      TABLE ACCESS FULL VENDORS (cr=2518 pr=0 pw=0 time=24 us)
    4246     VIEW  (cr=262420 pr=3622 pw=3622 time=28787059 us)
    8895      WINDOW SORT PUSHED RANK (cr=262420 pr=3622 pw=3622 time=28681926 us)
12205347       HASH JOIN  (cr=262420 pr=0 pw=0 time=178699 us)
  500000        TABLE ACCESS FULL PO_HEADER (cr=13190 pr=0 pw=0 time=24 us)
12205347        TABLE ACCESS FULL PO_LINE (cr=249230 pr=0 pw=0 time=21 us)

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
  direct path write temp                          1        0.00          0.00
  direct path read temp                         119        0.04          0.78
  SQL*Net message from client                     2        0.00          0.00
  SQL*Net more data to client                    25        0.00          0.00

Oracle Database 10.2.0.5 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.73       1.02          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        2     28.71      30.86     116593     272483         59         278
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        4     29.45      31.89     116593     272483         59         278

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 164 

 Rows     Row Source Operation
 -------  ---------------------------------------------------
     278  HASH JOIN  (cr=272483 pr=116593 pw=3563 time=30547001 us)
    2200   TABLE ACCESS FULL LOCATIONS (cr=31 pr=0 pw=0 time=32 us)
     278   HASH JOIN  (cr=272452 pr=116593 pw=3563 time=30545857 us)
   49786    TABLE ACCESS FULL VENDORS (cr=2518 pr=0 pw=0 time=13 us)
     278    HASH JOIN  (cr=269934 pr=116593 pw=3563 time=30524105 us)
    6647     HASH JOIN  (cr=7564 pr=0 pw=0 time=31940 us)
    6647      HASH JOIN  (cr=5046 pr=0 pw=0 time=20180 us)
       3       INLIST ITERATOR  (cr=6 pr=0 pw=0 time=46 us)
       3        TABLE ACCESS BY INDEX ROWID UMS (cr=6 pr=0 pw=0 time=37 us)
       3         INDEX UNIQUE SCAN SYS_C0012078 (cr=3 pr=0 pw=0 time=16 us)(object id 51696)
    6647       TABLE ACCESS FULL PARTS (cr=5040 pr=0 pw=0 time=19965 us)
   49786      TABLE ACCESS FULL VENDORS (cr=2518 pr=0 pw=0 time=22 us)
    4246     VIEW  (cr=262370 pr=116593 pw=3563 time=30599938 us)
    8928      WINDOW SORT PUSHED RANK (cr=262370 pr=116593 pw=3563 time=30473211 us)
12205347       HASH JOIN  (cr=262370 pr=113030 pw=0 time=179051 us)
  500000        TABLE ACCESS FULL PO_HEADER (cr=13190 pr=0 pw=0 time=25 us)
12205347        TABLE ACCESS FULL PO_LINE (cr=249180 pr=113030 pw=0 time=21 us)

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                       241        0.03          0.25
  db file scattered read                       1145        0.04          1.17
  i/o slave wait                                152        0.04          0.57
  direct path write temp                          1        0.00          0.00
  direct path read temp                         102        0.04          0.48
  SQL*Net message from client                     2        0.00          0.00
  SQL*Net more data to client                    25        0.00          0.00

Oracle Database 11.2.0.1 Standard Edition:

call     count       cpu    elapsed       disk      query    current        rows

------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.42       0.41          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        2     26.66      29.77     253287     272823         62         278
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        4     27.08      30.18     253287     272823         62         278

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 51 

 Rows     Row Source Operation
 -------  ---------------------------------------------------
     278  HASH JOIN  (cr=272823 pr=253287 pw=3742 time=459543 us cost=165959 size=1675042188 card=4576618)
    2200   TABLE ACCESS FULL LOCATIONS (cr=31 pr=0 pw=0 time=122 us cost=4 size=176000 card=2200)
     278   HASH JOIN  (cr=272792 pr=253287 pw=3742 time=459404 us cost=165933 size=1308912748 card=4576618)
   49786    TABLE ACCESS FULL VENDORS (cr=2505 pr=0 pw=0 time=17789 us cost=199 size=1593152 card=49786)
     278    HASH JOIN  (cr=270287 pr=253287 pw=3742 time=459127 us cost=151253 size=1162460972 card=4576618)
    6647     HASH JOIN  (cr=7535 pr=0 pw=0 time=5240 us cost=604 size=513146 card=2491)
    6647      HASH JOIN  (cr=5030 pr=0 pw=0 time=31951 us cost=403 size=189316 card=2491)
       3       INLIST ITERATOR  (cr=3 pr=0 pw=0 time=16 us)
       3        TABLE ACCESS BY INDEX ROWID UMS (cr=3 pr=0 pw=0 time=0 us cost=2 size=21 card=3)
       3         INDEX UNIQUE SCAN SYS_C009204 (cr=2 pr=0 pw=0 time=0 us cost=1 size=0 card=3)(object id 20303)
    6647       TABLE ACCESS FULL PARTS (cr=5027 pr=0 pw=0 time=29523 us cost=401 size=458367 card=6643)
   49786      TABLE ACCESS FULL VENDORS (cr=2505 pr=0 pw=0 time=16765 us cost=199 size=6472180 card=49786)
    4246     VIEW  (cr=262752 pr=253287 pw=3742 time=688439 us cost=150591 size=585856656 card=12205347)
  511557      WINDOW SORT PUSHED RANK (cr=262752 pr=253287 pw=3742 time=675760 us cost=150591 size=598062003 card=12205347)
12205347       HASH JOIN  (cr=262752 pr=249545 pw=0 time=7621317 us cost=27537 size=598062003 card=12205347)
  500000        TABLE ACCESS FULL PO_HEADER (cr=13190 pr=0 pw=0 time=82032 us cost=1118 size=10000000 card=500000)
12205347        TABLE ACCESS FULL PO_LINE (cr=249562 pr=249545 pw=0 time=3013736 us cost=20188 size=353955063 card=12205347)

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
  asynch descriptor resize                        9        0.00          0.00
  direct path read                              178        0.06          2.38
  direct path write temp                          1        0.00          0.00
  direct path read temp                         125        0.02          0.53
  SQL*Net message from client                     2        0.00          0.00

  SQL*Net more data to client                     6        0.00          0.00
 

Oracle Database 11.2.0.1 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.43       0.44          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        2     26.44      29.82     252898     272472         62         278
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        4     26.87      30.26     252898     272472         62         278

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 194 

 Rows     Row Source Operation
 -------  ---------------------------------------------------
     278  HASH JOIN  (cr=272472 pr=252898 pw=3742 time=475747 us cost=165907 size=1674935682 card=4576327)
    2200   TABLE ACCESS FULL LOCATIONS (cr=31 pr=0 pw=0 time=244 us cost=4 size=176000 card=2200)
     278   HASH JOIN  (cr=272441 pr=252898 pw=3742 time=475470 us cost=165881 size=1308829522 card=4576327)
   49786    TABLE ACCESS FULL VENDORS (cr=2518 pr=0 pw=0 time=16125 us cost=199 size=1593152 card=49786)
     278    HASH JOIN  (cr=269923 pr=252898 pw=3742 time=475193 us cost=151203 size=1162387058 card=4576327)
    6647     HASH JOIN  (cr=7561 pr=0 pw=0 time=6773 us cost=604 size=511704 card=2484)
    6647      HASH JOIN  (cr=5043 pr=0 pw=0 time=26584 us cost=403 size=188784 card=2484)
       3       INLIST ITERATOR  (cr=3 pr=0 pw=0 time=16 us)
       3        TABLE ACCESS BY INDEX ROWID UMS (cr=3 pr=0 pw=0 time=0 us cost=2 size=21 card=3)
       3         INDEX UNIQUE SCAN SYS_C0024653 (cr=2 pr=0 pw=0 time=0 us cost=1 size=0 card=3)(object id 83198)
    6647       TABLE ACCESS FULL PARTS (cr=5040 pr=0 pw=0 time=24666 us cost=401 size=456987 card=6623)
   49786      TABLE ACCESS FULL VENDORS (cr=2518 pr=0 pw=0 time=15101 us cost=199 size=6472180 card=49786)
    4246     VIEW  (cr=262362 pr=252898 pw=3742 time=713534 us cost=150541 size=585856656 card=12205347)
  511304      WINDOW SORT PUSHED RANK (cr=262362 pr=252898 pw=3742 time=688947 us cost=150541 size=598062003 card=12205347)
12205347       HASH JOIN  (cr=262362 pr=249156 pw=0 time=6328527 us cost=27487 size=598062003 card=12205347)
  500000        TABLE ACCESS FULL PO_HEADER (cr=13190 pr=0 pw=0 time=68978 us cost=1118 size=10000000 card=500000)
12205347        TABLE ACCESS FULL PO_LINE (cr=249172 pr=249156 pw=0 time=1858929 us cost=20138 size=353955063 card=12205347)

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
  asynch descriptor resize                        9        0.00          0.00
  direct path read                              174        0.05          2.85
  direct path write temp                          1        0.00          0.00
  direct path read temp                         101        0.01          0.39
  SQL*Net message from client                     2        0.00          0.00
  SQL*Net more data to client                     6        0.00          0.00   

Comparing the most recent vendor for each part with the expected vendor for each purchased part that was excluded from the previous query:

SELECT
  P.PART_ID,
  P.DESCRIPTION PART_DESCRIPTION,
  P.PRIMARY_WHS_ID,
  P.PRIMARY_LOC_ID,
  U.DESCRIPTION UMS_DESCRIPTION,
  U.UOM_SCALE,
  L.DESCRIPTION LOC_DESCRIPTION,
  V.VENDOR_ID,
  V.VENDOR_NAME,
  V.ADDR_1,
  V.ADDR_2,
  V.CITY,
  V.STATE,
  LV.VENDOR_ID LAST_VENDOR_ID,
  V2.VENDOR_NAME LAST_VENDOR_NAME,
  V2.STATE LAST_VENDOR_STATE,
  LV.DESIRED_RECV_DATE LAST_DES_RECV_DATE
FROM
  UMS U,
  LOCATIONS L,
  PARTS P,
  VENDORS V,
  (SELECT
    VENDOR_ID,
    PART_ID,
    DESIRED_RECV_DATE
  FROM
    (SELECT
      PO.VENDOR_ID,
      POL.PART_ID,
      POL.DESIRED_RECV_DATE,
      ROW_NUMBER() OVER (PARTITION BY POL.PART_ID ORDER BY POL.DESIRED_RECV_DATE DESC) RN
    FROM
      PO_HEADER PO,
      PO_LINE POL
    WHERE
      PO.PURC_ORDER_ID=POL.PURC_ORDER_ID)
  WHERE
    RN=1) LV,
  VENDORS V2
WHERE
  (P.PRODUCT_CODE NOT IN ('OFFICE','SHOP')
     OR U.UNIT_OF_MEASURE NOT IN ('EA','PC','CASE'))
  AND P.PURCHASED='Y'
  AND P.STOCK_UM=U.UNIT_OF_MEASURE
  AND P.PREF_VENDOR_ID=V.VENDOR_ID
  AND P.PRIMARY_WHS_ID=L.WAREHOUSE_ID
  AND P.PRIMARY_LOC_ID=L.LOCATION_ID
  AND P.PART_ID=LV.PART_ID
  AND LV.VENDOR_ID=V2.VENDOR_ID 

Laptop running 11.2.0.1 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.60       0.60          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        4     25.75      26.00     252854     272253         63        2550
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        6     26.36      26.61     252854     272253         63        2550

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 286 
Number of plan statistics captured: 1

Rows (1st) Rows (avg) Rows (max)  Row Source Operation
---------- ---------- ----------  ---------------------------------------------------
      2550       2550       2550  HASH JOIN  (cr=272253 pr=252854 pw=3805 time=917103 us cost=190663 size=3936278028 card=10754858)
      2200       2200       2200   TABLE ACCESS FULL LOCATIONS (cr=31 pr=0 pw=0 time=366 us cost=4 size=176000 card=2200)
      2551       2551       2551   HASH JOIN  (cr=272222 pr=252854 pw=3805 time=703263 us cost=190608 size=3075889388 card=10754858)
     49786      49786      49786    TABLE ACCESS FULL VENDORS (cr=2497 pr=0 pw=0 time=14973 us cost=197 size=6472180 card=49786)
      2551       2551       2551    HASH JOIN  (cr=269725 pr=252854 pw=3805 time=700981 us cost=168838 size=1677757848 card=10754858)
     49786      49786      49786     TABLE ACCESS FULL VENDORS (cr=2497 pr=0 pw=0 time=13950 us cost=197 size=1593152 card=49786)
      2551       2551       2551     HASH JOIN  (cr=267228 pr=252854 pw=3805 time=700310 us cost=151200 size=1333602392 card=10754858)
         8          8          8      TABLE ACCESS FULL UMS (cr=3 pr=0 pw=0 time=0 us cost=2 size=56 card=8)
      2829       2829       2829      MERGE JOIN  (cr=267225 pr=252854 pw=3805 time=817292 us cost=151140 size=1428005592 card=12205176)
      4246       4246       4246       VIEW  (cr=262229 pr=252854 pw=3805 time=800432 us cost=150135 size=585856656 card=12205347)
    519965     519965     519965        WINDOW SORT PUSHED RANK (cr=262229 pr=252854 pw=3805 time=822060 us cost=150135 size=598062003 card=12205347)
  12205347   12205347   12205347         HASH JOIN  (cr=262229 pr=249049 pw=0 time=6367055 us cost=27081 size=598062003 card=12205347)
    500000     500000     500000          TABLE ACCESS FULL PO_HEADER (cr=13173 pr=0 pw=0 time=63219 us cost=1038 size=10000000 card=500000)
  12205347   12205347   12205347          TABLE ACCESS FULL PO_LINE (cr=249056 pr=249049 pw=0 time=1935473 us cost=19811 size=353955063 card=12205347)
      2829       2829       2829       SORT JOIN (cr=4996 pr=0 pw=0 time=0 us cost=1005 size=3089061 card=44769)
     66462      66462      66462        TABLE ACCESS FULL PARTS (cr=4996 pr=0 pw=0 time=22494 us cost=398 size=3089061 card=44769)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                       4        0.00          0.00
  direct path read                                8        0.04          0.05
  asynch descriptor resize                        8        0.00          0.00
  direct path write temp                          1        0.00          0.00
  direct path read temp                         128        0.00          0.08
  SQL*Net message from client                     4        0.00          0.00
  SQL*Net more data to client                    56        0.00          0.00 

Oracle Database 10.2.0.5 Standard Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.99       1.20          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        4     28.00      28.65       3627     272534         60        2550
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        6     29.00      29.86       3627     272534         60        2550

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 47 

 Rows     Row Source Operation
 -------  ---------------------------------------------------
    2550  HASH JOIN  (cr=272534 pr=3627 pw=3622 time=28590189 us)
    2200   TABLE ACCESS FULL LOCATIONS (cr=31 pr=0 pw=0 time=35 us)
    2551   HASH JOIN  (cr=272503 pr=3627 pw=3622 time=28551033 us)
   49786    TABLE ACCESS FULL VENDORS (cr=2518 pr=0 pw=0 time=15 us)
    2551    HASH JOIN  (cr=269985 pr=3627 pw=3622 time=28522524 us)
   49786     TABLE ACCESS FULL VENDORS (cr=2518 pr=0 pw=0 time=23 us)
    2551     HASH JOIN  (cr=267467 pr=3627 pw=3622 time=28498973 us)
       8      TABLE ACCESS FULL UMS (cr=7 pr=5 pw=0 time=20191 us)
    2829      MERGE JOIN  (cr=267460 pr=3622 pw=3622 time=28472228 us)
    4246       VIEW  (cr=262420 pr=3622 pw=3622 time=28456925 us)
    8895        WINDOW SORT PUSHED RANK (cr=262420 pr=3622 pw=3622 time=28377263 us)
12205347         HASH JOIN  (cr=262420 pr=0 pw=0 time=173557 us)
  500000          TABLE ACCESS FULL PO_HEADER (cr=13190 pr=0 pw=0 time=17 us)
12205347          TABLE ACCESS FULL PO_LINE (cr=249230 pr=0 pw=0 time=20 us)
    2829       SORT JOIN (cr=5040 pr=0 pw=0 time=62158 us)
   66462        TABLE ACCESS FULL PARTS (cr=5040 pr=0 pw=0 time=49 us)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                       4        0.00          0.00
  db file sequential read                         1        0.01          0.01
  db file scattered read                          2        0.00          0.00
  direct path write temp                          1        0.00          0.00
  direct path read temp                         100        0.03          0.61
  SQL*Net message from client                     4        0.00          0.01
  SQL*Net more data to client                   229        0.00          0.00

Oracle Database 10.2.0.5 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.99       1.80          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        4     28.93      30.98     116717     272484         59        2550
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        6     29.93      32.78     116717     272484         59        2550

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 164 

 Rows     Row Source Operation
 -------  ---------------------------------------------------
    2550  HASH JOIN  (cr=272484 pr=116717 pw=3563 time=30946899 us)
    2200   TABLE ACCESS FULL LOCATIONS (cr=31 pr=0 pw=0 time=31 us)
    2551   HASH JOIN  (cr=272453 pr=116717 pw=3563 time=31958392 us)
   49786    TABLE ACCESS FULL VENDORS (cr=2518 pr=0 pw=0 time=13 us)
    2551    HASH JOIN  (cr=269935 pr=116717 pw=3563 time=31926556 us)
   49786     TABLE ACCESS FULL VENDORS (cr=2518 pr=0 pw=0 time=21 us)
    2551     HASH JOIN  (cr=267417 pr=116717 pw=3563 time=31902630 us)
       8      TABLE ACCESS FULL UMS (cr=7 pr=5 pw=0 time=39672 us)
    2829      MERGE JOIN  (cr=267410 pr=116712 pw=3563 time=30871775 us)
    4246       VIEW  (cr=262370 pr=116712 pw=3563 time=30771072 us)
    8928        WINDOW SORT PUSHED RANK (cr=262370 pr=116712 pw=3563 time=30671567 us)
12205347         HASH JOIN  (cr=262370 pr=113149 pw=0 time=173557 us)
  500000          TABLE ACCESS FULL PO_HEADER (cr=13190 pr=0 pw=0 time=18 us)
12205347          TABLE ACCESS FULL PO_LINE (cr=249180 pr=113149 pw=0 time=21 us)
    2829       SORT JOIN (cr=5040 pr=0 pw=0 time=60695 us)
   66462        TABLE ACCESS FULL PARTS (cr=5040 pr=0 pw=0 time=47 us)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                       4        0.00          0.00
  db file sequential read                       265        0.02          0.27
  db file scattered read                       1076        0.05          1.33
  i/o slave wait                                162        0.03          0.45
  direct path write temp                          1        0.00          0.00
  direct path read temp                         118        0.03          0.38
  SQL*Net message from client                     4        0.00          0.01
  SQL*Net more data to client                   229        0.00          0.00

Oracle Database 11.2.0.1 Standard Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.63       0.64          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        4     26.87      30.38     253292     272827         62        2550
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        6     27.51      31.03     253292     272827         62        2550

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 51 

 Rows     Row Source Operation
 -------  ---------------------------------------------------
    2550  HASH JOIN  (cr=272827 pr=253292 pw=3742 time=707146 us cost=191123 size=3936296694 card=10754909)
    2200   TABLE ACCESS FULL LOCATIONS (cr=31 pr=0 pw=0 time=0 us cost=4 size=176000 card=2200)
    2551   HASH JOIN  (cr=272796 pr=253292 pw=3742 time=617905 us cost=191068 size=3075903974 card=10754909)
   49786    TABLE ACCESS FULL VENDORS (cr=2505 pr=0 pw=0 time=17533 us cost=199 size=6472180 card=49786)
    2551    HASH JOIN  (cr=270291 pr=253292 pw=3742 time=616563 us cost=169295 size=1677765804 card=10754909)
   49786     TABLE ACCESS FULL VENDORS (cr=2505 pr=0 pw=0 time=15741 us cost=199 size=1593152 card=49786)
    2551     HASH JOIN  (cr=267786 pr=253292 pw=3742 time=614550 us cost=151655 size=1333608716 card=10754909)
       8      TABLE ACCESS FULL UMS (cr=7 pr=5 pw=0 time=0 us cost=2 size=56 card=8)
    2829      MERGE JOIN  (cr=267779 pr=253287 pw=3742 time=1493184 us cost=151595 size=1428012378 card=12205234)
    4246       VIEW  (cr=262752 pr=253287 pw=3742 time=660596 us cost=150591 size=585856656 card=12205347)
  511557        WINDOW SORT PUSHED RANK (cr=262752 pr=253287 pw=3742 time=1379383 us cost=150591 size=598062003 card=12205347)
12205347         HASH JOIN  (cr=262752 pr=249545 pw=0 time=8177985 us cost=27537 size=598062003 card=12205347)
  500000          TABLE ACCESS FULL PO_HEADER (cr=13190 pr=0 pw=0 time=65267 us cost=1118 size=10000000 card=500000)
12205347          TABLE ACCESS FULL PO_LINE (cr=249562 pr=249545 pw=0 time=3676259 us cost=20188 size=353955063 card=12205347)
    2829       SORT JOIN (cr=5027 pr=0 pw=0 time=0 us cost=1003 size=3056010 card=44290)
   66462        TABLE ACCESS FULL PARTS (cr=5027 pr=0 pw=0 time=27734 us cost=402 size=3056010 card=44290)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                       4        0.00          0.00
  db file sequential read                         2        0.01          0.01
  db file scattered read                          1        0.00          0.00
  direct path read                              202        0.07          2.80
  asynch descriptor resize                        8        0.00          0.00
  direct path write temp                          1        0.00          0.00
  direct path read temp                         101        0.04          0.51
  SQL*Net message from client                     4        0.00          0.00
  SQL*Net more data to client                    56        0.00          0.00

Oracle Database 11.2.0.1 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.67       0.66          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        4     26.75      30.20     252903     272476         62        2550
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        6     27.42      30.86     252903     272476         62        2550

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 194 

 Rows     Row Source Operation
 -------  ---------------------------------------------------
    2550  HASH JOIN  (cr=272476 pr=252903 pw=3742 time=712244 us cost=191070 size=3936284616 card=10754876)
    2200   TABLE ACCESS FULL LOCATIONS (cr=31 pr=0 pw=0 time=244 us cost=4 size=176000 card=2200)
    2551   HASH JOIN  (cr=272445 pr=252903 pw=3742 time=614550 us cost=191015 size=3075894536 card=10754876)
   49786    TABLE ACCESS FULL VENDORS (cr=2518 pr=0 pw=0 time=17661 us cost=199 size=6472180 card=49786)
    2551    HASH JOIN  (cr=269927 pr=252903 pw=3742 time=613476 us cost=169243 size=1677760656 card=10754876)
   49786     TABLE ACCESS FULL VENDORS (cr=2518 pr=0 pw=0 time=14973 us cost=199 size=1593152 card=49786)
    2551     HASH JOIN  (cr=267409 pr=252903 pw=3742 time=611597 us cost=151602 size=1333604624 card=10754876)
       8      TABLE ACCESS FULL UMS (cr=7 pr=5 pw=0 time=0 us cost=2 size=56 card=8)
    2829      MERGE JOIN  (cr=267402 pr=252898 pw=3742 time=705457 us cost=151543 size=1428008049 card=12205197)
    4246       VIEW  (cr=262362 pr=252898 pw=3742 time=659098 us cost=150541 size=585856656 card=12205347)
  511304        WINDOW SORT PUSHED RANK (cr=262362 pr=252898 pw=3742 time=711906 us cost=150541 size=598062003 card=12205347)
12205347         HASH JOIN  (cr=262362 pr=249156 pw=0 time=9688757 us cost=27487 size=598062003 card=12205347)
  500000          TABLE ACCESS FULL PO_HEADER (cr=13190 pr=0 pw=0 time=61939 us cost=1118 size=10000000 card=500000)
12205347          TABLE ACCESS FULL PO_LINE (cr=249172 pr=249156 pw=0 time=5162968 us cost=20138 size=353955063 card=12205347)
   2829       SORT JOIN (cr=5040 pr=0 pw=0 time=0 us cost=1001 size=3046557 card=44153)
  66462        TABLE ACCESS FULL PARTS (cr=5040 pr=0 pw=0 time=26200 us cost=402 size=3046557 card=44153)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                       4        0.00          0.00
  db file sequential read                         1        0.00          0.00
  db file scattered read                          2        0.00          0.00
  direct path read                              187        0.07          2.90
  asynch descriptor resize                        8        0.00          0.00
  direct path write temp                          1        0.00          0.00
  direct path read temp                         127        0.03          0.44
  SQL*Net message from client                     4        0.00          0.00
  SQL*Net more data to client                    56        0.00          0.00   

For all parts, determine the number of purchase order line exceptions where a part was purchase from a vendor other than the preferred vendor:

SELECT
  P.PART_ID,
  P.DESCRIPTION,
  P.PREF_VENDOR_ID,
  V.VENDOR_NAME PREF_VENDOR_NAME,
  PV.VENDOR_ID,
  V2.VENDOR_NAME LAST_VENDOR_NAME,
  PV.ORDER_LINES,
  PV.FIRST_RECV_DATE,
  PV.LAST_RECV_DATE
FROM
  (SELECT
    PO.VENDOR_ID,
    POL.PART_ID,
    COUNT(*) ORDER_LINES,
    MIN(POL.DESIRED_RECV_DATE) FIRST_RECV_DATE,
    MAX(POL.DESIRED_RECV_DATE) LAST_RECV_DATE
  FROM
    PO_HEADER PO,
    PO_LINE POL
  WHERE
    PO.PURC_ORDER_ID=POL.PURC_ORDER_ID
  GROUP BY
    PO.VENDOR_ID,
    POL.PART_ID) PV,
  PARTS P,
  VENDORS V,
  VENDORS V2
WHERE
  P.PART_ID=PV.PART_ID
  AND P.PREF_VENDOR_ID != PV.VENDOR_ID
  AND P.PREF_VENDOR_ID=V.VENDOR_ID
  AND PV.VENDOR_ID=V2.VENDOR_ID 

Laptop running 11.2.0.1 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.09       0.08          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch      151      9.98      10.16     249049     272219          0      149403
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total      153     10.07      10.24     249049     272219          0      149403

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 286 
Number of plan statistics captured: 1

Rows (1st) Rows (avg) Rows (max)  Row Source Operation
---------- ---------- ----------  ---------------------------------------------------
    149403     149403     149403  HASH JOIN  (cr=272219 pr=249049 pw=0 time=244266 us cost=161133 size=1879414152 card=12203988)
     49786      49786      49786   TABLE ACCESS FULL VENDORS (cr=2497 pr=0 pw=0 time=13182 us cost=197 size=1443794 card=49786)
    149403     149403     149403   HASH JOIN  (cr=269722 pr=249049 pw=0 time=166941 us cost=160877 size=1525498500 card=12203988)
     66462      66462      66462    JOIN FILTER CREATE :BF0000 (cr=7493 pr=0 pw=0 time=62115 us cost=594 size=4519416 card=66462)
     66462      66462      66462     HASH JOIN  (cr=7493 pr=0 pw=0 time=51123 us cost=594 size=4519416 card=66462)
     49786      49786      49786      TABLE ACCESS FULL VENDORS (cr=2497 pr=0 pw=0 time=12286 us cost=197 size=1443794 card=49786)
     66462      66462      66462      TABLE ACCESS FULL PARTS (cr=4996 pr=0 pw=0 time=31824 us cost=396 size=2592018 card=66462)
    150920     150920     150920    VIEW  (cr=262229 pr=249049 pw=0 time=99204 us cost=150135 size=695704779 card=12205347)
    150920     150920     150920     HASH GROUP BY (cr=262229 pr=249049 pw=0 time=65027 us cost=150135 size=598062003 card=12205347)
   8219280    8219280    8219280      JOIN FILTER USE :BF0000 (cr=262229 pr=249049 pw=0 time=5918254 us cost=27081 size=598062003 card=12205347)
  12205347   12205347   12205347       HASH JOIN  (cr=262229 pr=249049 pw=0 time=5812435 us cost=27081 size=598062003 card=12205347)
    500000     500000     500000        TABLE ACCESS FULL PO_HEADER (cr=13173 pr=0 pw=0 time=58612 us cost=1038 size=10000000 card=500000)
  12205347   12205347   12205347        TABLE ACCESS FULL PO_LINE (cr=249056 pr=249049 pw=0 time=1746674 us cost=19811 size=353955063 card=12205347)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                     151        0.00          0.00
  asynch descriptor resize                        6        0.00          0.00
  direct path read                                9        0.00          0.01
  SQL*Net message from client                   151        0.00          0.23
  SQL*Net more data to client                  1643        0.00          0.07 

Oracle Database 10.2.0.5 Standard Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.10       0.14          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch      151     12.05      12.14          0     272496          0      149395
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total      153     12.16      12.29          0     272496          0      149395

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 47 

 Rows     Row Source Operation
 -------  ---------------------------------------------------
  149395  HASH JOIN  (cr=272496 pr=0 pw=0 time=11778583 us)
   49786   TABLE ACCESS FULL VENDORS (cr=2518 pr=0 pw=0 time=36 us)
  149395   HASH JOIN  (cr=269978 pr=0 pw=0 time=11761016 us)
   66462    HASH JOIN  (cr=7558 pr=0 pw=0 time=17370 us)
   49786     TABLE ACCESS FULL VENDORS (cr=2518 pr=0 pw=0 time=20 us)
   66462     TABLE ACCESS FULL PARTS (cr=5040 pr=0 pw=0 time=18 us)
  224290    VIEW  (cr=262420 pr=0 pw=0 time=11532768 us)
  224290     HASH GROUP BY (cr=262420 pr=0 pw=0 time=11532765 us)
12205347      HASH JOIN  (cr=262420 pr=0 pw=0 time=178331 us)
  500000       TABLE ACCESS FULL PO_HEADER (cr=13190 pr=0 pw=0 time=23 us)
12205347       TABLE ACCESS FULL PO_LINE (cr=249230 pr=0 pw=0 time=20 us)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                     151        0.00          0.00
  SQL*Net message from client                   151        0.00          0.24
  SQL*Net more data to client                  7448        0.00          0.10

Oracle Database 10.2.0.5 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.06       0.21          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch      151     12.65      14.34     113149     272446          0      149407
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total      153     12.71      14.56     113149     272446          0      149407

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 164 

 Rows     Row Source Operation
 -------  ---------------------------------------------------
  149407  HASH JOIN  (cr=272446 pr=113149 pw=0 time=13979365 us)
   49786   TABLE ACCESS FULL VENDORS (cr=2518 pr=0 pw=0 time=25 us)
  149407   HASH JOIN  (cr=269928 pr=113149 pw=0 time=13961727 us)
   66462    HASH JOIN  (cr=7558 pr=0 pw=0 time=17388 us)
   49786     TABLE ACCESS FULL VENDORS (cr=2518 pr=0 pw=0 time=20 us)
   66462     TABLE ACCESS FULL PARTS (cr=5040 pr=0 pw=0 time=19 us)
  224290    VIEW  (cr=262370 pr=113149 pw=0 time=13733144 us)
  224290     HASH GROUP BY (cr=262370 pr=113149 pw=0 time=13733143 us)
12205347      HASH JOIN  (cr=262370 pr=113149 pw=0 time=172881 us)
  500000       TABLE ACCESS FULL PO_HEADER (cr=13190 pr=0 pw=0 time=26 us)
12205347       TABLE ACCESS FULL PO_LINE (cr=249180 pr=113149 pw=0 time=21 us)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                     151        0.00          0.00
  db file sequential read                       245        0.02          0.25
  db file scattered read                       1215        0.04          1.33
  SQL*Net message from client                   151        0.00          0.24
  SQL*Net more data to client                  7458        0.00          0.10 

Oracle Database 11.2.0.1 Standard Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.09       0.09          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch      151      9.96      18.19     249545     272789          0      149400
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total      153     10.06      18.28     249545     272789          0      149400

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 51 

 Rows     Row Source Operation
 -------  ---------------------------------------------------
  149400  HASH JOIN  (cr=272789 pr=249545 pw=0 time=200990 us cost=161597 size=1879414152 card=12203988)
   49786   TABLE ACCESS FULL VENDORS (cr=2505 pr=0 pw=0 time=15101 us cost=199 size=1443794 card=49786)
  149400   HASH JOIN  (cr=270284 pr=249545 pw=0 time=130068 us cost=161339 size=1525498500 card=12203988)
   66462    JOIN FILTER CREATE :BF0000 (cr=7532 pr=0 pw=0 time=61092 us cost=600 size=4519416 card=66462)
   66462     HASH JOIN  (cr=7532 pr=0 pw=0 time=50101 us cost=600 size=4519416 card=66462)
   49786      TABLE ACCESS FULL VENDORS (cr=2505 pr=0 pw=0 time=13182 us cost=199 size=1443794 card=49786)
   66462      TABLE ACCESS FULL PARTS (cr=5027 pr=0 pw=0 time=25817 us cost=400 size=2592018 card=66462)
  150920    VIEW  (cr=262752 pr=249545 pw=0 time=80131 us cost=150591 size=695704779 card=12205347)
  150920     HASH GROUP BY (cr=262752 pr=249545 pw=0 time=53506 us cost=150591 size=598062003 card=12205347)
 8219280      JOIN FILTER USE :BF0000 (cr=262752 pr=249545 pw=0 time=20817762 us cost=27537 size=598062003 card=12205347)
12205347       HASH JOIN  (cr=262752 pr=249545 pw=0 time=16388226 us cost=27537 size=598062003 card=12205347)
  500000        TABLE ACCESS FULL PO_HEADER (cr=13190 pr=0 pw=0 time=65651 us cost=1118 size=10000000 card=500000)
12205347        TABLE ACCESS FULL PO_LINE (cr=249562 pr=249545 pw=0 time=12278561 us cost=20188 size=353955063 card=12205347)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                     151        0.00          0.00
  asynch descriptor resize                        6        0.00          0.00
  direct path read                             1943        0.04          7.84
  SQL*Net message from client                   151        0.00          0.26
  SQL*Net more data to client                  1792        0.00          0.03 

Oracle Database 11.2.0.1 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.09       0.09          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch      151     10.34      15.04     249156     272438          0      149408
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total      153     10.43      15.13     249156     272438          0      149408

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 194 

 Rows     Row Source Operation
 -------  ---------------------------------------------------
  149408  HASH JOIN  (cr=272438 pr=249156 pw=0 time=202794 us cost=161546 size=1879414152 card=12203988)
   49786   TABLE ACCESS FULL VENDORS (cr=2518 pr=0 pw=0 time=12798 us cost=199 size=1443794 card=49786)
  149408   HASH JOIN  (cr=269920 pr=249156 pw=0 time=133531 us cost=161289 size=1525498500 card=12203988)
   66462    JOIN FILTER CREATE :BF0000 (cr=7558 pr=0 pw=0 time=60198 us cost=600 size=4519416 card=66462)
   66462     HASH JOIN  (cr=7558 pr=0 pw=0 time=48567 us cost=600 size=4519416 card=66462)
   49786      TABLE ACCESS FULL VENDORS (cr=2518 pr=0 pw=0 time=12286 us cost=199 size=1443794 card=49786)
   66462      TABLE ACCESS FULL PARTS (cr=5040 pr=0 pw=0 time=23900 us cost=400 size=2592018 card=66462)
  150920    VIEW  (cr=262362 pr=249156 pw=0 time=82819 us cost=150541 size=695704779 card=12205347)
  150920     HASH GROUP BY (cr=262362 pr=249156 pw=0 time=51970 us cost=150541 size=598062003 card=12205347)
 8219280      JOIN FILTER USE :BF0000 (cr=262362 pr=249156 pw=0 time=6369576 us cost=27487 size=598062003 card=12205347)
12205347       HASH JOIN  (cr=262362 pr=249156 pw=0 time=6154577 us cost=27487 size=598062003 card=12205347)
  500000        TABLE ACCESS FULL PO_HEADER (cr=13190 pr=0 pw=0 time=65779 us cost=1118 size=10000000 card=500000)
12205347        TABLE ACCESS FULL PO_LINE (cr=249172 pr=249156 pw=0 time=2004720 us cost=20138 size=353955063 card=12205347)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                     151        0.00          0.00
  asynch descriptor resize                        6        0.00          0.00
  direct path read                              578        0.06          4.78
  SQL*Net message from client                   151        0.00          0.26
  SQL*Net more data to client                  1793        0.00          0.03   

A give me every column type query, were the user doesn’t know exactly what vendor they are looking for, or exactly what part, but they know that the purchase order line has been posted to the GL:

SELECT
  *
FROM
  PO_HEADER PO,
  PO_LINE POL,
  PARTS P,
  VENDORS V
WHERE
  PO.VENDOR_ID LIKE '100%'
  AND PO.POSTING_CANDIDATE='N'
  AND PO.PURC_ORDER_ID=POL.PURC_ORDER_ID
  AND POL.PART_ID BETWEEN '80' AND '999999'
  AND POL.PART_ID=P.PART_ID
  AND PO.VENDOR_ID=V.VENDOR_ID 

Laptop running 11.2.0.1 Enterprise Edition:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.06       0.05          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        6      0.12       0.64       1410      11322          0        4629
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        8      0.18       0.69       1410      11322          0        4629

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 286 
Number of plan statistics captured: 1

Rows (1st) Rows (avg) Rows (max)  Row Source Operation
---------- ---------- ----------  ---------------------------------------------------
      4629       4629       4629  NESTED LOOPS  (cr=11322 pr=1410 pw=0 time=707312 us)
      4629       4629       4629   NESTED LOOPS  (cr=6693 pr=1410 pw=0 time=724219 us cost=12 size=2964 card=3)
      4629       4629       4629    NESTED LOOPS  (cr=2058 pr=1343 pw=0 time=606393 us cost=9 size=1875 card=3)
       387        387        387     NESTED LOOPS  (cr=571 pr=6 pw=0 time=2991 us cost=6 size=505 card=1)
        33         33         33      TABLE ACCESS BY INDEX ROWID VENDORS (cr=40 pr=2 pw=0 time=224 us cost=3 size=342 card=1)
        33         33         33       INDEX RANGE SCAN SYS_C0024972 (cr=7 pr=2 pw=0 time=128 us cost=2 size=0 card=1)(object id 82050)
       387        387        387      TABLE ACCESS BY INDEX ROWID PO_HEADER