Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Problem with Decode fuction

Re: Problem with Decode fuction

From: Anurag Varma <avarmadba.skipthis_at_yahoo.com>
Date: Sun, 28 Sep 2003 20:41:25 GMT
Message-ID: <VHHdb.24324$ZR1.12824@nwrddc01.gnilink.net>

"Tom Miskiewicz" <miskiewicz2_at_yahoo.com> wrote in message news:unHdb.7$p1.19843_at_news.ecrc.de...
> Are there alternatives to the above quesry with respect to performace?
> Or is the comparsion to DUAL the non-plus-ultra of this kind of querys?
>
> Thanks
> Tom
>
>

Usually a query can be written in many different ways. Same is the case with your query.
Your version however did not give correct results (as per your statement).

For example if you had done the following:

SELECT DECODE(COUNT(1), 0, NULL,1) FROM my_table WHERE field1 = 'STRING1' AND
component_type = 'STRING2' AND
component = 'STRING3' AND
plant != 'STRING4';

You actually might have gotten the right results. However, it would have been inefficient.
To understand why the exists query works better, you need to grab a book on performance tuning.
I'd suggest the new Tom Kyte's book.

Anurag Received on Sun Sep 28 2003 - 15:41:25 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US