日期:2014-05-16  浏览次数:20541 次

number 和binary_float binary_double 性能比较

Number类型和float类型的比较

http://blog.csdn.net/wyzxg/article/details/6184877

 

SQL> create table zfk_test03
  2  ( number_type number,float_type binary_float,double_type binary_double);
 
Table created
 
SQL> insert into zfk_test03 select rownum,rownum,rownum from dba_objects;
 
139815 rows inserted
 
SQL> commit;
 
Commit complete
 
SQL> set timing on;

SQL> select sum(sin(number_type)) from zfk_test03;
 
SUM(SIN(NUMBER_TYPE))
---------------------
     1.40583495761752
 
Executed in 3.031 seconds
 

再次运算下
SQL> select sum(sin(number_type)) from zfk_test03;
 
SUM(SIN(NUMBER_TYPE))
---------------------
     1.40583495761752
 
Executed in 2.797 seconds
 
SQL> select sum(sin(float_type)) from zfk_test03;
 
SUM(SIN(FLOAT_TYPE))
--------------------
    1.40583495761753
 
Executed in 0.578 seconds
 
SQL> select sum(sin(double_type)) from zfk_test03;
 
SUM(SIN(DOUBLE_TYPE))
---------------------
     1.40583495761753
 
Executed in 0.453 seconds

 

看样子FLOAT确实比NUMBER快NB


SQL> select sum(number_type) from zfk_test03;
 
SUM(NUMBER_TYPE)
----------------
      9774187020
 
Executed in 0.438 seconds
 
SQL> select sum(number_type) from zfk_test03;
 
SUM(NUMBER_TYPE)
----------------
      9774187020
 
Executed in 0.375 seconds


 
SQL> select sum(float_type) from zfk_test03;
 
SUM(FLOAT_TYPE)
---------------
     9774106620
 
Executed in 0.406 seconds
 
SQL> select sum(float_type) from zfk_test03;
 
SUM(FLOAT_TYPE)
---------------
     9774106620
 
Executed in 0.375 seconds


 
SQL> select sum(double_type) from zfk_test03;
 
SUM(DOUBLE_TYPE)
----------------
      9774187020
 
Executed in 0.407 seconds
 
SQL> select sum(double_type) from zfk_test03;
 
SUM(DOUBLE_TYPE)
----------------
      9774187020
 
Executed in 0.375 seconds

性能方面是一样的.

一般我们用数字类型基本上都是 SUM()和count()  使用SIN()函数的场景很少