pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Heikki Linnakangas <hlinnaka@iki.fi>
To: Andrey Borodin <amborodin@acm.org>
To: pgsql-hackers@postgresql.org
Subject: Re: Optimizing numeric SUM() aggregate
Date: Fri, 2 Sep 2016 11:52:49 +0300
Message-ID: <ac2a41c6-9dba-982f-5e8f-9786ea3555c1@iki.fi> (raw)
In-Reply-To: <20160803174720.1314.6360.pgcf@coridan.postgresql.org>
References: <c0545351-a467-5b76-6d46-4840d1ea8aa4@iki.fi>
	<c0545351-a467-5b76-6d46-4840d1ea8aa4@iki.fi>
	<20160803174720.1314.6360.pgcf@coridan.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

On 08/03/2016 08:47 PM, Andrey Borodin wrote:
> 1. Currenlty overflow is carried every 9999 addition. I suggest that
> it is possibe to do it only every (INT32_MAX - INT32_MAX / NBASE) /
> (NBASE - 1) addition. Please note that with this overflow count it
> will be neccesary to check whether two finishing carrings are
> required.

I left it at (NBASE -1), but added a comment on that. I couldn't measure 
any performance difference between that and a larger interval, so it 
didn't seem worthwhile. The code wouldn't be much more complicated, but 
the math required to explain what the safe maximum is, would be :-).

> 2. Aggregates and numeric regression tests do not containt
> any test case covering overflows. I recommend adding sum with numer 1
> 000 000 of 99 999 999 values. May be you will come up with more
> clever overflow testing.

Hmm. Added a couple of simple SUM() queries to the regression tests, so 
that we have at least some test coverage of the overflows. But nothing 
very clever.

Looking closer, I don't think this implementation is actually dependent 
on NBASE being 10000. So I removed the comment changes that suggested so.

I did some more minor comment fixes, and committed. Thanks for the review!

- Heikki



-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



view thread (13+ messages)

Message-ID: <ac2a41c6-9dba-982f-5e8f-9786ea3555c1@iki.fi>
Permalink:  ../ac2a41c6-9dba-982f-5e8f-9786ea3555c1@iki.fi/
Also on:    postgresql.org/message-id/ac2a41c6-9dba-982f-5e8f-9786ea3555c1@iki.fi

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: hlinnaka@iki.fi, amborodin@acm.org
  Subject: Re: Optimizing numeric SUM() aggregate
  In-Reply-To: <ac2a41c6-9dba-982f-5e8f-9786ea3555c1@iki.fi>
  References: <c0545351-a467-5b76-6d46-4840d1ea8aa4@iki.fi> <20160803174720.1314.6360.pgcf@coridan.postgresql.org> <ac2a41c6-9dba-982f-5e8f-9786ea3555c1@iki.fi>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox