Professional Documents
Culture Documents
How To Use SQL Trace and TKPROF For Performance Issues With EBusiness Suite
How To Use SQL Trace and TKPROF For Performance Issues With EBusiness Suite
In this Document
Abstract
Document History
How To Use SQL Trace And TKPROF For Performance Issues with EBusiness Suite
SQL Trace
TKPROF Utility
Using the SQL Trace Option and TKPROF Utility
Formatting Trace File with TKPROF
TKPROF Analysis
Examples of TKPROF Statement
Parameters Meaning
Interpreting TKPROF Output
SQL Trace Statistic
Generating a Trace File for Forms
Generating a Trace File for a Concurrent Program
Generating a Trace File for Java Programs
Summary
ABSTRACT
This paper explains succinctly the use of SQL Trace and TKPROF to identify and diagnose
performance issues in the Oracle E-Business Suite.
DOCUMENT HISTORY
Author: Luis J. Gonzalez
Create Date 21-Dec-2009
Update Date 21-Dec-2009
HOW TO USE SQL TRACE AND TKPROF FOR PERFORMANCE ISSUES WITH
EBUSINESS SUITE
SQL Trace
SQL Trace is an Oracle option that can be enabled to generate a raw trace file containing the
internal SQL activity when a program is executed. The internal activity obtained when tracing
SQL activity encompasses the following statistics for each statement:
TKPROF Utility
The TKPROF is an Oracle utility used to generate a readable output from a SQL trace file, so
that performance issues can be identified and diagnosed.
TKPROF generates a readable output of a trace file produced by the SQL Trace utility. The
following tasks can be performed after the SQL trace facility has generated a number of trace
files:
Run TKPROF on each individual trace file, producing a number of formatted output files,
one for each session.
Concatenate the trace files, and then run TKPROF on the result to produce a formatted
output file for the entire instance.
TKPROF Analysis
TKPROF Example 1: If you are processing a large trace file using a combination of SORT
parameters and the PRINT parameter, then you can produce a TKPROF output file containing
only the highest resource-intensive statements. For example, the following statement prints the
10 statements in the trace file that have generated the most physical I/O:
TKPROF ora53269.trc ora53269.prf SORT = (PRSDSK, EXEDSK, FCHDSK) PRINT = 10
TKPROF Example 2: This example runs TKPROF, accepts a trace file named
dlsun12_jane_fg_sqlplus_007.trc, and writes a formatted output file named outputa.prf:
Parameters Meaning
The EXPLAIN value causes TKPROF to connect as the user SCOTT and use the EXPLAIN
PLAN statement to generate the execution plan for each traced SQL statement. This option can
be used to get access paths and row source counts.
The TABLE value causes TKPROF to use the table temp_plan_table_a in the schema SCOTT as
a temporary plan table.
The INSERT value causes TKPROF to generate a SQL script named STOREA.SQL that stores
statistics for all traced SQL statements in the database.
The SYS parameter with the value of NO causes TKPROF to omit recursive SQL statements
from the output file. In this way, internal Oracle statements can be ignored, such as temporary
table operations.
The SORT value causes TKPROF to sort the SQL statements in order of the sum of the CPU
time spent executing and the CPU time spent fetching rows before writing them to the output
file. For greatest efficiency, SORT parameters must be always used.
PARSE: Translates the SQL statement into an execution plan, including checks for proper
security authorization and checks for the existence of tables, columns, and other referenced
objects.
EXECUTE: Actual execution of the statement by Oracle. For INSERT, UPDATE, and DELETE
statements, this modifies the data. For SELECT statements, this identifies the selected rows.
FETCH: Retrieves rows returned by a query. Fetches are only performed for SELECT
statements.
SQL Trace Statistic
CPU: Total CPU time in seconds for all parse, execute, or fetch calls for the statement. This
value is zero (0) if TIMED_STATISTICS is not turned on.
ELAPSED: Total elapsed time in seconds for all parse, execute, or fetch calls for the statement.
This value is zero (0) if TIMED_STATISTICS is not turned on.
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. Usually, buffers are retrieved in consistent mode for queries.
CURRENT: Total number of buffers retrieved in current mode. Buffers are retrieved in current
mode for statements such as INSERT, UPDATE, and DELETE.
Regular Trace
Trace with Binds
Trace with Waits
Trace with Binds and Waits
"You have enabled SQL tracing for this form and any other form you open. You trace file is
located at ..."
- Enable the trace option by selecting the Enable Trace Checkbox in the concurrent program
definition.
- Disable the trace option by unchecking the Enable Trace Checkbox in the concurrent program
definition.
- Navigation:
- Click the diagnostic icon at the top of the page. Two options are displayed:
Show Log
Set Trace Level
- Select 'Set Trace Level'
- Click Go.
- Click Save.
- To determine where the raw trace files are located from SQLPlus:
SELECT value
FROM v$parameter
WHERE name = 'user_dump_dest';
The trace id numbers will be part of the name of the trace files.
- Run TKPROF procedure on the raw trace files. For example, hrab51_ora_18190.trc is the
name of the raw trace file and trace1.txt is the name of the TKPROF file.
SUMMARY
SQL Trace and TKPROF are used to identify and diagnose performance issues in the Oracle E-
Business Suite. The SQL Trace register the statistics generated when statements are executed;
these statistics include, among others, parse, execute, and fetch counts, CPU and elapsed times,
and physical reads and logical reads.
The TKPROF utility must be used to obtain a readable and formatted output of the SQL Trace.
The TKPROF report shows relevant information that can be used to identify and improve
performance issues.