Re: [HACKERS] Re: bug on aggregate function AVG()

From: "Thomas G(dot) Lockhart" <lockhart(at)alumni(dot)caltech(dot)edu>
To: Sferacarta Software <sferac(at)bo(dot)nettuno(dot)it>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [HACKERS] Re: bug on aggregate function AVG()
Date: 1998-11-04 15:16:28
Message-ID: 36406FCC.8C3B9F32@alumni.caltech.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> I don't know what does the word "hosed" mean Tom, I hope you don't
> want to tell me there's no solution for this problem.

As you guessed, "hosed" isn't good ;)

> I see that AVG() and SUM() uses an accumulator not enough big to hold
> the result of calculation, but the point is: should we consider this
> thing a "terrible" bug or an acceptable feature ?
> What about to convert every accumulator to float8 ?

imho we can't do that because we lose the exact qualities of integers.
If you accumulate in float8, and if you take a sum over a very large
table, you might start ignoring values. That is, if you have accumulated
15 or 16 digits worth of number, and then try adding 1 as the next
number, the result will be the same as the input. With integers that is
never the case, but we have to deal with overflows better.

I would think we should start signalling overflows rather than silently
overflowing, but I'm not sure what that entails.

> Anyway I think we need to work a little bit on aggregates:
> MIN() and MAX() doesn't accept a string as parameter.

Yes, at the moment only numeric quantities are supported.

> SUM() and AVG() gives a wrong result because it goes on overflow.
> and none of them allows the clause DISTINCT.

Yes, SELECT SUM(DISTINCT i) FROM t; is not yet supported. That's a
project for v6.5.

btw, I'm also planning on working on your "NULL problem" you mentioned
earlier...

- Tom

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas G. Lockhart 1998-11-04 15:19:03 Re: [HACKERS] Warning!!
Previous Message A James Lewis 1998-11-04 15:04:02 Re: [HACKERS] Warning!!