Free Oracle Tips

Oracle Consulting Oracle Training Development

Remote DBA

 

Remote DBA Plans
Remote DBA Service

 
Remote DBA Oracle Home
Remote DBA Oracle Training
Remote DBA SQL Tuning Consulting
Remote DBA Oracle Tuning Consulting
Remote DBA Data Warehouse Consulting
Remote DBA Oracle Project Management
Remote DBA Oracle Security Assessment
Remote DBA Unix Consulting
Burleson Books
Burleson Articles
Burleson Web Courses
Burleson Qualifications
Oracle Internals Magazine
Oracle Links
Remote DBA Oracle Monitoring
Remote DBA Support Benefits
Remote DBA Plans & Prices
Our Automation Strategy
What We Monitor
Oracle Apps Support
Print Our Brochure
Contact Us (e-mail)
Oracle Job Opportunities
Oracle Consulting Prices





   

 


        
 

 SQL*Plus AUTOTRACE
Oracle Tips by Burleson Consulting

Advanced Oracle Utilities: The Definitive Reference by Rampant TechPress is written by top Oracle database experts (Bert Scalzo, Andrew Kerber, Donald Burleson, and Steve Callan).  The following is an excerpt from the book.

Sometimes the explain plan by itself does not provide sufficient information because although there is now an idea of the procedural logic or algorithm used to process the query, the plan itself does not provide any realistic work execution context or background by which to measure. How can one actually tell if a full table scan is really better than an indexed search if the work actual performed for each is unknown? What is needed is an extended “explain plan” capability – one where both the estimated algorithm and its net resulting workload are displayed. Fortunately, Oracle has built that exact feature into SQL*Plus, and it is one of the most useful ways to work with and/or measure explain plan effectiveness. It is called SQL*Plus AUTOTRACE.

 

SQL*Plus AUTOTRACE requires some initial setup before it can be used, much like explain plans, meaning that some scripts need to be run. The user must be granted a special role known as PLUSTRC in order to use AUTOTRACE, or they will see the error message shown here:

 

Figure 5.9:  Error Message without PLUSTRC

In order to setup AUTOTRACE, the DBA must perform the following two steps. First, they must run the $ORACLE_HOME/sqlplus/admin/plustrce.sql script shown below to create the PLUSTRACE role. Then that PLUSTRACE role simply needs to be granted as a default enabled role to any users who want to utilize this facility.

 

plustrce.sql script

 

set echo on

 

drop role plustrace;

create role plustrace;

 

grant select on v_$sesstat to plustrace;

grant select on v_$statname to plustrace;

grant select on v_$mystat to plustrace;

grant plustrace to dba with admin option;

 

set echo off

 

Once the proper setup steps have been completed, there is now a much improved explain plan output, one with both the estimated algorithm and the actual work performed to run it as shown in Figure 5.10. The SQL*Plus user merely has to include a SET AUTOTRACE ON command. Now information can be received about the actual work performs like logical reads, physical reads, sorts and such.

 

Figure 5. 10:  
SQL*Plus Auto-Trace Output

 

Note: Although the SQL*Plus AUTOTRACE facility is easy to use and generates a lot of useful information, the DBA or developer can gather much more detailed information via the session level trace facility. This is a quick and dirty approach. When better information is needed, favor session-level trace output.



Fo
r more details on Oracle utilities, see the book "Advanced Oracle Utilities" by Bert Scalzo, Donald K. Burleson, and Steve Callan.

You can buy it direct from the publisher for 30% off directly from Rampant TechPress.


     

Remote DBA Service
 

Oracle Tuning Book

Free Oracle dictionary reference poster

BC Oracle support

Oracle books by Rampant

Oracle monitoring software

North Carolina Oracle Users Group

 

 Arabian horse breeder

Seeing eye horses

 

 

 

 

 

Burleson is the American Team

American Flag

 

 

BC Remote Oracle Support
P.O. Box 511 • Kittrell, NC, 27544

Remote DBA

Remote DBA Services

 

Copyright © 1996 -  2011 by Burleson Enterprises. All rights reserved.

Oracle® is the registered trademark of Oracle Corporation.