select count(*) from table 
where a_column = 
 ( select cdk(123) from dual where rownum = 1 )

or you can use DISTINCT or a NO_MERGE hint - anything
to force the subquery to be evaluated in isolation

hth
connor

 --- David Turner <[EMAIL PROTECTED]> wrote: > My
users are writing many of their own functions and
> it is causing performance to suffer
> on a few simple queries. For example, I have a query
> that just selects count(*) from a
> table. With the function
> 
> select count(*) from a_table where a_column =
> cdk(1234567890);
> 
> It takes 5 minutes
> 
> By plugging in the result of the cdk function into
> the query
> 
> select count(*) from a_table where a_column =
> 0987654321;
> 
> It take .18 of a second.
> 
> How can I tell the optimizer that the result of the
> function will be the same every
> time so you don't need to call it for every row?  I
> can do this in the app but it would
> be cool to know if I can do this on the database
> side also.
> 
> Thanks, Dave
> 
> -- 
> Please see the official ORACLE-L FAQ:
> http://www.orafaq.com
> -- 
> Author: David Turner
>   INET: [EMAIL PROTECTED]
> 
> Fat City Network Services    -- (858) 538-5051  FAX:
> (858) 538-5051
> San Diego, California        -- Public Internet
> access / Mailing Lists
>
--------------------------------------------------------------------
> To REMOVE yourself from this mailing list, send an
> E-Mail message
> to: [EMAIL PROTECTED] (note EXACT spelling of
> 'ListGuru') and in
> the message BODY, include a line containing: UNSUB
> ORACLE-L
> (or the name of mailing list you want to be removed
> from).  You may
> also send the HELP command for other information
> (like subscribing). 

=====
Connor McDonald
http://www.oracledba.co.uk (mirrored at 
http://www.oradba.freeserve.co.uk)

"Some days you're the pigeon, some days you're the statue"

____________________________________________________________
Do You Yahoo!?
Get your free @yahoo.co.uk address at http://mail.yahoo.co.uk
or your free @yahoo.ie address at http://mail.yahoo.ie
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: =?iso-8859-1?q?Connor=20McDonald?=
  INET: [EMAIL PROTECTED]

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).

Reply via email to