Re: Weird function behavior from Sept 11 snapshot

From: Thomas Lockhart <lockhart(at)alumni(dot)caltech(dot)edu>
To: Mike Mascari <mascarm(at)mascari(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Weird function behavior from Sept 11 snapshot
Date: 2000-09-12 14:10:03
Message-ID: 39BE393B.38CA2E71@alumni.caltech.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> Is this correct behavior? All of the regression tests pass on the
> snapshot version, BTW.

This is the expected behavior, and is "correct". There was a change
recently to the aggregate functions to make them more robust. So
sum(int4) now calculates and returns a numeric result rather than an
int4.

The problem is that numeric is extremely slow compared to an int4
calculation, and I'd like us to consider doing the calculation in int4
(downside: silent overflow when dealing with non-trivial data), int8
(downside: no support on a few platforms), or float8 (downside: silent
truncation on non-trivial data).

Tom, do you recall measuring the performance difference on aggregate
functions between int4 and numeric for small-value cases? We probably
don't want to take order-of-magnitude performance hits to get this more
correct behavior, but I'm not sure what the performance actually is.

btw, Mike's function works when defined as

create function c(int4) returns int4
as 'select cast(sum(key) as int4) from test' language 'sql';

- Thomas

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2000-09-12 14:12:06 Re: Dibs for upcoming commit
Previous Message Tom Lane 2000-09-12 13:59:11 Re: strange behaviour (bug)