Oracle TKPROF & SQL_TRACE(=10046 level 1)

Oracle TKPROF & SQL_TRACE
Version 11.1
 
General Information
Note: Use "dbms_monitor.session_trace_enable()" instead of "alter session set events ..." and you will see the columns sys.gv_$session updated

TKPROF stands for TransientKernel Profiler

Event Numbering Range10000 - 10999

Event Definitions
Event #LevelDescription
8186-

ALTER SESSION SET EVENTS '8186 trace name context OFF' - VERSIONS BETWEEN query

100131Monitor Transaction Recovery
100151Dump Undo Segment Headers
100153Identify corrupt undo segments
100324Dump Sort Statistics
10031 Sort Debug Events
1003210Dump Sort Statistics
100334Dump Sort Large Run Statistics (blocks dumped to disk and read back)- poss. no levels.
1003310Dump Sort Intermediate Run Statistics
100451Trace Free List Management Operations
100460No statistics generated
100461Standard trace output including parsing, executes and fetches plus more
100462Same as Level 1
100464Level 1 + Bind Variables
100468Level 1 + Waits
1004612Level 1 + Bind Variables & Waits
1004616Added in 11g to generate STAT line dumps for each execution. STAT dumping has been amended in 11g so that they are not aggregated across all executions but are dumped after execution.
100531Dump Optimizer Statistics and Computations
100532Dump Optimizer Computations only
100601Dump Predicates
100651Restrict Library Cache Output for State Object Dumps - Library Objects Only
100652Restrict Library Cache Output for State Object Dumps + library object lock details
100653Restrict Library Cache Output for State Object Dumps + library object handle and library object
100792Dump SQL*Net Statistics
100811Dump High Water Mark Changes
1010410Dump Hash Join Statistics
101281Dump Partition Pruning Information
101282Dump partition iterators
101284Dump optimizer decisions about partition-wise joins
101288Dump ROWID range scan pruning information
1013212Dumps SQL statements into UDUMP along with the actual execution plan
102001Dump Consistent Reads
102011Dump Consistent Read Undo Application
1021010Table Integrity Check
1021110Index Integrity Check
102201Dump Changes to Undo Header
102217Dump Undo Changes
102241Dump Index Block Splits / Deletes
102251Dump Changes to Dictionary Managed Extents
1023110Causes full table scans to skip corrupt blocks, rather than fail with an ORA-1578 error
1023210Causes corrupt blocks to be dumped to the process trace file
1023310Traces memory usage statistics
102351Check memory manager internal structures (use with ORA-600/ORA-7445 errors)
102411Dump Remote SQL Execution
102461Trace PMON Process
1024810Trace Dispatcher Processes
1024910Trace Shared Server (MTS) Processes
1027010Debug Shared Cursors
102891Dump a database block in hexadecimal
102991Debug Prefetch
103571Debug Direct Path
103591Stops writes to the control file during NOLOGGING operations: May substantially improve performance
103900x0001Dump Parallel Execution Slave Statistics -  Slave-side execution messages
103900x0002Dump Parallel Execution Slave Statistics -  Coordinator-side execution messages
103900x0004Dump Parallel Execution Slave Statistics -  Slave context state changes
103900x0008Dump Parallel Execution Slave Statistics -  Slave ROWID range bind variables and xty
103900x0010Dump Parallel Execution Slave Statistics -  Slave fetched rows as enqueued to TQ
103900x0020Dump Parallel Execution Slave Statistics -  Coordinator wait reply handling
103900x0040Dump Parallel Execution Slave Statistics -  Coordinator wait message buffering
103900x0080Dump Parallel Execution Slave Statistics -  Slave dump timing
103900x0100Dump Parallel Execution Slave Statistics -  Coordinator dump timing
103900x0200Dump Parallel Execution Slave Statistics -  Slave dump allocation file number
103900x0400Dump Parallel Execution Slave Statistics -  Terse format for debug dumps
103900x0800Dump Parallel Execution Slave Statistics -  Trace CRI random sampling
103900x1000Dump Parallel Execution Slave Statistics -  Trace signals
103900x2000Dump Parallel Execution Slave Statistics -  Trace parallel execution granule operations
103900x4000Dump Parallel Execution Slave Statistics -  Force compilation by slave 0
103910x0001Dump Parallel Execution Granule Allocation - Summary of each object scanned in parallel
103910x0002Dump Parallel Execution Granule Allocation - Full dump of each object except extent map
103910x0004Dump Parallel Execution Granule Allocation - Full dump of each object including extent map
103910x0010Dump Parallel Execution Granule Allocation - Summary of each granule generators
103910x0020Dump Parallel Execution Granule Allocation - Granule generators except granule instances
103910x0040Dump Parallel Execution Granule Allocation - Granule generators including granule instances
103910x0080Dump Parallel Execution Granule Allocation - System information
103910x0100Dump Parallel Execution Granule Allocation - Reference object for the query
103910x0200Dump Parallel Execution Granule Allocation - kxfralo timing
103910x0400Dump Parallel Execution Granule Allocation - Affinity module
103910x0800Dump Parallel Execution Granule Allocation - Granule allocation during query execution
103910x1000Dump Parallel Execution Granule Allocation - Object flush
103931Dump Parallel Execution Statistics
104011KSXP tracing - event 10401 trace name context forever, level 1 (for RAC kernel)
104021SKGXP tracing - event 10402 trace name context forever, level 1 (for RAC kernel) minimal tracing
10402127SKGXP tracing - event 10402 trace name context forever, level 1 (for RAC kernel) maximum tracing
105001Trace SMON Process
1060810Trace Bitmap Index Creation
107041Trace Enqueues
107061Trace Global Enqueue Manipulation
1070810Trace RAC Buffer Cache
107101Trace Bitmap Index Access
107111Trace Bitmap Index Merge Operation
107121Trace Bitmap Index OR Operation
107131Trace Bitmap Index AND Operation
107141Trace Bitmap Index MINUS Operation
107151Trace Bitmap Index Conversion to ROWIDs
107161Trace Bitmap Index Compress / Decompress
107171Trace Bitmap Index Compaction
10719110719 - Trace Bitmap Index DML
107301Trace Fine Grained Access Predicates
107311Trace CURSOR Statements
107312Trace CURSOR Statements
108512Disables error 24005 when attempting to manually drop a queue table
10852 Enable dumping of the AQ statistics hash table
10853 Event for AQ statistics latch cleanup testing
10856 Disable AQ propagator from using streaming
10857 Force AQ propagator to use two-phase commit
10858 Crash the AQ propagator at different stages of commit
10859 Disable updates of message retry count
10860 Event for AQ admin disable new name parser
10861 Disable storing extended message properties
108621Resolve default queue owner to current user in enqueue/dequeue
10901 Disable extent trimming
109281Trace PL/SQL Execution
109381Trace PL/SQL Execution Statistics
29700 Enable the collection of DLM lock conversion statistics to query GV$DLM_CONVERT_LOCAL and GV$DLM_CONVERT_REMOTE
444100xmlagg() with a GROUP BY can fail withORA-22813 if the result is too large. No statistics
444101Basic statistics CURSOR, PARSE, EXEC, FETCH ERROR, SORT UMAP, ERROR, UMAP, STATS and XCTEND. Same as setting sql_trace=true.
444102Same as level 1
444104Level 1 plus binds
444108Level 1 plus wait events
4441012Combine levels 4 and 8
 
