Beruflich Dokumente
Kultur Dokumente
First, run the following commands from the SQL*Plus command prompt to switch
on timed statistics and to allow for an unlimited trace file size.
If you fail to set TIMED_STATISTICS=TRUE, your database kernel will emit only
zero values instead of real durations into your trace file. If your setting of
MAX_DUMP_FILE_SIZE is too restrictive, you'll suffer the chagrin of generating a
message like the following in your trace file instead of the timing data you
wanted:
Before starting your trace, you can modify the name of the trace file by adding a
TRACEFILE_IDENTIFIER to it. You can do this by an ALTER SESSION command
such as what is below.
Next comes activating the trace itself. There are several ways to do this. The old-
fashioned way is to use the ALTER SESSION command as follows:
alter session set events '10046 trace name context forever, level
12'
/* code to be traced goes here */
alter session set events '10046 trace name context off'
A more elegant way to accomplish the extended SQL trace activation is to use
the DBMS_SUPPORT package:
dbms_support.start_trace(waits=>true, binds=>true)
/* code to be traced goes here */
dbms_support.stop_trace()
To find the trace file, first find the directory where it is located using the
following:
SID
Serial#
Next, run the following commands from the SQL*Plus command prompt to switch on timed
statistics and to allow for an unlimited trace file size.
If you fail to set TIMED_STATISTICS=TRUE, your database kernel will emit only zero values
instead of real durations into your trace file. If your setting of MAX_DUMP_FILE_SIZE is too
restrictive, you'll suffer the chagrin of generating a message like the following in your trace file
instead of the timing data you wanted:
Before starting your trace, you can modify the name of the trace file by adding a
TRACEFILE_IDENTIFIER to it. You can do this by an ALTER SESSION command such as what
is below.
Next comes activating the trace itself. There are several ways to do this. The old-fashioned way is
to use the ALTER SESSION command as follows:
A more elegant way to accomplish the extended SQL trace activation is to use the
DBMS_SYSTEM package:
e.g.
To find the trace file, first find the directory where it is located using the following:
select value from v$parameter where name = 'user_dump_dest';
Introduction.
between any 2 operations
This is a short reference article which summarises the output format of the raw
SQL_TRACE output file. The second part of the article describes the additional
trace lines that may be enabled by the DBMS_SUPPORT package. See Metalink
Note 62294.1 for details of this package.
Note: The format may vary slightly between releases.
PARSING IN CURSOR #<CURSOR> len=X dep=X uid=X oct=X lid=X tim=X hv=X
ad='X' <statement> END OF STMT
<CURSOR> Cursor number.
len Length of SQL statement.
dep Recursive depth of the cursor.
uid Schema user id of parsing user.
oct Oracle command type.
lid Privilege user id.
tim Timestamp.
Pre-Oracle9i, the times recorded by Oracle only have a
resolution of 1/100th of a second (10mS). As of Oracle9i
some times are available to microsecond accuracy
(1/1,000,000th of a second).
The timestamp can be used to determine times between points
the trace file. The value is the value in V$TIMER when the
line was written. If there are TIMESTAMPS in the file you
can use the difference between 'tim' values to determine an
absolute time.
hv Hash id.
ad SQLTEXT address (see <View:V$SQLAREA> and <View:V$SQLTEXT>).
PARSE #<CURSOR>:c=0,e=0,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=4,tim=0
EXEC #<CURSOR>:c=0,e=0,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=4,tim=0
FETCH #<CURSOR>:c=0,e=0,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=4,tim=0
UNMAP #<CURSOR>:c=0,e=0,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=4,tim=0
- OPERATIONS:
STAT #<CURSOR> id=N cnt=0 [pid=0 pos=0 obj=0 op='SORT AGGREGATE ']
STAT Lines report explain plan statistics for the numbered <CURSOR>.
id Line of the explain plan which the row count applies to (starts at
line 1). This is effectively the row source row
count for all row sources in the execution tree.
cnt Number of rows for this row source.
==========================================================
The items below are only output if WAITS or BINDS are being traced.
These can be enabled with the DBMS_SUPPORT package.
==========================================================
BINDS #%d: bind 0: dty=2 mxl=22(22) mal=00 scl=00 pre=00 oacflg=03 oacfl2=0 size=24
offset=0 bfp=02fedb44 bln=22 avl=00 flg=05 value=10
BIND
Variables bound
to a cursor.
WAIT #1: nam="db file scattered read" ela= 5 p1=4 p2=1435 p3=25
WAITing under CURSOR no 1
for "db file scattered read"
We waited 0.05 seconds
For a read of: File 4, start block 1435, for 25 Oracle
blocks
WAIT #1: nam="db file sequential read" ela= 4 p1=4 p2=1224 p3=1
WAITing under CURSOR no 1
for "db file sequential read"
We waited 0.04 seconds for a single block read (p3=1)
from file 4, block 1224.
HOW TO find SQL trace file directories
Platform: Oracle App:
DB Ver: 9.2 App Ver:
Revision Date: 17-Sep-2005 Keyword HOWTO, TRACE FILES, DIRECTORIES, DIRECTORY
s:
Goal
To find directories on the database server where SQL trace files are located
Facts
Solution
The following SQL script will find the SID and SERIAL# required to activate a
session specific SQL trace, together with supporting information about that
session.
SELECT
s.sid db_sid
,s.serial# db_serial
,p.spid os_pid
,to_char(s.logon_time, 'YYYY/MM/DD HH24:MI:SS') db_logon_time
,nvl(s.username, 'SYS') db_user
,s.osuser os_user
,s.machine os_machine
,nvl(decode(instr(s.terminal, chr(0))
,0
,s.terminal
,substr(s.terminal, 1, instr(s.terminal, chr(0))-1)),'none')
os_terminal
,s.program os_program
from
v$session s
,v$process p
where 1=1
and s.paddr = p.addr
and s.username like upper('&1')
/
HOW TO find a concurrent program's trace file
Platform: Oracle App:
DB Ver: 9.2 App Ver:
Revision Date: 28-Jun-2006 Keyword HOWTO, TRACE, CONCURRENT PROGRAM
s:
Goal
To find the SQL trace file for a concurrent program
Facts
Solution
Run the following script:
prompt
ACCEPT request prompt 'Please enter the concurrent request id for
the appropriate concurrent program:'
prompt
SELECT
req.request_id
,req.logfile_node_name node
,req.oracle_Process_id
,req.enable_trace
,dest.VALUE||'/'||LOWER(dbnm.VALUE)||'_ora_'||
oracle_process_id||'.trc' trace_filename
,prog.user_concurrent_program_name
,execname.execution_file_name
,execname.subroutine_name
,phase_code
,status_code
,ses.SID
,ses.serial#
,ses.module
,ses.machine
FROM
fnd_concurrent_requests req
,v$session ses
,v$process proc
,v$parameter dest
,v$parameter dbnm
,fnd_concurrent_programs_vl prog
,fnd_executables execname
WHERE 1=1
AND req.request_id = &request
AND req.oracle_process_id=proc.spid(+)
AND proc.addr = ses.paddr(+)
AND dest.NAME='user_dump_dest'
AND dbnm.NAME='db_name'
AND req.concurrent_program_id = prog.concurrent_program_id
AND req.program_application_id = prog.application_id
AND prog.application_id = execname.application_id
AND prog.executable_id=execname.executable_id
HOW TO trace SQL*Plus client
trace_level_client = 16
trace_file_client = cli.trc
trace_directory_client = c:\tmp
trace_unique_client = on
trace_timestamp_client = on
trace_filelen_client = 100
trace_fileno_client = 2
log_file_client = cli
log_directory_client = c:\tmp
tnsping.trace_directory = c:\tmp
tnsping.trace_level = admin