Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

Free Oracle Tips

HTML Text

 Home
 E-mail Us
 Oracle Articles


 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog


 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Analysis
 Design
 Implementation
 Oracle Support


 SQL Tuning
 Security

 Oracle UNIX
 Oracle Linux
 Monitoring
 Remote s
upport
 Remote plans
 Remote
services
 Application Server

 Applications
 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S
upport  
 Development  

 Implementation


 Consulting Staff
 Consulting Prices
 Help Wanted!

 


 Oracle Posters
 Oracle Books

 Oracle Scripts
 Ion
 Excel-DB   


 

 

 


 

 

 
 

Gathering SQL execution details

Oracle Tips by Burleson Consulting
Match 5, 2008

 

In addition to TKPROF (SQL*Trace) and the SQL*Plus "set autotrace on" command, we see new tools for getting additional SQL execution information.

Staring with Oracle9i, we see several exciting new execution plan columns and you can ruin specialized queries to see estimates of resource usage associated with specific steps of Oracle SQL execution: 

  • CPU_COST - The CPU cost of the operation as estimated by the optimizer's cost-based approach. For statements that use the rule-based approach, this column is null. The value of this column is proportional to the number of machine cycles required for the operation. 

  • IO_COST - The I/O cost of the operation as estimated by the optimizer's cost-based approach. For statements that use the rule-based approach, this column is null. The value of this column is proportional to the number of data blocks read by the operation  

  • TEMP_SPACE - The temporary space, in bytes, used by the operation as estimated by the optimizer's cost-based approach. For statements that use the rule-based approach, or for operations that don't use any temporary space, this column is null.

In Oracle 10g, also see gather_plan_statistics hint tips where you can gather estimated rows vs. actual rows.  Oracle claims to use this information to make more intelligent choices of execution plans, but there is a serious problem with this approach. 

1 – The CBO has no a-priori knowledge of the data buffer contents – Because of this shortcoming, the CBO cannot know if the data blocks are already in the RAM data buffers.

2 – CPU costs depend upon system load – The CPU costs associated with servicing an Oracle query depend upon the server load, and CPU costs are generally not important unless the entire Oracle instance is using excessive CPU resources.

 3 – Temporary segment space is transient – Even though the CBO estimates the TEMP_SPACE costs at optimization time, this execution plan will become permanent for the SQL query until the executable is flushed from the library cache.  Hence, obsolete execution plans may be used to execute a query.

Oracle also has two new views to show active work area space, the v$sql_workarea and the v$sql_workarea_active views.  The v$sql_workarea_active view will display all of the work areas that are currently executing in the instance.  Note that small sorts (under 65,535 bytes) are excluded from the view. The v$sql_workarea_active view can be used to quickly monitor the size of all large active work areas.

workarea.sql 

select
   to_number(decode(SID, 65535, NULL, SID)) sid,
   operation_type              OPERATION,
   trunc(WORK_AREA_SIZE/1024)  WSIZE,
   trunc(EXPECTED_SIZE/1024)   ESIZE,
   trunc(ACTUAL_MEM_USED/1024) MEM,
   trunc(MAX_MEM_USED/1024)    "MAX MEM",
   number_passes               PASS
from
   v$sql_workarea_active
order by
   1,2;

Here is a sample listing from this script, showing the work area estimated vs. actual size, plus the memory used for the specific operation.  This is a great way to see the actual RAM used in a sort or hash join operation.

SID OPERATION             WSIZE     ESIZE       MEM   MAX MEM PASS
--- --------------------- ----- --------- --------- --------- ----
 27 GROUP BY (SORT)          73        73        64        64    0
 44 HASH-JOIN              3148      3147      2437      6342    1
 71 HASH-JOIN             13241     19200     12884     34684    1

For more details on gathering run-time SQL execution statistics see my book "Oracle Tuning: The Definitive Reference".

If you like Oracle tuning, you might enjoy my book "Oracle Tuning: The Definitive Reference", with 950 pages of tuning tips and scripts. 

You can buy it direct from the publisher for 30%-off and get instant access to the code depot of Oracle tuning scripts.


 

 

  
 

 
 
 
 
Oracle performance tuning software
 
 

 

 
 
 
Oracle performance Tuning 10g reference poster
 
 
 
Oracle training in Linux commands
 
Oracle training Excel
 
Oracle training & performance tuning books
 

 

Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  and include the URL for the page.


                    









Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


 

Copyright © 1996 -  2012 

All rights reserved.

Oracle © is the registered trademark of Oracle Corporation.