sum of nulls versus zeroes

  • From: "Mark W. Farnham" <mwf@xxxxxxxx>
  • To: "'ORACLE-L'" <oracle-l@xxxxxxxxxxxxx>
  • Date: Wed, 7 Jun 2017 15:25:06 -0400

sum() as defined by oracle ignores nulls. 

 

It has been at least since Oracle 6 that I measured which was faster: sum()
with a bunch of zeroes or sum() with a bunch of nulls (each with some
non-zero values as well).

 

So I have some existing sqls that have to be modified. Has anyone tested
whether either is significantly faster?

 

An existing case statement produces a null that could just as easily be a
zero.

 

If someone else has tested recently, then I get to be lazy and leverage the
list.

 

Otherwise I'll break down and do the work. I suspect it doesn't matter, but
there might be 100s of millions of null or zero rows in the sum, so a small
difference could matter.

 

Thanks in advance if you have the answer for 12.1 or 12.2 in hand.

 

No need to comment if you don't have the answer. And no, I can just skip the
rows, multiple different columns are being summed.

 

mwf

Other related posts: