Oracle8i Tuning Release 8.1.5 A67775-01 |
|
The SQL trace facility and TKPROF are two basic performance diagnostic tools that can help you monitor and tune applications running against the Oracle Server. This chapter covers:
The SQL trace facility and TKPROF enable you to accurately assess the efficiency of the SQL statements your application runs. For best results, use these tools with EXPLAIN PLAN, rather than using EXPLAIN PLAN alone. This section covers:
The SQL trace facility provides performance information on individual SQL statements. It generates the following statistics for each statement:
You can enable the SQL trace facility for a session or for an instance. When the SQL trace facility is enabled, performance statistics for all SQL statements executed in a user session or in an instance are placed into a trace file.
The additional overhead of running the SQL trace facility against an application with performance problems is normally insignificant, compared with the inherent overhead caused by the application's inefficiency.
You can run the TKPROF program to format the contents of the trace file and place the output into a readable output file. Optionally, TKPROF can also:
TKPROF reports each statement executed with the resources it has consumed, the number of times it was called, and the number of rows which it processed. This information lets you easily locate those statements that are using the greatest resource. With experience or with baselines available, you can assess whether the resources used are reasonable given the work done.
Follow these steps to use the SQL trace facility and TKPROF:
In the following sections each of these steps is discussed in depth.
When the SQL trace facility is enabled for a session, Oracle generates a trace file containing statistics for traced SQL statements for that session. When the SQL trace facility is enabled for an instance, Oracle creates a separate trace file for each process.
Before enabling the SQL trace facility, you should:
Table 14-1 SQL Trace Facility Dynamic Initialization Parameters
Be sure you know how to distinguish the trace files by name. Oracle writes them to the user dump destination specified by USER_DUMP_DEST. However, this directory may soon contain many hundreds of files, usually with generated names. It may be difficult to match trace files back to the session or process that created them. You can tag trace files by including in your programs a statement like SELECT 'program name' FROM DUAL. You can then trace each file back to the process that created it.
You can enable the SQL trace facility for a session or for the instance. This section covers:
To enable the SQL trace facility for your current session, enter:
ALTER SESSION SET SQL_TRACE = TRUE;
Alternatively, you can enable the SQL trace facility for your session by using the DBMS_SESSION.SET_SQL_TRACE procedure.
To disable the SQL trace facility for your session, enter:
ALTER SESSION SET SQL_TRACE = FALSE;
The SQL trace facility is automatically disabled for your session when your application disconnects from Oracle.
To enable the SQL trace facility for your instance, set the value of the SQL_TRACE initialization parameter to TRUE. Statistics will be collected for all sessions.
Once the SQL trace facility has been enabled for the instance, you can disable it for an individual session by entering:
ALTER SESSION SET SQL_TRACE = FALSE;
This section covers:
TKPROF accepts as input a trace file produced by the SQL trace facility and produces a formatted output file. TKPROF can also be used to generate execution plans.
Once the SQL trace facility has generated a number of trace files, you can:
TKPROF does not report COMMITs and ROLLBACKs that are recorded in the trace file.
Sample output from TKPROF is as follows:
SELECT * FROM emp, dept WHERE emp.deptno = dept.deptno; call count cpu elapsed disk query current rows ---- ------- ------- --------- -------- -------- ------- ------ Parse 1 0.16 0.29 3 13 0 0 Execute 1 0.00 0.00 0 0 0 0 Fetch 1 0.03 0.26 2 2 4 14 Misses in library cache during parse: 1 Parsing user id: (8) SCOTT Rows Execution Plan ------- --------------------------------------------------- 14 MERGE JOIN 4 SORT JOIN 4 TABLE ACCESS (FULL) OF 'DEPT' 14 SORT JOIN 14 TABLE ACCESS (FULL) OF 'EMP'
For this statement, TKPROF output includes the following information:
TKPROF also provides a summary of user level statements and recursive SQL calls for the trace file.
Invoke TKPROF using this syntax:
If you invoke TKPROF without arguments, online help is displayed.
Use the following arguments with TKPROF:
Argument | Meaning | |
filename1 |
Specifies the input file, a trace file containing statistics produced by the SQL trace facility. This file can be either a trace file produced for a single session or a file produced by concatenating individual trace files from multiple sessions. |
|
filename2 |
Specifies the file to which TKPROF writes its formatted output. |
|
SORT |
Sorts traced SQL statements in descending order of specified sort option before listing them into the output file. If more than one option is specified, the output is sorted in descending order by the sum of the values specified in the sort options. If you omit this parameter, TKPROF lists statements into the output file in order of first use. Sort options are as follows: |
|
PRSCNT |
Number of times parsed |
|
PRSCPU |
CPU time spent parsing |
|
PRSELA |
Elapsed time spent parsing |
|
PRSDSK |
Number of physical reads from disk during parse |
|
PRSMIS |
Number of consistent mode block reads during parse |
|
PRSCU |
Number of current mode block reads during parse |
|
PRSMIS |
Number of library cache misses during parse |
|
EXECNT |
Number of executes |
|
EXECPU |
CPU time spent executing |
|
EXEELA |
Elapsed time spent executing |
|
EXEDSK |
Number of physical reads from disk during execute |
|
EXEQRY |
Number of consistent mode block reads during execute |
|
EXECU |
Number of current mode block reads during execute |
|
EXEROW |
Number of rows processed during execute |
|
EXEMIS |
Number of library cache misses during execute |
|
FCHCNT |
Number of fetches |
|
FCHCPU |
CPU time spent fetching |
|
FCHELA |
Elapsed time spent fetching |
|
FCHDSK |
Number of physical reads from disk during fetch |
|
FCHQRY |
Number of consistent mode block reads during fetch |
|
FCHCU |
Number of current mode block reads during fetch |
|
FCHROW |
Number of rows fetched |
|
|
Lists only the first integer sorted SQL statements into the output file. If you omit this parameter, TKPROF lists all traced SQL statements. This parameter does not affect the optional SQL script. The SQL script always inserts statistics for all traced SQL statements. |
|
AGGREGATE |
If you specify AGGREGATE = NO, then TKPROF does not aggregate multiple users of the same SQL text. |
|
INSERT |
Creates a SQL script that stores the trace file statistics in the database. TKPROF creates this script with the name filename3. This script creates a table and inserts a row of statistics for each traced SQL statement into the table. |
|
SYS |
Enables and disables the listing of SQL statements issued by the user SYS, or recursive SQL statements, into the output file. The default value of YES causes TKPROF to list these statements. The value of NO causes TKPROF to omit them. This parameter does not affect the optional SQL script. The SQL script always inserts statistics for all traced SQL statements, including recursive SQL statements. |
|
TABLE |
Specifies the schema and name of the table into which TKPROF temporarily places execution plans before writing them to the output file. If the specified table already exists, TKPROF deletes all rows in the table, uses it for the EXPLAIN PLAN statement (which writes more rows into the table), and then deletes those rows. If this table does not exist, TKPROF creates it, uses it, and then drops it. |
|
RECORD |
Creates a SQL script with the specified filename with all of the nonrecursive SQL in the trace file. This can be used to replay the user events from the trace file. |
|
EXPLAIN |
Determines the execution plan for each SQL statement in the trace file and writes these execution plans to the output file. TKPROF determines execution plans by issuing the EXPLAIN PLAN statement after connecting to Oracle with the user and password specified in this parameter. The specified user must have CREATE SESSION system privileges. TKPROF will take longer to process a large trace file if the EXPLAIN option is used. |
This section provides two brief examples of TKPROF usage. For an complete example of TKPROF output, see "TKPROF Output Example".
If you are processing a large trace file using a combination of SORT parameters and the PRINT parameter, you can produce a TKPROF output file containing only the highest resource-intensive statements. For example, the following statement prints the ten statements in the trace file that have generated the most physical I/O:
TKPROF ora53269.trc ora 53269.prf SORT = (PRSDSK, EXEDSK, FCHDSK) PRINT = 10
This example runs TKPROF, accepts a trace file named "dlsun12_jane_fg_svrmgr_007.trc", and writes a formatted output file named "outputa.prf":
TKPROF DLSUN12_JANE_FG_SVRMGR_007.TRC OUTPUTA.PRF EXPLAIN=SCOTT/TIGER TABLE=SCOTT.TEMP_PLAN_TABLE_A INSERT=STOREA.SQL SYS=NO SORT=(EXECPU,FCHCPU)
This example is likely to be longer than a single line on your screen and you may have to use continuation characters, depending on your operating system.
Note the other parameters in this example:
This section provides pointers for interpreting TKPROF output.
While TKPROF provides a very useful analysis, the most accurate measure of efficiency is the actual performance of the application in question. At the end of the TKPROF output is a summary of the work done in the database engine by the process during the period that the trace was running.
TKPROF lists the statistics for a SQL statement returned by the SQL trace facility in rows and columns. Each row corresponds to one of three steps of SQL statement processing. The step for which each row contains statistics is identified by the value of the CALL column:
The other columns of the SQL trace facility output are combined statistics for all parses, all executes, and all fetches of a statement. These values are zero (0) if TIMED_STATISTICS is not turned on. The sum of query and current is the total number of buffers accessed.
Statistics about the processed rows appear in the ROWS column.
ROWS |
Total number of rows processed by the SQL statement. This total does not include rows processed by subqueries of the SQL statement. |
For SELECT statements, the number of rows returned appears for the fetch step. For UPDATE, DELETE, and INSERT statements, the number of rows processed appears for the execute step.
Timing statistics have a resolution of one hundredth of a second; therefore, any operation on a cursor that takes a hundredth of a second or less may not be timed accurately. Keep this in mind when interpreting statistics. In particular, be careful when interpreting the results from simple queries that execute very quickly.
Sometimes in order to execute a SQL statement issued by a user, Oracle must issue additional statements. Such statements are called recursive calls or recursive SQL statements. For example, if you insert a row into a table that does not have enough space to hold that row, Oracle makes recursive calls to allocate the space dynamically. Recursive calls are also generated when data dictionary information is not available in the data dictionary cache and must be retrieved from disk.
If recursive calls occur while the SQL trace facility is enabled, TKPROF produces statistics for the recursive SQL statements and marks them clearly as recursive SQL statements in the output file. You can suppress the listing of recursive calls in the output file by setting the SYS statement-line parameter to NO. The statistics for a recursive SQL statement are included in the listing for that statement, not in the listing for the SQL statement that caused the recursive call. So when you are calculating the total resources required to process a SQL statement, you should consider the statistics for that statement as well as those for recursive calls caused by that statement.
TKPROF also lists the number of library cache misses resulting from parse and execute steps for each SQL statement. These statistics appear on separate lines following the tabular statistics. If the statement resulted in no library cache misses, TKPROF does not list the statistic. In "Sample TKPROF Output", the example, the statement resulted in one library cache miss for the parse step and no misses for the execute step.
The following SQL statements are truncated to 25 characters in the SQL trace file:
TKPROF also lists the user ID of the user issuing each SQL statement. If the SQL trace input file contained statistics from multiple users and the statement was issued by more than one user, TKPROF lists the ID of the last user to parse the statement. The user ID of all database users appears in the data dictionary in the column ALL_USERS.USER_ID.
If you specify the EXPLAIN parameter on the TKPROF statement line, TKPROF uses the EXPLAIN PLAN statement to generate the execution plan of each SQL statement traced. TKPROF also displays the number of rows processed by each step of the execution plan.
The following listing shows TKPROF output for one SQL statement as it appears in the output file:
SELECT * FROM emp, dept WHERE emp.deptno = dept.deptno; call count cpu elapsed disk query current rows ---- ------- ------- --------- -------- -------- ------- ------ Parse 11 0.08 0.18 0 0 0 0 Execute 11 0.23 0.66 0 3 6 2 Fetch 35 6.70 6.83 100 12326 2 824 ------------------------------------------------------------------ total 57 7.01 7.67 100 12329 8 826 Misses in library cache during parse: 0 10 user SQL statements in session. 0 internal SQL statements in session. 10 SQL statements in session.
If it is acceptable to expend 7.01 CPU seconds to insert, update or delete 2 rows and to retrieve 824 rows, then you need not look any further at this trace output. In fact, a major use of TKPROF reports in a tuning exercise is to eliminate processes from the detailed tuning phase.
You can also see from this summary that 1 unnecessary parse call was made (because there were 11 parse calls, but only 10 user SQL statements) and that array fetch operations were performed. (You know this because more rows were fetched than there were fetches performed.)
Finally, very little physical I/O was performed; this is suspicious and probably means that the same database blocks were being continually revisited.
Having established that the process has used excessive resource, the next step is to discover which SQL statements are the culprits. Normally only a small percentage of the SQL statements in any process need to be tuned--those that use the greatest resource.
The examples that follow were all produced with TIMED_STATISTICS=TRUE. However, with the exception of locking problems and inefficient PL/SQL loops, neither the CPU time nor the elapsed time are necessary to find the problem statements. The key is the number of block visits both query (that is, subject to read consistency) and current (not subject to read consistency). Segment headers and blocks that are going to be updated are always acquired in current mode, but all query and subquery processing requests the data in query mode. These are precisely the same measures as the instance statistics CONSISTENT GETS and DB BLOCK GETS.
The SQL parsed as SYS is recursive SQL used to maintain the dictionary cache, and is not normally of great benefit. If the number of internal SQL statements looks high, you might want to check to see what has been going on. (There may be excessive space management overhead.)
This section covers:
You may want to keep a history of the statistics generated by the SQL trace facility for your application and compare them over time. TKPROF can generate a SQL script that creates a table and inserts rows of statistics into it. This script contains
After running TKPROF, you can run this script to store the statistics in the database.
When you run TKPROF, use the INSERT parameter to specify the name of the generated SQL script. If you omit this parameter, TKPROF does not generate a script.
After TKPROF has created the SQL script, you may want to edit the script before running it.
If you have already created an output table for previously collected statistics and you want to add new statistics to this table, remove the CREATE TABLE statement from the script. The script will then insert the new rows into the existing table.
If you have created multiple output tables, perhaps to store statistics from different databases in different tables, edit the CREATE TABLE and INSERT statements to change the name of the output table.
The following CREATE TABLE statement creates the TKPROF_TABLE:
CREATE TABLE tkprof_table (date_of_insert DATE, cursor_num NUMBER, depth NUMBER, user_id NUMBER, parse_cnt NUMBER, parse_cpu NUMBER, parse_elap NUMBER, parse_disk NUMBER, parse_query NUMBER, parse_current NUMBER, parse_miss NUMBER, exe_count NUMBER, exe_cpu NUMBER, exe_elap NUMBER, exe_disk NUMBER, exe_query NUMBER, exe_current NUMBER, exe_miss NUMBER, exe_rows NUMBER, fetch_count NUMBER, fetch_cpu NUMBER, fetch_elap NUMBER, fetch_disk NUMBER, fetch_query NUMBER, fetch_current NUMBER, fetch_rows NUMBER, clock_ticks NUMBER, sql_statement LONG);
Most output table columns correspond directly to the statistics that appear in the formatted output file. For example, the PARSE_CNT column value corresponds to the count statistic for the parse step in the output file.
These columns help you identify a row of statistics:
The following query returns the statistics from the output table. These statistics correspond to the formatted output shown in the section "Sample TKPROF Output".
SELECT * FROM tkprof_table;
Oracle responds with something similar to:
DATE_OF_INSERT CURSOR_NUM DEPTH USER_ID PARSE_CNT PARSE_CPU PARSE_ELAP -------------- ---------- ----- ------- --------- --------- ---------- 21-DEC-1998 1 0 8 1 16 22 PARSE_DISK PARSE_QUERY PARSE_CURRENT PARSE_MISS EXE_COUNT EXE_CPU ---------- ----------- ------------- ---------- --------- ------- 3 11 0 1 1 0 EXE_ELAP EXE_DISK EXE_QUERY EXE_CURRENT EXE_MISS EXE_ROWS FETCH_COUNT -------- -------- --------- ----------- -------- -------- ----------- 0 0 0 0 0 0 1 FETCH_CPU FETCH_ELAP FETCH_DISK FETCH_QUERY FETCH_CURRENT FETCH_ROWS --------- ---------- ---------- ----------- ------------- ---------- 2 20 2 2 4 10 SQL_STATEMENT --------------------------------------------------------------------- SELECT * FROM EMP, DEPT WHERE EMP.DEPTNO = DEPT.DEPTNO
This section describes some fine points of TKPROF interpretation:
Look at the totals and try to identify the statements that constitute the bulk of the load.
Do not attempt to perform many different jobs within a single query. It is more effective to separate out the different queries that should be used when particular optional parameters are present, and when the parameters provided contain wild cards.
If particular parameters are not specified by the report user, the query uses bind variables that have been set to "%". This action has the effect of ignoring any LIKE clauses in the query. It would be more efficient to run a query in which these clauses are not present.
If you are not aware of the values being bound at run time, it is possible to fall into the "argument trap". Especially where the LIKE operator is used, the query may be markedly less efficient for particular values, or types of value, in a bind variable. This is because the optimizer must make an assumption about the probable selectivity without knowing the value.
The next example illustrates the read consistency trap. Without knowing that an uncommitted transaction had made a series of updates to the NAME column it is very difficult to see why so many block visits would be incurred.
Cases like this are not normally repeatable: if the process were run again, it is unlikely that another transaction would interact with it in the same way.
select NAME_ID from CQ_NAMES where NAME = 'FLOOR'; call count cpu elapsed disk query current rows ---- ----- --- ------- ---- ----- ------- ---- Parse 1 0.10 0.18 0 0 0 0 Execute 1 0.00 0.00 0 0 0 0 Fetch 1 0.11 0.21 2 101 0 1 Misses in library cache during parse: 1 Parsing user id: 01 (USER1) Rows Execution Plan ---- --------- ---- 0 SELECT STATEMENT 1 TABLE ACCESS (BY ROWID) OF 'CQ_NAMES' 2 INDEX (RANGE SCAN) OF 'CQ_NAMES_NAME' (NON_UNIQUE)
This example shows an extreme (and thus easily detected) example of the schema trap. At first it is difficult to see why such an apparently straightforward indexed query needs to look at so many database blocks, or why it should access any blocks at all in current mode.
select NAME_ID from CQ_NAMES where NAME = 'FLOOR'; call count cpu elapsed disk query current rows -------- ------- -------- --------- ------- ------ ------- ---- Parse 1 0.06 0.10 0 0 0 0 Execute 1 0.02 0.02 0 0 0 0 Fetch 1 0.23 0.30 31 51 3 1 Misses in library cache during parse: 0 Parsing user id: 02 (USER2) Rows Execution Plan ------- --------------------------------------------------- 0 SELECTSTATEMENT 2340 TABLE ACCESS (BY ROWID) OF 'CQ_NAMES' 0 INDEX (RANGE SCAN) OF 'CQ_NAMES_NAME' (NON-UNIQUE)
Two statistics suggest that the query may have been executed via a full table scan. These statistics are the current mode block visits, plus the number of rows originating from the Table Access row source in the execution plan. The explanation is that the required index was built after the trace file had been produced, but before TKPROF had been run.
Sometimes, as in the following example, you may wonder why a particular query has taken so long.
update CQ_NAMES set ATTRIBUTES = lower(ATTRIBUTES) where ATTRIBUTES = :att call count cpu elapsed disk query current rows -------- ------- -------- --------- -------- -------- ------- ---------- Parse 1 0.06 0.24 0 0 0 0 Execute 1 0.62 19.62 22 526 12 7 Fetch 0 0.00 0.00 0 0 0 0 Misses in library cache during parse: 1 Parsing user id: 02 (USER2) Rows Execution Plan ------- --------------------------------------------------- 0 UPDATE STATEMENT 2519 TABLE ACCESS (FULL) OF 'CQ_NAMES'
Again, the answer is interference from another transaction. In this case another transaction held a shared lock on the table CQ_NAMES for several seconds before and after the update was issued. It takes a fair amount of experience to diagnose that interference effects are occurring. On the one hand, comparative data is essential when the interference is contributing only a short delay (or a small increase in block visits in the previous example). On the other hand, if the interference is contributing only a modest overhead, and the statement is essentially efficient, its statistics may never have to be subjected to analysis.
The resources reported for a statement include those for all of the SQL issued while the statement was being processed. Therefore, they include any resources used within a trigger, along with the resources used by any other recursive SQL (such as that used in space allocation). With the SQL trace facility enabled, TKPROF reports these resources twice. Avoid trying to tune the DML statement if the resource is actually being consumed at a lower level of recursion.
You may need to inspect the raw trace file to see exactly where the resource is being expended. The entries for recursive SQL follow the PARSING IN CURSOR entry for the user's statement. Within the trace file, the order is less easily defined.
For comparison with the output that results from one of the foregoing traps, here is the TKPROF output for the indexed query with the index in place and without any contention effects.
select NAME_ID
from CQ_NAMES where NAME = 'FLOOR';
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 1 0.00 0.00 0 2 0 1
Misses in library cache during parse: 0
Parsing user id: 02 (USER2)
Rows Execution Plan
------- ---------------------------------------------------
0 SELECT STATEMENT
1 TABLE ACCESS (BY ROWID) OF 'CQ_NAMES'
2 INDEX (RANGE SCAN) OF 'CQ_NAMES_NAME' (NON-UNIQUE)
One of the marked features of this correct version is that the parse call took 10 milliseconds of both elapsed and CPU time, but the query apparently took no time at all to execute and no time at all to perform the fetch. In fact, no parse took place because the query was already available in parsed form within the shared SQL area. These anomalies arise because the clock tick of 10 msec is too long to reliably record simple and efficient queries.
This section provides an extensive example of TKPROF output. Portions have been edited out for the sake of brevity.
Copyright (c) Oracle Corporation 1979, 1998. All rights reserved. Trace file: v80_ora_2758.trc Sort options: default ******************************************************************************** count = number of times ../../server.815/a67846/toc.htm procedure was executed cpu = cpu time in seconds executing elapsed = elapsed time in seconds executing disk = number of physical reads of buffers from disk query = number of buffers gotten for consistent read current = number of buffers gotten in current mode (usually for update) rows = number of rows processed by the fetch or execute call ******************************************************************************** The following statement encountered a error during parse: select deptno, avg(sal) from emp e group by deptno having exists (select deptno from dept where dept.deptno = e.deptno and dept.budget > avg(e.sal)) order by 1 Error encountered: ORA-00904 ********************************************************************************
alter session set sql_trace = true call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 0 0.00 0.00 0 0 0 0 Execute 1 0.00 0.10 0 0 0 0 Fetch 0 0.00 0.00 0 0 0 0 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 1 0.00 0.10 0 0 0 0 Misses in library cache during parse: 0 Misses in library cache during execute: 1 Optimizer goal: CHOOSE Parsing user id: 02 (USER02) ******************************************************************************** select emp.ename, dept.dname from emp, dept where emp.deptno = dept.deptno call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 1 0.11 0.13 2 0 1 0 Execute 1 0.00 0.00 0 0 0 0 Fetch 1 0.00 0.00 2 2 4 14 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 3 0.11 0.13 4 2 5 14 Misses in library cache during parse: 1 Optimizer goal: CHOOSE Parsing user id: 02 (USER02) Rows Execution Plan ------- --------------------------------------------------- 0 SELECT STATEMENT GOAL: CHOOSE 14 MERGE JOIN 4 SORT (JOIN) 4 TABLE ACCESS (FULL) OF 'DEPT' 14 SORT (JOIN) 14 TABLE ACCESS (FULL) OF 'EMP' ******************************************************************************** select a.ename name, b.ename manager from emp a, emp b where a.mgr = b.empno(+) 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 1 0.01 0.01 1 50 2 14 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 3 0.02 0.02 1 50 2 14 Misses in library cache during parse: 1 Optimizer goal: CHOOSE Parsing user id: 01 (USER01) Rows Execution Plan ------- --------------------------------------------------- 0 SELECT STATEMENT GOAL: CHOOSE 13 NESTED LOOPS (OUTER) 14 TABLE ACCESS (FULL) OF 'EMP' 13 TABLE ACCESS (BY ROWID) OF 'EMP' 26 INDEX (RANGE SCAN) OF 'EMP_IND' (NON-UNIQUE) ******************************************************************************** select ename,job,sal from emp where sal = (select max(sal) from emp) 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 1 0.00 0.00 0 12 4 1 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 3 0.00 0.00 0 12 4 1 Misses in library cache during parse: 1 Optimizer goal: CHOOSE Parsing user id: 01 (USER01) Rows Execution Plan ------- --------------------------------------------------- 0 SELECT STATEMENT GOAL: CHOOSE 14 FILTER 14 TABLE ACCESS (FULL) OF 'EMP' 14 SORT (AGGREGATE) 14 TABLE ACCESS (FULL) OF 'EMP' ******************************************************************************** select deptno from emp where job = 'clerk' group by deptno having count(*) >= 2 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 1 0.00 0.00 0 1 1 0 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 3 0.00 0.00 0 1 1 0 Misses in library cache during parse: 13 Optimizer goal: CHOOSE Parsing user id: 01 (USER01) Rows Execution Plan ------- --------------------------------------------------- 0 SELECT STATEMENT GOAL: CHOOSE 0 FILTER 0 SORT (GROUP BY) 14 TABLE ACCESS (FULL) OF 'EMP' ******************************************************************************** select dept.deptno,dname,job,ename from dept,emp where dept.deptno = emp.deptno(+) order by dept.deptno call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 1 0.00 0.00 0 0 0 0 Execute 1 0.00 0.00 0 0 0 0 Fetch 1 0.00 0.00 0 3 3 10 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 3 0.00 0.00 0 3 3 10 Misses in library cache during parse: 1 Optimizer goal: CHOOSE Parsing user id: 01 (USER01) Rows Execution Plan ------- --------------------------------------------------- 0 SELECT STATEMENT GOAL: CHOOSE 14 MERGE JOIN (OUTER) 4 SORT (JOIN) 4 TABLE ACCESS (FULL) OF 'DEPT' 14 SORT (JOIN) 14 TABLE ACCESS (FULL) OF 'EMP' ******************************************************************************** select grade,job,ename,sal from emp,salgrade where sal between losal and hisal order by grade,job call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 1 0.04 0.06 2 16 1 0 Execute 1 0.00 0.00 0 0 0 0 Fetch 1 0.01 0.01 1 10 12 10 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 3 0.05 0.07 3 26 13 10 Misses in library cache during parse: 1 Optimizer goal: CHOOSE Parsing user id: 02 (USER02) Rows Execution Plan ------- --------------------------------------------------- 0 SELECT STATEMENT GOAL: CHOOSE 14 SORT (ORDER BY) 14 NESTED LOOPS 5 TABLE ACCESS (FULL) OF 'SALGRADE' 70 TABLE ACCESS (FULL) OF 'EMP' ******************************************************************************** select lpad(' ',level*2)||ename org_chart,level,empno,mgr,job,deptno from emp connect by prior empno = mgr start with ename = 'clark' or ename = 'blake' order by deptno 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 1 0.01 0.01 0 1 2 0 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 3 0.02 0.02 0 1 2 0 Misses in library cache during parse: 1 Optimizer goal: CHOOSE Parsing user id: 02 (USER02) Rows Execution Plan ------- --------------------------------------------------- 0 SELECT STATEMENT GOAL: CHOOSE 0 SORT (ORDER BY) 0 CONNECT BY 14 TABLE ACCESS (FULL) OF 'EMP' 0 TABLE ACCESS (BY ROWID) OF 'EMP' 0 TABLE ACCESS (FULL) OF 'EMP' ******************************************************************************** create table tkoptkp (a number, b number) call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 1 0.00 0.00 0 0 0 0 Execute 1 0.01 0.01 1 0 1 0 Fetch 0 0.00 0.00 0 0 0 0 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 2 0.01 0.01 1 0 1 0 Misses in library cache during parse: 1 Optimizer goal: CHOOSE Parsing user id: 02 (USER02) Rows Execution Plan ------- --------------------------------------------------- 0 CREATE TABLE STATEMENT GOAL: CHOOSE ******************************************************************************** insert into tkoptkp values (1,1) call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 1 0.07 0.09 0 0 0 0 Execute 1 0.01 0.20 2 2 3 1 Fetch 0 0.00 0.00 0 0 0 0 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 2 0.08 0.29 2 2 3 1 Misses in library cache during parse: 1 Optimizer goal: CHOOSE Parsing user id: 02 (USER02) Rows Execution Plan ------- --------------------------------------------------- 0 INSERT STATEMENT GOAL: CHOOSE . ******************************************************************************** insert into tkoptkp select * from tkoptkp call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 1 0.00 0.00 0 0 0 0 Execute 1 0.02 0.02 0 2 3 11 Fetch 0 0.00 0.00 0 0 0 0 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 2 0.02 0.02 0 2 3 11 Misses in library cache during parse: 1 Optimizer goal: CHOOSE Parsing user id: 02 (USER02) Rows Execution Plan ------- --------------------------------------------------- 0 INSERT STATEMENT GOAL: CHOOSE 12 TABLE ACCESS (FULL) OF 'TKOPTKP' ******************************************************************************** select * from tkoptkp where a > 2 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 1 0.00 0.00 0 1 2 10 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 3 0.01 0.01 0 1 2 10 Misses in library cache during parse: 1 Optimizer goal: CHOOSE Parsing user id: 02 (USER02) Rows Execution Plan ------- --------------------------------------------------- 0 SELECT STATEMENT GOAL: CHOOSE 24 TABLE ACCESS (FULL) OF 'TKOPTKP' ********************************************************************************
OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 18 0.40 0.53 30 182 3 0 Execute 19 0.05 0.41 3 7 10 16 Fetch 12 0.05 0.06 4 105 66 78 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 49 0.50 1.00 37 294 79 94 Misses in library cache during parse: 18 Misses in library cache during execute: 1 OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 69 0.49 0.60 9 12 8 0 Execute 103 0.13 0.54 0 0 0 0 Fetch 213 0.12 0.27 40 435 0 162 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 385 0.74 1.41 49 447 8 162 Misses in library cache during parse: 13 19 user SQL statements in session. 69 internal SQL statements in session. 88 SQL statements in session. 17 statements EXPLAINed in this session. ******************************************************************************** Trace file: v80_ora_2758.trc Trace file compatibility: 7.03.02 Sort options: default 1 session in tracefile. 19 user SQL statements in trace file. 69 internal SQL statements in trace file. 88 SQL statements in trace file. 41 unique SQL statements in trace file. 17 SQL statements EXPLAINed using schema: SCOTT.prof$plan_table Default table was used. Table was created. Table was dropped. 1017 lines in trace file.