Re: Optimizing numeric SUM() aggregate - Mailing list pgsql-hackers

From Dean Rasheed
Subject Re: Optimizing numeric SUM() aggregate
Date
Msg-id CAEZATCWgq-BdbjOgvZc-2n4GCv5d6BV0Esxa2H-ew05Vt8QvFg@mail.gmail.com
Whole thread Raw
In response to Re: Optimizing numeric SUM() aggregate  (Andrew Borodin <borodin@octonica.com>)
List pgsql-hackers
On 27 July 2016 at 10:17, Andrew Borodin <borodin@octonica.com> wrote:
>>   if (accum->maxdig > (INT_MAX - INT_MAX / NBASE) / (NBASE - 1))
> Woth noting that (INT_MAX - INT_MAX / NBASE) / (NBASE - 1) == INT_MAX
> / NBASE for any NBASE > 1

Interesting. I think it's clearer the way it is in mul_var() though,
because the intention is to avoid letting digits exceed INT_MAX -
INT_MAX/NBASE, so that there is no danger of overflow in the carry
propagation step. The long form makes that clearer (and is just as
efficient, since these expressions will be evaluated by the
preprocessor).

Regards,
Dean



pgsql-hackers by date:

Previous
From: Dean Rasheed
Date:
Subject: Re: Optimizing numeric SUM() aggregate
Next
From: Craig Ringer
Date:
Subject: Re: handling unconvertible error messages