I want to talk about a scenario that we can use both nvl or case in the select statement. In PL-SQL using nvl will be easier that is true. But when it comes to query (in select statement)
will using nvl make it slower? I have a package that have loads of select statement with NVl. If I replace them with case will it work faster?
For example;
select case sum(nvl(birikim,0)) when null then 0 else sum(nvl(birikim,0) end
instead of using this,
select nvl(sum(nvl(birikim, 0)), 0))
I doubt you will see a great performance increase. Built in functions are very optimized. On the other hand, any function that you use on
SELECTstatement will have impact in performance, unless your indexes take the function in consideration.My suggestion: run an
EXPLAIN PLANon both queries to check the performance.If there is not that much difference, take readability into consideration. Having
NVLinstead ofCASEwill make it more readable. Sometimes you have to balance performance with maintainability.