DeCode Performance

Performance wise which is a better option if-else construct or a decode? Why

Questions by test2008

Showing Answers 1 - 12 of 12 Answers

The answer to this question would actually depend on the type of applicability of the usage that is being done. i.e. is it required in a query or in a PLSQL block. If it is in a query we cannot use if....else we will have to use decode. In a PLSQL block we can use if..else. However, for simple condition checking if..else is better in performance but for using this in sql we would have to use de-code.

In general decode does affect the performance of the query however, if we are using a function based index which has been built by using decode then it might actually be faster.

DECODE is faster than IF-THEN-ELSE

REASON:
Decode is an Oracle built-in function, so no need to pass parameters to this function. Because all the parameters are internally defined but If-then-else statements we should define explicitly, so takes time for execution and converting into P-code.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions