Function performance question

From: Greg George <a201902>
Date: 1995/11/07
Message-ID: <47o26s$4ec_at_news-srv1.fmr.com>#1/1


Can someone explain why simple functions in Oracle (7.2.2) take such a long time? Is there some way for me to optimize my function compilation?  

For example, I've got a 42,461 row table, TABLE1, with a char(15) field, X. If I run the following query with timing on, this is my output:  

    SQL> select count(*) from TABLE1;  

      COUNT(*)


         42461  

    Elapsed: 00:00:02.54

Now, if I use the to_number built-in function, I get:

    SQL> select count(*) from TABLE1 where to_number(X) > 0;  

      COUNT(*)


         42461  

    Elapsed: 00:00:05.80

And then using my my_to_number function:  

    SQL> create or replace function my_to_number ( x char ) return number is

      2  begin
      3    return(x);
      4  end my_to_number;
      5  /
 

I get:  

    SQL> select count(*) from TABLE1 where my_to_number(X) > 0;  

      COUNT(*)


         42461  

    Elapsed: 00:00:38.66    

Why would such a simple function get such bad performance?  

Any ideas.  

Thanks in advance Received on Tue Nov 07 1995 - 00:00:00 CET

Original text of this message