tkprof basic overview

11
Checked for relevance on 10-Feb-2012 TKPROF and Problem Solving ========================== Purpose ------- This document discusses the use of the following: * SQL TRACE * EXPLAIN PLAN * TKPROF Scope & Application -------------------- For users wanting to obtain a query plan and/or execution times for their queries. Related Documents ------------------ The majority of the material covered in this document can be found in the following manuals: * Oracle7 Server SQL Reference * Oracle7 Server Tuning Introduction ------------ Much information can be gathered about the performance of an Oracle database from the dynamic 'V$' views, as these are documented in the Oracle7 Server Manual. Oracle also provides additional performance diagnostic tools to assist in monitoring and tuning the server. The reader should be familiar with the concepts of the Oracle Server initialization file and startup parameters. Most of the suggestions described in this document should be conducted by an experienced DBA. Overview Of SQL TRACE --------------------- The diagnostic tool 'sql trace' provides performance information about individual SQL statements and generates the following statistics for each statement: * parse, execute, and fetch counts

Upload: melissa-miller

Post on 02-Oct-2015

3 views

Category:

Documents


1 download

DESCRIPTION

TKprof Basic overview

TRANSCRIPT

Checked for relevance on 10-Feb-2012

TKPROF and Problem Solving==========================

Purpose-------This document discusses the use of the following: * SQL TRACE * EXPLAIN PLAN * TKPROF

Scope & Application--------------------For users wanting to obtain a query plan and/or execution times for their queries.

Related Documents------------------The majority of the material covered in this document can be found in the following manuals: * Oracle7 Server SQL Reference * Oracle7 Server Tuning

Introduction------------Much information can be gathered about the performance of an Oracledatabase from the dynamic 'V$' views, as these are documented in theOracle7 Server Manual. Oracle also provides additional performancediagnostic tools to assist in monitoring and tuning the server.

The reader should be familiar with the concepts of the Oracle Serverinitialization file and startup parameters. Most of the suggestionsdescribed in this document should be conducted by an experienced DBA.

Overview Of SQL TRACE---------------------The diagnostic tool 'sql trace' provides performance information aboutindividual SQL statements and generates the following statistics foreach statement:

* parse, execute, and fetch counts * CPU and elapsed times * physical reads and logical reads * number of rows processed * misses on the library cache

This information is input to a trace (.trc) file and sql trace can beenabled/disabled for a session or an instance.

Setting Initialization Parameters---------------------------------The following parameters need to be set up in the "init.ora" filefor the particular instance (SID) that you wish to use SQL Trace:

* SQL_TRACE + Enable/Disable SQL Trace for the instance.

Values ------ TRUE Enable statistics to be collected for all sessions. FALSE Disable statistics to be collected for all sessions.

* TIMED_STATISTICS + Enable/Disable the collection of timed statistics, such as CPU and elapsed times.

Values ------ TRUE Enable timing (we usually recommend this) FALSE Default value.

* MAX_DUMP_FILE_SIZE + Specifies the maximum size of trace files operating system blocks.

Values ------ The default value for this is 500 but if your trace file is truncated then increase this value.

* USER_DUMP_DEST + Specifies the destination for the trace file.

Values ------ The default value for this parameter is the default destination for system dumps on your operating system.

Enabling SQL Trace------------------The SQL Trace facility can either be enabled/disabled for an individualsession or the instance.

* To enable the SQL trace facility for your session issue the following SQL statement:

ALTER SESSION SET SQL_TRACE = TRUE;

* To disable the SQL trace facility for your session issue the following SQL statement:

ALTER SESSION SET SQL_TRACE = FALSE;

Enabling TIMED_STATISTICS-------------------------The parameter TIMED_STATISTICS can be enabled/disabled dynamically by using ALTER SYSTEM SET TIMED_STATISTICS = TRUE;

or ALTER SESSION SET TIMED_STATISTICS = TRUE;

To disable set TIMED_STATISTICS = FALSE:

SQL Trace Facility for an Instance----------------------------------Note that if the initialization parameter SQL_TRACE=TRUE, then statisticswill be gathered for ALL sessions. If the facility has been enabled forthe instance, it may be disabled for an individual session by issuing bythe above SQL statement.

Trace Files-----------Oracle will generate trace (.trc) files for every session where the valueof SQL_TRACE = TRUE and write them to the USER_DUMP_DEST destination.If tracing has been enabled for the instance then individual trace fileswill be generated for each session, unless otherwise disabled (see above).Note, that the generated files may be owned by an operating system userother than your own so you may have to get this user to grant you accessbefore you can use TKPROF to format them.

Using TKPROF------------The TKPROF facility accepts as input an SQL trace file and produces aformatted output file. Note that TKPROF can be run on individual orappended trace files to produce the formatted output file.

* For the full syntax of TKPROF see Oracle7 Server Tuning Manual.

* Invoke TKPROF with no arguments and online help is displayed.

Syntax of TKPROF----------------

TKPROF command ::=

>>-- TKPROF filename1 filename2 ----------------------------------------------> | | +- SORT = ---------------------------------+ | | +-- OPTION --+ | | | +---- , ----+ | | V | | |__( OPTION )__|

>-----------------------------------------------------------------------------> | | | | | | +-- PRINT = integer --+ +-- INSERT = filname3 --+ +-- SYS = ---------+ | | +- YES -+ | | +- NO --+

>-----------------------------------------------------------------------------> | | +---------------------------------------- EXPLAIN = user/password ------+ | | +---- TABLE = schema.table ----+

>---------------------------------------------------------------------------->