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

 
 Home
 E-mail Us
 Oracle Articles
New 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  

Don Burleson Blog 


 

 

 


 

 

 
 

Using BINARY_FLOAT and BINARY_DOUBLE datatypes


Oracle Tips by Burleson Consulting

 

The following Tip is from the outstanding book "Oracle PL/SQL Tuning: Expert Secrets for High Performance Programming" by Dr. Tim Hall, Oracle ACE of the year, 2006:

Like the PLS_INTEGER mentioned previously, the BINARY_FLOAT and BINARY_DOUBLE types in Oracle 10g use machine arithmetic and require less storage space, both of which make them more efficient than the NUMBER type.  They do not always represent fractional values precisely and may be affected by rounding differently than NUMBER types, so they should not be used where accuracy is paramount.

The float_double_test.sql script compares the performance of the NUMBER, BINARY_FLOAT and BINARY_DOUBLE types.

float_double_test.sql

SET SERVEROUTPUT ON
DECLARE
  l_number1         NUMBER := 1;
  l_number2         NUMBER := 1;
  l_binary_float1   BINARY_FLOAT := 1;
  l_binary_float2   BINARY_FLOAT := 1;
  l_binary_double1  BINARY_DOUBLE := 1;
  l_binary_double2  BINARY_DOUBLE := 1;
  l_loops           NUMBER := 10000000;
  l_start           NUMBER;
BEGIN
  -- Time NUMBER.
  l_start := DBMS_UTILITY.get_time; 

  FOR i IN 1 .. l_loops LOOP
    l_number1 := l_number1 + l_number2;
  END LOOP;
 
  DBMS_OUTPUT.put_line('NUMBER         : ' ||
                       (DBMS_UTILITY.get_time - l_start));

  -- Time BINARY_FLOAT.
  l_start := DBMS_UTILITY.get_time; 

  FOR i IN 1 .. l_loops LOOP
    l_binary_float1 := l_binary_float1 + l_binary_float2;
  END LOOP; 

  DBMS_OUTPUT.put_line('BINARY_FLOAT   : ' ||
                       (DBMS_UTILITY.get_time - l_start));

  -- Time BINARY_DOUBLE.
  l_start := DBMS_UTILITY.get_time; 

  FOR i IN 1 .. l_loops LOOP
    l_binary_double1 := l_binary_double1 + l_binary_double2;
  END LOOP; 

  DBMS_OUTPUT.put_line('BINARY_DOUBLE  : ' ||
                       (DBMS_UTILITY.get_time - l_start));
END;
/

The output of the script run against and Oracle 10g database is displayed below.

SQL> @float_double_test.sql

NUMBER         : 194
BINARY_FLOAT   : 101
BINARY_DOUBLE  : 104

PL/SQL procedure successfully completed.

From this we can see that the performance of the new types are comparable to each other and are nearly twice the speed of the NUMBER type.

The process of compiling PL/SQL code to native shared libraries is the subject of the next section.

 

This is an excerpt from the bestselling book "Oracle PL/SQL Tuning: Expert Secrets for High Performance Programming" by Dr. Tim Hall, Oracle ACE of the year, 2006.

You can buy the book for only $23.95 (30%-off) when you buy directly from the publisher, and you also get instant access to the code depot of PL/SQL tuning scripts:


 

 
��  
 
 
Oracle Training at Sea
 
 
 
 
oracle dba poster
 

 
Follow us on Twitter 
 
Oracle performance tuning software 
 
Oracle Linux poster
 
 
 

 

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 -  2017

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.

Remote Emergency Support provided by Conversational