ShowDoc

10060 Event

10128 Event

CREATE TABLE kkoipt_table (
c1 INTEGER,
c2 VARCHAR2(80);
CREATE TABLE kkpap_pruning (
partition_count  NUMBER,
iterator         VARCHAR2(32),
partition_level  VARCHAR2(32),
order_pt         VARCHAR2(12),
call_time        VARCHAR2(12),
part#            NUMBER,
subp#            NUMBER,
abs#             NUMBER);
 
Trace File Locations$ORACLE_BASE/admin/sid_name/

bdump ... alert logs and system generated trace files
cdump ... core dumps
udump ... user generated trace files
Grant public access to all views used by TKPROF with verbose=y option.$ORACLE_HOME/rdbms/admin/utltkprf.sql
Add timed statistics to trace fileconn / as sysdba

set linesize 121
col name format a40
col value format a30

SELECT name, value
FROM gv$parameter
WHERE name LIKE 'timed%';

ALTER SYSTEM SET timed_statistics=TRUE;
System Privilege To Enable and Disable TracingGRANT alter session TO <user_name>;
GRANT alter session TO uwclass;

REVOKE alter session FROM uwclass;
 
PFile Entries vs. Alter Session
init.ora Parameter Exampleevent='1401 trace name errorstack, level 12';
 
ALTER SESSION Commands
Start and Stop Session TracingALTER SESSION SET sql_trace = <TRUE | FALSE>;
ALTER SESSION SET sql_trace = TRUE;

ALTER SESSION SET sql_trace = FALSE;
 
Event Tracing Examples
Active Session Historyalter session set events 'immediate trace name ashdump level 10';
Control File Dumpalter session set events 'immediate trace name CONTROLF level 10';
Error Stack (Exception) Tracealter session set events '<error_number_without_leading_zeros> trace name errorstack level 10';
alter session set events '60 trace name errorstack level 10';
File Header Dumpalter session set events 'immediate trace name FILE_HDRS level 10';
Library Cache Dumpalter session set events 'immediate trace name LIBRARY_CACHE level 10';
Process State Dumpalter session set events 'immediate trace name PROCESSSTATE LEVEL 10';
Redo Log Headers Dumpalter session set events 'immediate trace name REDOHDR LEVEL 10';
System State Dumpalter session set events 'immediate trace name SYSTEMSTATE LEVEL 10';
 
Tracing Demo
Go through a 10053 output to find why Oracle ignores a hint or thinks it is smarter than you. One little trick is to grep for lines starting "Join order" and "Best so far." The join order lists tables by table name, so you can see when an order you expected did not survive (or did not reach) the CBO's processing. The "Best so far" appear only when the CBO has decided that the most recent join order has a plan better than the previous best, so you can quickly check the evolution of the plan.
ALTER SESSION SETtracefile_identifier = 'test_plan1';

ALTER SESSION SET EVENTS '10053 trace name context forever, level 1';

ALTER SESSION SET EVENTS '10046 trace name context forever, level 12';

SELECT srvr_id
FROM servers
WHERE srvr_id IN (
   SELECT srvr_id
   FROM serv_inst);

SELECT srvr_id
FROM servers
WHERE srvr_id IN (
   SELECT i.srvr_id
   FROM serv_inst i, servers s
   WHERE i.srvr_id = s.srvr_id);

ALTER SESSION SET EVENTS '10053 trace name context OFF';
ALTER SESSION SET EVENTS '10046 trace name context OFF';
or
ALTER SESSION SET SQL_TRACE=FALSE;

review the trace file in $ORACLE_BASE/diag/orabase/orabase/trace
 
TKPROF

Generate TKPROF Output
TKPROF <trace_file_name> <output_file_name>
[explain=<user/password> [table=<schema.table_name>]]
[print=<integer>]    -- list only the first nth SQL statements
[aggregate=<yes|no>
[insert=<file_name>] -- list SQL statements and data inside INSERT statements
[sys=<no>]           -- TKPROF does not list SQL statements run as user SYS
[record=<file_name>] -- record non-recursive statements in the trace file
[waits=<yes|no>]     -- record summary of for wait events in the trace file
[sort=<sort_options_list>] -- zero or more of the listed sort options
Sort OptionDescription
execntnumber of execute was called
execpucpu time spent executing
execunumber of buffers for current read during execute
exedsknumber of disk reads during execute
exeelaelapsed time executing
exemisnumber of library cache misses during execute
exeqrynumber of buffers for consistent read during execute
exerownumber of rows processed during execute
fchcntnumber of times fetch was called
fchcpucpu time spent fetching
fchcunumber of buffers for current read during fetch
fchdsknumber of disk reads during fetch
fchelaelapsed time fetching
fchqrynumber of buffers for consistent read during fetch
fchrownumber of rows fetched
prscntnumber of times parse was called
prscpucpu time parsing
prscunumber of buffers for current read during parse
prsdsknumber of disk reads during parse
prselaelapsed time parsing
prsmisnumber of misses in library cache during parse
prsqrynumber of buffers for consistent read during parse
useriduserid of user that parsed the cursor
TKPROF c: emp\orabase_ora_1492.trc   c: emp race_out.txt
 
PLSHPROF

Generate PLSHPROF Output
PLSHPROF [<options>] -output <input_file1> [<input_file2>]
 
Note: "output" refers to the output from DBMS_HPROF not the output from PLSHPROF.
OptionsDescriptionDefault
-trace <symbol>Specifies function name of tree rootN/A
-skip <count>Skips first count calls. Use only with -trace symbol0
-collect <count>Collects information for count calls. Use only with -trace symbol1
-output <filename>Specifies name of output fileN/A
-summaryPrints only elapsed timeN/A
plshprof -trace -output hprof_trace.html hprof.trc
 
Related Topics
ASH
DBMS_HPROF
DBMS_MONITOR
DBMS_PROFILER
DBMS_SUPPORT
DBMS_SYSTEM
DBMS_TRACE
Explain Plan
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值