Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Code review... gurus required!
In article <u2qchv8ufv72gm1ueeto10fmg2ish2s30u_at_4ax.com>,
steve_at_itemfront.ltd.uk says...
> Hi All,
>
> I've been asked to do a code review, and came across this line...
>
> select nvl(count(*),0) into variable
>
> ...and I'm not sure if it is necessary! Do you need the nvl() function
> in this pl/sql statement, and will its removal speed things up?
>
> I reckon no and yes, but would appreciate the experts view!
>
> Cheers,
>
> Steve
>
You don't need nvl for count(*). Even if the table is empty, you'll
still get "0".
For other aggregates like avg, sum, min, max etc. you will need nvl if there are no records to aggregate.
Not sure about speed loss, probably tiny.