Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

How To Use SQL Trace And TKPROF For Performance Issues with EBusiness To

Suite (Doc ID 980711.1) Bottom

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:

 Parse, execute, and fetch counts


 CPU and elapsed times
 Physical reads and logical reads
 Number of rows processed
 Misses on the library cache
 Username under which each parse occurred
 Each commit and rollback

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.

Using the SQL Trace Option and TKPROF Utility

1. Set initialization parameters for trace file management.


2. Enable the SQL Trace facility for the desired session, and run the application.
3. Run TKPROF to translate the trace file created in Step 2 into a readable output file. This
step can optionally create a SQL script that can be used to store the statistics in a
database.
4. Interpret the output file created in Step 3.Formatting Trace File with TKPROF

Formatting Trace File with TKPROF

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 sample shows the following information:

 The text of the SQL statement.


 The SQL trace statistics in tabular form.
 The number of library cache misses for the parsing and execution of the statement.
 The user initially parsing the statement.
 The execution plan generated by EXPLAIN PLAN.
 TKPROF also provides a summary of user level statements and recursive SQL calls for
the trace file.

Examples of TKPROF Statement

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:

TKPROF dlsun12_jane_fg_sqlplus_007.trc OUTPUTA.PRF EXPLAIN=scott/tiger


TABLE=scott.temp_plan_table_a INSERT=STOREA.SQL SYS=NO SORT=(EXECPU,FCHCPU)

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.

Interpreting TKPROF Output

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

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. 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.

Generating a Trace File for Forms

- Help > Diagnostics

Select one of the following options:

 Regular Trace
 Trace with Binds
 Trace with Waits
 Trace with Binds and Waits

The following message will be displayed:

"You have enabled SQL tracing for this form and any other form you open.  You trace file is
located at ..."

- Reproduce the performance issue.

- Disable the trace.


The following SQL can also be used to check where the trace file has been stored:
SELECT t1.VALUE
FROM v$parameter t1
WHERE t1.NAME = 'utl_file_dir'

Generating a Trace File for a Concurrent Program

- Enable the trace option by selecting the Enable Trace Checkbox in the concurrent program
definition.

- Reproduce the performance issue.

- Disable the trace option by unchecking the Enable Trace Checkbox in the concurrent program
definition.

Generating a Trace File for Java Programs

- Navigation:

Responsibility = System Administrator


Security > Profile
User: Enter User name of the user facing the issue.
Query the Profile: FND: Diagnostics
Set the FND:Diagnostics profile to Yes at User level.
- Login into Self Service under the same user used to set the profile value.

- Navigate to the point immediately before the error is received, if any.

- 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.

- A page with a set of options is displayed.


Disable Trace
Trace (regular)
Trace with binds
Trace with waits
Trace with binds and waits
- Choose Trace with binds and waits

- Click Save.

- Return back to the page and reproduce the error, if any.

- Turn off Trace.


Select the Diagnostic icon.
Click on option: Set Trace Level
Click Go
Select : Disable Trace
- Note the trace id numbers - there will be more than one and exit the Application

- 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.

tkprof hrab51_ora_18190.trc <output_file.tkp> explain=apps/<apps pw>


sort=‘(prsela,exeela,fchela)

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.

You might also like