Call (800) 766-1884 for Oracle support & training
Free Oracle Tips

Oracle Consulting Support
Oracle Upgrades
Use New Oracle Features
Oracle Replication Support
Oracle Training
Remote Oracle DBA
System Documentation
Oracle Tips
Oracle Performance
 

Free Oracle Tips


 

HTML Text

BC Oracle tuning

Oracle training

Oracle support

Remote Oracle

Redneck
 

Donald K. Burleson

Oracle Utilities Tips


Simple Tracing With autotrace

The autotrace utility is a very underutilized feature of SQL*Plus. It offers statement tracing and instant feedback on any successful SELECT, INSERT, UPDATE or DELETE statement. The utility requires a plan table (for the Explain Plan) under the current user’s schema. In addition, it requires the plustrace or DBA role for the user executing the trace. The source for the PLUSTRACE role can be found in
$ORACLE_HOME/sqlplus/admin/plustrce.sql.

Tracing is enabled via the set autotrace command in SQL*Plus:

SQL> set autotrace on
SQL> select ename from emp where empno = 1122;

no rows selected

Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=CHOOSE
1 0 TABLE ACCESS (BY INDEX ROWID) OF 'EMP'
2 1 INDEX (UNIQUE SCAN) OF 'PK_EMP' (UNIQUE)


Statistics
----------------------------------------------------------
83 recursive calls
0 db block gets
21 consistent gets
3 physical reads
0 redo size
221 bytes sent via SQL*Net to client
368 bytes received via SQL*Net from client
1 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
0 rows processed


autotrace provides instantaneous feedback including the returned rows, execution plan, and statistics. The user doesn’t need to be concerned about trace file locations and formatting since the output is displayed instantly on the screen. This is very important data that can be used to tune the SQL statement.

autotrace supports the following options:

• on – Enables all options.

• on explain – Displays returned rows and the explain plan.

• on statistics – Displays returned rows and statistics.

• trace explain – Displays the execution plan for a select statement without actually executing it.
set autotrace trace explain

• traceonly – Displays execution plan and statistics without displaying the returned rows. This option should be used when a large result set is expected.

autotrace is so easy to use that it should be the first tracing utility used for most SQL performance tuning issues. tkprof can be used for more detailed analysis.

For DBAs requiring the lowest level debugging – oradebug, described in the next section, will do the job.
 


The above is an excerpt from Oracle Utilities - Using Hidden Programs, Import/Export, SQL Loader, oradebug, Dbverify, Tkprof and More by Rampant TechPress (Dave Moore).

It’s only $19.95 and you can order the book and get instant access to the online Oracle utilities scripts:

http://www.rampant-books.com/book_2003_1_utils.htm


 

http://rampant-books.com/book_2003_2_audit.htm

  ”call


Download your Oracle scripts now:

www.oracle-script.com

The definitive Oracle Script collection for every Oracle professional DBA






Oracle reference poster 




Rampant Oracle books     

   

Copyright © 1996 -  2009 by Burleson Enterprises, Inc. All rights reserved.

Oracle® is the registered trademark of Oracle Corporation.