Reprinted: http://yedward.net/?id=140
start trace file
1. exec dbms_monitor.session_trace_enable
(Many times, it is not the process of the current user that needs to be tracked, but other users. At this time, it can be achieved through the dbms_system.set_sql_trace_in_session provided by the system. The set_sql_trace_in_session method has three parameters, namely sid, serial# and true (or false), When it is true, it means that tracking is enabled, and when it is false, it means that tracking is turned off. sid and serial# can be found by searching the v$session view, or you can refer to the v$process view. The example is as follows, executed in the command window
exec dbms_system.set_sql_trace_in_session(10, 223, true) -- 启用
exec dbms_system.set_sql_trace_in_session(10. 223, false) -- 停止)
2. Find trace files
SELECT d.value || '/' || lower(rtrim(i.instance,
chr(0))) || '_ora_' || p.spid || '.trc' trace_file_name FROM (SELECT p.spid
FROM v$mystat m,
v$session s,
v$process p
WHERE m.statistic# = 1
AND s.sid = m.sid
AND p.addr = s.paddr) p,
(SELECT t.instance
FROM v$thread t,
v$parameter v
WHERE v.name = 'thread'
AND (v.value = 0 OR t.thread# = to_number(v.value))) i,
(SELECT VALUE
FROM v$parameter
WHERE NAME = 'user_dump_dest') d
3. After finding the trace file, execute t tkprof dcs_m000_5956.trc result.txt
Here are some performance numbers that are commonly seen in tkprof generated files:
count: Indicates the number of database calls performed.
cpu: Indicates the CPU time spent processing data calls, in seconds.
elapsed: Indicates the total time spent processing database calls, in seconds.
disk: Indicates the number of data blocks physically read.
query: Indicates the number of blocks read from the cache logic in consistent mode.
current: Indicates the number of blocks read from the cache logic in the current mode.
rows: Indicates the number of data rows processed.