Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Performance decission DECODE vs CASE

647681Jul 14 2008 — edited Aug 16 2010
Hi Gurus,

I have a stored procedure that has to process around 2 million records. The performance is very slow at the moment.

I need advise on the following section :-)

CASE x
WHEN '1' THEN
y := 'A';
WHEN '2' THEN
y := 'B';
WHEN '3' THEN
y := 'C';
.
.
.
.
WHEN '...'
y := '...';
END CASE;

There are around 25 different cases, of course the values I put here are dummy...

Can I replace it with DECODE as its 1 to 1 comparison / return like
y := DECODE(x, '1', 'A', '2', 'B', '3', 'C', .... '...', '...');

Is it a faster executing code or CASE better? I know, CASE has its own advantages like readability, flexibility etc. but how about performance in my particular expression set?

Best Regards,
Faisal.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 13 2010
Added on Jul 14 2008
12 comments
15,131 views