Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
This information is input to a trace (.trc) file and sql trace can be
enabled/disabled for a session or an instance.
SQL_TRACE
+ Enable/Disable SQL Trace for the instance.
Values
-----TRUE
Enable statistics to be collected
for all sessions.
FALSE Disable statistics to be collected
for all sessions.
TIMED_STATISTICS
+ Enable/Disable the collection of timed
statistics, such as CPU and elapsed times.
Values
-----TRUE
Enable timing (we usually recommend this)
FALSE Default value.
MAX_DUMP_FILE_SIZE
+ Specifies the maximum size of trace
files operating system blocks.
Values
-----The default value for this is 500 but if your
trace file is truncated then increase this value.
USER_DUMP_DEST
+ Specifies the destination for the trace file.
Values
-----The default value for this parameter is the default
destination for system dumps on your operating system.
Syntax of TKPROF
---------------TKPROF command ::=
>>-- TKPROF filename1 filename2
---------------------------------------------->
|
+- SORT = ---------------------------------+
|
|
+-OPTION
--+
|
|
|
+---- , ----+
|
|
V
|
|
|__(
OPTION
)__|
>---------------------------------------------------------------------------->
|
|
|
|
|
|
+-- PRINT = integer --+
+-- INSERT = filname3 --+
+-- SYS = ---------+
|
|
+- YES -+
|
|
+- NO --+
>---------------------------------------------------------------------------->
|
|
+---------------------------------------- EXPLAIN = user/password ------+
|
|
+---- TABLE = schema.table ----+
>---------------------------------------------------------------------------><
|
|
+---- RECORD = filname ----+
The Basics Of TKPROF
-------------------For the purpose of this document we will only describe some of the
fundamental arguments for TKPROF:
*
'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 appending together
together individual trace files from multiple sessions.
'filename2'
Specifies the file to which TKPROF writes its
formatted output.
'EXPLAIN'
Determines the execution plan for each SQL statement in
in the trace file and writes these execution plans to
the output file. TKPROF determines execution plans by
issuing the EXPLAIN PLAN command after connecting to
Oracle with the user and password specified in this
parameter. The specified user must have CREATE SESSION
privileges.
'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
to omit them.
Simple Example
-------------This example shows TKPROF being run to format a trace file named
"dsdb2_ora_18468.trc" and writing it to a formatted output file
named "dsdb2_trace.out".
TKPROF dsdb2_ora_18468.trc dsdb2_trace.out SYS=NO EXPLAIN=SCOTT/TIGER
Note that if the command is likely to be longer than a single line on your
terminal screen you may have to use continuation characters.
The Parameters In This Example:
------------------------------The EXPLAIN value causes TKPROF to connect as the user SCOTT and use the
EXPLAIN PLAN command to generate the execution plan for each traced SQL
statement. The SYS parameter with the value of NO causes TKPROF to omit
recursive SQL statements from the output file.
Interpretting TKPROF Output
===========================
The EXPLAIN PLAN Command
-----------------------The EXPLAIN PLAN command displays the execution plan chosen by the
PARSE
This step translates the SQL statement into an execution plan.
This includes checks for proper security authorization and
checks or the existence of tables, columns, and other
referenced objects.
EXECUTE
This step is the actual execution of the statement by Oracle.
For INSERT, UPDATE, and DELETE statements, this step modifies
the data. For SELECT statements, the step identifies the
selected rows.
FETCH
This step retrieves rows returned by a query.
Fetches are only performed for SELECT statements.
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:
COUNT
Number of times a statement was parsed, executed, or fetched.
CPU
Total CPU time in seconds for all parse, execute, or fetch calls
for the statement.
ELAPSED
Total elapsed time in seconds for all parse, execute, or fetch calls
for the statement.
DISK
Total number of data blocks physically read from the datafiles on
disk for all parse, execute, or fetch calls.
QUERY
Total number of buffers retrieved in consistent mode for all parse,
execute, or fetch calls. Buffers are usually retrieved in consistent
mode for queries.
CURRENT
Total number of buffers retrieved in current mode. Buffers are often
retrieved in current mode for INSERT, UPDATE, and DELETE statements.
+
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.
Example Output (Partial) File
----------------------------TKPROF: Release 7.2.2.3.0 - Production on Wed Aug
Copyright (c) Oracle Corporation 1979, 1994.
7 11:29:43 1996
call
count
rows
------- --------------Parse
2
0
Execute
29
19
Fetch
0
0
------- --------------total
31
19
cpu
elapsed
disk
query
current
0.00
12.04
12.61
6786
6853
108
0.00
0.00
12.61
6786
6853
108
Execution Plan
--------------------------------------------------DELETE STATEMENT
HINT: CHOOSE
TABLE ACCESS (FULL) OF 'RM$HASH_ELMS'
*****************************END-OF-EXAMPLEFILE********************************
Resolution of Statistics
-----------------------Since timing statistics have a resolution of one hundredth of a second,
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.
Recursive Calls
--------------Sometimes 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 clearly marks them
as recursive SQL statements in the output file. Note that 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.
Execution Plan
-------------If you specify the EXPLAIN parameter on the TKPROF command line, TKPROF
uses the EXPLAIN PLAN command 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.
-----------------------------------------------------------------------------Worldwide Customer Support Services