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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Query Performance: Using DECODE() instead of IN()

Re: Query Performance: Using DECODE() instead of IN()

From: Lothar Armbruester <lothar.armbruester_at_t-online.de>
Date: Mon, 20 Oct 2003 18:32:09 +0200
Message-ID: <PM0003CA20E332D041@hades.none.local>


Paul Tomlinson wrote:
> Guys, a question,
>
> Which is the more effecient way of running a query:
>
> select * from x where decode(y,'Y',1,'Q',1,0) = 1
>
> or
>
> select * from x where y in ('Y','Q')
>
> I think I recall somewhere that using a decode uses an index scan
> where
> using IN() uses a full table scan, however I can't seem to prove this.
>

Hello Paul,

AFAIK applying a function on a column value prevents any index on that column from being used. (Unless you have a function based index which uses that function)
So in your case, the version using 'in' does at least have a chance using an index whereas the version with 'decode' does not.

Hope that hepls,
Lothar

-- 
Lothar Armbrüster       | la_at_oktagramm.de
Hauptstr. 26            | la_at_heptagramm.de
D-65346 Eltville        | lothar.armbruester_at_t-online.de
Received on Mon Oct 20 2003 - 11:32:09 CDT

Original text of this message

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